Given <T as Trait>::A: Ty suggest T: Trait<A = Ty>

Fix #75829
This commit is contained in:
Esteban Küber 2020-09-23 23:01:17 -07:00
parent e89ce461d3
commit 5e23cc4960
4 changed files with 161 additions and 0 deletions

View file

@ -0,0 +1,9 @@
trait Bar {
type Baz;
}
struct Foo<T> where T: Bar, <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
t: T,
}
fn main() {}

View file

@ -0,0 +1,23 @@
error[E0404]: expected trait, found struct `String`
--> $DIR/assoc_type_bound_with_struct.rs:5:46
|
LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
| ^^^^^^ not a trait
|
::: $SRC_DIR/alloc/src/string.rs:LL:COL
|
LL | pub trait ToString {
| ------------------ similarly named trait `ToString` defined here
|
help: constrain the associated type to `String`
|
LL | struct Foo<T> where T: Bar, T: Bar<Baz = String> {
| ^^^^^^^^^^^^^^^^^^^^
help: a trait with a similar name exists
|
LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: ToString {
| ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0404`.