diff --git a/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.rs b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.rs new file mode 100644 index 0000000000000..1768b006622e2 --- /dev/null +++ b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.rs @@ -0,0 +1,18 @@ +trait Id { + type This: ?Sized; +} +impl Id for T { + type This = T; +} + +trait Trait { + type Assoc: Id; +} + +// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy` +fn foo(x: T::Assoc) -> (T::Assoc, T::Assoc) { + (x, x) + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.stderr b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.stderr new file mode 100644 index 0000000000000..cd0e026905c9a --- /dev/null +++ b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/cant-see-copy-bound-from-child-rigid-2.rs:14:9 + | +LL | fn foo(x: T::Assoc) -> (T::Assoc, T::Assoc) { + | - move occurs because `x` has type `::Assoc`, which does not implement the `Copy` trait +LL | (x, x) + | - ^ value used here after move + | | + | value moved here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.rs b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.rs new file mode 100644 index 0000000000000..6b3fd7e898d18 --- /dev/null +++ b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.rs @@ -0,0 +1,18 @@ +trait Id { + type This: ?Sized; +} + +trait Trait { + type Assoc: Id; +} + +// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy` +fn foo(x: T::Assoc) -> (T::Assoc, T::Assoc) +where + T::Assoc: Id, +{ + (x, x) + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.stderr b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.stderr new file mode 100644 index 0000000000000..3ed73918de313 --- /dev/null +++ b/tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `x` + --> $DIR/cant-see-copy-bound-from-child-rigid.rs:14:9 + | +LL | fn foo(x: T::Assoc) -> (T::Assoc, T::Assoc) + | - move occurs because `x` has type `::Assoc`, which does not implement the `Copy` trait +... +LL | (x, x) + | - ^ value used here after move + | | + | value moved here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`.