diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.rs b/tests/ui/traits/ice-with-dyn-pointee-errors.rs new file mode 100644 index 00000000000..46cef2c8bc0 --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.rs @@ -0,0 +1,15 @@ +#![feature(ptr_metadata)] +// Address issue #112737 -- ICE with dyn Pointee +extern crate core; +use core::ptr::Pointee; + +fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} + +fn raw_pointer_in(x: &dyn Pointee) { + unknown_sized_object_ptr_in(x) + //~^ ERROR type mismatch resolving ` as Pointee>::Metadata == ()` +} + +fn main() { + raw_pointer_in(&42) +} diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.stderr b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr new file mode 100644 index 00000000000..8ad11c3344a --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr @@ -0,0 +1,19 @@ +error[E0271]: type mismatch resolving ` as Pointee>::Metadata == ()` + --> $DIR/ice-with-dyn-pointee-errors.rs:9:33 + | +LL | unknown_sized_object_ptr_in(x) + | --------------------------- ^ expected `()`, found `DynMetadata>` + | | + | required by a bound introduced by this call + | + = note: expected unit type `()` + found struct `DynMetadata>` +note: required by a bound in `unknown_sized_object_ptr_in` + --> $DIR/ice-with-dyn-pointee-errors.rs:6:50 + | +LL | fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} + | ^^^^^^^^^^^^^ required by this bound in `unknown_sized_object_ptr_in` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/ice-with-dyn-pointee.rs b/tests/ui/traits/ice-with-dyn-pointee.rs new file mode 100644 index 00000000000..9b3b9c8cddf --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee.rs @@ -0,0 +1,11 @@ +// run-pass +#![feature(ptr_metadata)] +// Address issue #112737 -- ICE with dyn Pointee +extern crate core; +use core::ptr::Pointee; + +fn raw_pointer_in(_: &dyn Pointee) {} + +fn main() { + raw_pointer_in(&42) +}