-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for shortcomings of associated type bounds
- Loading branch information
1 parent
03994e4
commit 8ca7aac
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
trait Id { | ||
type This: ?Sized; | ||
} | ||
impl<T: ?Sized> Id for T { | ||
type This = T; | ||
} | ||
|
||
trait Trait { | ||
type Assoc: Id<This: Copy>; | ||
} | ||
|
||
// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy` | ||
fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) { | ||
(x, x) | ||
//~^ ERROR use of moved value | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) { | ||
| - move occurs because `x` has type `<T as Trait>::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`. |
18 changes: 18 additions & 0 deletions
18
tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
trait Id { | ||
type This: ?Sized; | ||
} | ||
|
||
trait Trait { | ||
type Assoc: Id<This: Copy>; | ||
} | ||
|
||
// We can't see use the `T::Assoc::This: Copy` bound to prove `T::Assoc: Copy` | ||
fn foo<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) | ||
where | ||
T::Assoc: Id<This = T::Assoc>, | ||
{ | ||
(x, x) | ||
//~^ ERROR use of moved value | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
tests/ui/associated-type-bounds/cant-see-copy-bound-from-child-rigid.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T: Trait>(x: T::Assoc) -> (T::Assoc, T::Assoc) | ||
| - move occurs because `x` has type `<T as Trait>::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`. |