Skip to content

Commit 740e1f4

Browse files
authored
Rollup merge of #84485 - marmeladema:trait-tests, r=jackh726
Add some associated type bounds tests Closes #83017 Closes #81193 r? `@jackh726`
2 parents 8d75898 + 3b96dfe commit 740e1f4

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
#![feature(associated_type_bounds)]
4+
5+
trait A<'a, 'b> {}
6+
7+
trait B<'a, 'b, 'c> {}
8+
9+
fn err<'u, 'a, F>()
10+
where
11+
for<'b> F: Iterator<Item: for<'c> B<'a, 'b, 'c> + for<'c> A<'a, 'c>>,
12+
{
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#![feature(associated_type_bounds)]
2+
3+
trait TraitA<'a> {
4+
type AsA;
5+
}
6+
7+
trait TraitB<'a, 'b> {
8+
type AsB;
9+
}
10+
11+
trait TraitC<'a, 'b, 'c> {}
12+
13+
struct X;
14+
15+
impl<'a, 'b, 'c> TraitC<'a, 'b, 'c> for X {}
16+
17+
struct Y;
18+
19+
impl<'a, 'b> TraitB<'a, 'b> for Y {
20+
type AsB = X;
21+
}
22+
23+
struct Z;
24+
25+
impl<'a> TraitA<'a> for Z {
26+
type AsA = Y;
27+
}
28+
29+
fn foo<T>()
30+
where
31+
for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>,
32+
{
33+
}
34+
35+
fn main() {
36+
foo::<Z>();
37+
//~^ ERROR: the trait bound `for<'a, 'b> <Z as TraitA<'a>>::AsA: TraitB<'a, 'b>` is not satisfied
38+
//~| ERROR: the trait bound `for<'a, 'b, 'c> <<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB: TraitC<'a, 'b, 'c>` is not satisfied
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0277]: the trait bound `for<'a, 'b> <Z as TraitA<'a>>::AsA: TraitB<'a, 'b>` is not satisfied
2+
--> $DIR/issue-83017.rs:36:5
3+
|
4+
LL | fn foo<T>()
5+
| --- required by a bound in this
6+
LL | where
7+
LL | for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>,
8+
| ------------------------------------------------------- required by this bound in `foo`
9+
...
10+
LL | foo::<Z>();
11+
| ^^^^^^^^ the trait `for<'a, 'b> TraitB<'a, 'b>` is not implemented for `<Z as TraitA<'a>>::AsA`
12+
13+
error[E0277]: the trait bound `for<'a, 'b, 'c> <<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB: TraitC<'a, 'b, 'c>` is not satisfied
14+
--> $DIR/issue-83017.rs:36:5
15+
|
16+
LL | fn foo<T>()
17+
| --- required by a bound in this
18+
LL | where
19+
LL | for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>,
20+
| -------------------------- required by this bound in `foo`
21+
...
22+
LL | foo::<Z>();
23+
| ^^^^^^^^ the trait `for<'a, 'b, 'c> TraitC<'a, 'b, 'c>` is not implemented for `<<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB`
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)