Skip to content

Commit accc90f

Browse files
Rollup merge of rust-lang#157400 - kohsine:late-bound-assoc-type-reg-test, r=Kivooeo
Add regression test for late-bound type param in nested `impl Trait` Regression test for rust-lang#132055
2 parents 649f157 + 7f6a63c commit accc90f

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(non_lifetime_binders)]
2+
3+
//! Regression test for https://github.com/rust-lang/rust/issues/132055.
4+
//! Compiler gave ICE with late-bound type parameter in nested `impl Trait` on
5+
//! associated type.
6+
7+
trait Trait<T: ?Sized> {
8+
type Assoc<'a> = i32;
9+
//~^ ERROR associated type defaults are unstable
10+
}
11+
12+
fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
13+
//~^ ERROR cannot capture late-bound type parameter in nested `impl Trait`
14+
//~| ERROR missing generics for associated type `Trait::Assoc`
15+
//~| ERROR missing generics for associated type `Trait::Assoc`
16+
//~| ERROR the trait bound `{integer}: Trait<()>` is not satisfied
17+
16
18+
}
19+
//~^ ERROR `main` function not found in crate `late_bound_assoc_type`
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
error[E0658]: associated type defaults are unstable
2+
--> $DIR/late-bound-assoc-type.rs:8:5
3+
|
4+
LL | type Assoc<'a> = i32;
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information
8+
= help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0601]: `main` function not found in crate `late_bound_assoc_type`
12+
--> $DIR/late-bound-assoc-type.rs:18:2
13+
|
14+
LL | }
15+
| ^ consider adding a `main` function to `$DIR/late-bound-assoc-type.rs`
16+
17+
error: cannot capture late-bound type parameter in nested `impl Trait`
18+
--> $DIR/late-bound-assoc-type.rs:12:58
19+
|
20+
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
21+
| - parameter defined here ^
22+
23+
error[E0107]: missing generics for associated type `Trait::Assoc`
24+
--> $DIR/late-bound-assoc-type.rs:12:39
25+
|
26+
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
27+
| ^^^^^ expected 1 lifetime argument
28+
|
29+
note: associated type defined here, with 1 lifetime parameter: `'a`
30+
--> $DIR/late-bound-assoc-type.rs:8:10
31+
|
32+
LL | type Assoc<'a> = i32;
33+
| ^^^^^ --
34+
help: add missing lifetime argument
35+
|
36+
LL | fn produce() -> impl for<T> Trait<(), Assoc<'a> = impl Trait<T>> {
37+
| ++++
38+
39+
error[E0107]: missing generics for associated type `Trait::Assoc`
40+
--> $DIR/late-bound-assoc-type.rs:12:39
41+
|
42+
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
43+
| ^^^^^ expected 1 lifetime argument
44+
|
45+
note: associated type defined here, with 1 lifetime parameter: `'a`
46+
--> $DIR/late-bound-assoc-type.rs:8:10
47+
|
48+
LL | type Assoc<'a> = i32;
49+
| ^^^^^ --
50+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
51+
help: add missing lifetime argument
52+
|
53+
LL | fn produce() -> impl for<T> Trait<(), Assoc<'a> = impl Trait<T>> {
54+
| ++++
55+
56+
error[E0277]: the trait bound `{integer}: Trait<()>` is not satisfied
57+
--> $DIR/late-bound-assoc-type.rs:12:17
58+
|
59+
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
60+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<()>` is not implemented for `{integer}`
61+
...
62+
LL | 16
63+
| -- return type was inferred to be `{integer}` here
64+
|
65+
help: this trait has no implementations, consider adding one
66+
--> $DIR/late-bound-assoc-type.rs:7:1
67+
|
68+
LL | trait Trait<T: ?Sized> {
69+
| ^^^^^^^^^^^^^^^^^^^^^^
70+
71+
error: aborting due to 6 previous errors
72+
73+
Some errors have detailed explanations: E0107, E0277, E0601, E0658.
74+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)