From 09f05489e34f54f3e1f89350651bbcbd564dbbf7 Mon Sep 17 00:00:00 2001 From: Anthony Kalaitzis Date: Tue, 27 Jun 2023 17:52:26 +0930 Subject: [PATCH] Add passing & failing test for bultin dyn trait generation --- .../ui/traits/ice-with-dyn-pointee-errors.rs | 15 +++++++++++++++ .../traits/ice-with-dyn-pointee-errors.stderr | 19 +++++++++++++++++++ tests/ui/traits/ice-with-dyn-pointee.rs | 11 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/ui/traits/ice-with-dyn-pointee-errors.rs create mode 100644 tests/ui/traits/ice-with-dyn-pointee-errors.stderr create mode 100644 tests/ui/traits/ice-with-dyn-pointee.rs 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) +}