Skip to content

Commit 8c03b96

Browse files
committed
Auto merge of #109581 - matthiaskrgr:rollup-e8fi2vi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #109355 (Fix bad suggestion for clone/is_some in field init shorthand) - #109484 (Bugfix: avoid panic on invalid json output from libtest) - #109539 (Refactor `find_*_stability` functions) - #109542 (rustdoc: clean up `storage.js`) - #109545 (Deeply check well-formedness of return-position `impl Trait` in trait) - #109568 (miri: fix raw pointer dyn receivers) - #109570 (Add GUI test for "Auto-hide item methods' documentation" setting) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7bb7ccb + b7b0461 commit 8c03b96

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/pass/dyn-arbitrary-self.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,35 @@ fn pointers_and_wrappers() {
123123
assert_eq!(wpw.wrapper_ptr_wrapper(), 7);
124124
}
125125

126+
fn raw_ptr_receiver() {
127+
use std::ptr;
128+
129+
trait Foo {
130+
fn foo(self: *const Self) -> &'static str;
131+
}
132+
133+
impl Foo for i32 {
134+
fn foo(self: *const Self) -> &'static str {
135+
"I'm an i32!"
136+
}
137+
}
138+
139+
impl Foo for u32 {
140+
fn foo(self: *const Self) -> &'static str {
141+
"I'm a u32!"
142+
}
143+
}
144+
145+
let null_i32 = ptr::null::<i32>() as *const dyn Foo;
146+
let null_u32 = ptr::null::<u32>() as *const dyn Foo;
147+
148+
assert_eq!("I'm an i32!", null_i32.foo());
149+
assert_eq!("I'm a u32!", null_u32.foo());
150+
}
151+
126152
fn main() {
127153
pin_box_dyn();
128154
stdlib_pointers();
129155
pointers_and_wrappers();
156+
raw_ptr_receiver();
130157
}

0 commit comments

Comments
 (0)