Skip to content

Commit e8c1110

Browse files
authored
Unrolled build for rust-lang#122826
Rollup merge of rust-lang#122826 - compiler-errors:associated-type-bound-tests, r=lcnr Add tests for shortcomings of associated type bounds Adds the test in rust-lang#122791 (comment) Turns out that rust-lang#121123 is what breaks `tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.rs` (passes on nightly), but given that associated type bounds haven't landed anywhere yet, I'm happy with breaking it. This is unrelated to rust-lang#122791, which just needed that original commit e6b64c6 stacked on top of it so that it wouldn't have tests failing. r? lcnr
2 parents 0ad927c + 8ca7aac commit e8c1110

4 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
trait Id {
2+
type This: ?Sized;
3+
}
4+
impl<T: ?Sized> Id for T {
5+
type This = T;
6+
}
7+
8+
trait Trait {
9+
type Assoc: Id<This: Copy>;
10+
}
11+
12+
// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy`
13+
fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) {
14+
(x, x)
15+
//~^ ERROR use of moved value
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0382]: use of moved value: `x`
2+
--> $DIR/cant-see-copy-bound-from-child-rigid-2.rs:14:9
3+
|
4+
LL | fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) {
5+
| - move occurs because `x` has type `<T as Trait>::Assoc`, which does not implement the `Copy` trait
6+
LL | (x, x)
7+
| - ^ value used here after move
8+
| |
9+
| value moved here
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0382`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
trait Id {
2+
type This: ?Sized;
3+
}
4+
5+
trait Trait {
6+
type Assoc: Id<This: Copy>;
7+
}
8+
9+
// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy`
10+
fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc)
11+
where
12+
T::Assoc: Id<This = T::Assoc>,
13+
{
14+
(x, x)
15+
//~^ ERROR use of moved value
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0382]: use of moved value: `x`
2+
--> $DIR/cant-see-copy-bound-from-child-rigid.rs:14:9
3+
|
4+
LL | fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc)
5+
| - move occurs because `x` has type `<T as Trait>::Assoc`, which does not implement the `Copy` trait
6+
...
7+
LL | (x, x)
8+
| - ^ value used here after move
9+
| |
10+
| value moved here
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)