Closed
Description
Given the following code (taken from #79636 (comment), playground):
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
pub trait SomeTrait {
type Wrapped<A>: SomeTrait;
fn f() -> ();
}
fn program<W>() -> ()
where
// Missing type parameter for `Wrapped`
W: SomeTrait<Wrapped = W>,
{
return W::f();
}
fn main() {}
The current output is:
error[E0107]: missing generics for associated type `SomeTrait::Wrapped`
--> src/main.rs:5:10
|
5 | type Wrapped<A>: SomeTrait;
| ^^^^^^^ expected 1 type argument
|
note: associated type defined here, with 1 type parameter: `A`
--> src/main.rs:5:10
|
5 | type Wrapped<A>: SomeTrait;
| ^^^^^^^ -
help: use angle brackets to add missing type argument
|
5 | type Wrapped<A><A>: SomeTrait;
| ^^^
Note that the suggestion is syntactically invalid:
pub trait SomeTrait {
type Wrapped<A><A>: SomeTrait;
fn f() -> ();
}
error: expected one of `:`, `;`, `=`, or `where`, found `<`
--> src/main.rs:5:20
|
4 | pub trait SomeTrait {
| - while parsing this item list starting here
5 | type Wrapped<A><A>: SomeTrait;
| ^ expected one of `:`, `;`, `=`, or `where`
...
8 | }
| - the item list ends here
The problem is that the span is pointing at the associated type, not the where
clause bound.
Ideally the output should look like:
error[E0107]: missing generics for associated type `SomeTrait::Wrapped`
--> src/main.rs:12:18
|
12 | W: SomeTrait<Wrapped = W>,
| ^^^^^^^ expected 1 type argument
|
note: associated type defined here, with 1 type parameter: `A`
--> src/main.rs:5:10
|
5 | type Wrapped<A>: SomeTrait;
| ^^^^^^^ -
help: use angle brackets to add missing type argument
|
12 | W: SomeTrait<Wrapped<A> = W>,
| ^^^