diff options
| author | Michael Goulet <michael@errs.io> | 2022-03-03 22:04:23 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-03-03 22:04:23 -0800 |
| commit | 210e829010022d2a8e49a2519aec8ac6bee20ed1 (patch) | |
| tree | bfc3fe177009aaf61a02738c118b1d92ed6b2015 | |
| parent | 1d834cb657d4911535a01af38e974d11d081e9f4 (diff) | |
| download | rust-210e829010022d2a8e49a2519aec8ac6bee20ed1.tar.gz rust-210e829010022d2a8e49a2519aec8ac6bee20ed1.zip | |
add tests for metadata for unsized generics and opaques
| -rw-r--r-- | src/test/ui/traits/pointee-tail-is-generic-errors.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/traits/pointee-tail-is-generic-errors.stderr | 40 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/test/ui/traits/pointee-tail-is-generic-errors.rs b/src/test/ui/traits/pointee-tail-is-generic-errors.rs new file mode 100644 index 00000000000..d081721aca2 --- /dev/null +++ b/src/test/ui/traits/pointee-tail-is-generic-errors.rs @@ -0,0 +1,22 @@ +// edition:2018 + +#![feature(ptr_metadata)] +#![feature(type_alias_impl_trait)] + +type Opaque = impl std::fmt::Debug + ?Sized; + +fn opaque() -> &'static Opaque { + &[1] as &[i32] +} + +fn a<T: ?Sized>() { + is_thin::<T>(); + //~^ ERROR type mismatch resolving `<T as Pointee>::Metadata == ()` + + is_thin::<Opaque>(); + //~^ ERROR type mismatch resolving `<impl Debug + ?Sized as Pointee>::Metadata == ()` +} + +fn is_thin<T: std::ptr::Pointee<Metadata = ()> + ?Sized>() {} + +fn main() {} diff --git a/src/test/ui/traits/pointee-tail-is-generic-errors.stderr b/src/test/ui/traits/pointee-tail-is-generic-errors.stderr new file mode 100644 index 00000000000..fa5fe67e53c --- /dev/null +++ b/src/test/ui/traits/pointee-tail-is-generic-errors.stderr @@ -0,0 +1,40 @@ +error[E0271]: type mismatch resolving `<T as Pointee>::Metadata == ()` + --> $DIR/pointee-tail-is-generic-errors.rs:13:5 + | +LL | is_thin::<T>(); + | ^^^^^^^^^^^^ expected `()`, found associated type + | + = note: expected unit type `()` + found associated type `<T as Pointee>::Metadata` + = help: consider constraining the associated type `<T as Pointee>::Metadata` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: required by a bound in `is_thin` + --> $DIR/pointee-tail-is-generic-errors.rs:20:33 + | +LL | fn is_thin<T: std::ptr::Pointee<Metadata = ()> + ?Sized>() {} + | ^^^^^^^^^^^^^ required by this bound in `is_thin` + +error[E0271]: type mismatch resolving `<impl Debug + ?Sized as Pointee>::Metadata == ()` + --> $DIR/pointee-tail-is-generic-errors.rs:16:5 + | +LL | type Opaque = impl std::fmt::Debug + ?Sized; + | ----------------------------- the found opaque type +... +LL | is_thin::<Opaque>(); + | ^^^^^^^^^^^^^^^^^ expected `()`, found associated type + | + = note: expected unit type `()` + found associated type `<impl Debug + ?Sized as Pointee>::Metadata` +note: required by a bound in `is_thin` + --> $DIR/pointee-tail-is-generic-errors.rs:20:33 + | +LL | fn is_thin<T: std::ptr::Pointee<Metadata = ()> + ?Sized>() {} + | ^^^^^^^^^^^^^ required by this bound in `is_thin` +help: consider constraining the associated type `<impl Debug + ?Sized as Pointee>::Metadata` to `()` + | +LL | type Opaque = impl std::fmt::Debug<Metadata = ()> + ?Sized; + | +++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. |
