Rollup merge of #73320 - estebank:type-param-sugg-more, r=davidtwco
Make new type param suggestion more targetted Do not suggest new type param when encountering a missing type in an ADT field with generic parameters. Fix #72640.
This commit is contained in:
commit
f4b5f581a9
6 changed files with 80 additions and 15 deletions
|
|
@ -4,7 +4,16 @@ error[E0412]: cannot find type `A` in this scope
|
|||
LL | fn foo2<I: Foo>(x: I) {
|
||||
| - similarly named type parameter `I` defined here
|
||||
LL | let _: A = x.boo();
|
||||
| ^ help: a type parameter with a similar name exists: `I`
|
||||
| ^
|
||||
|
|
||||
help: a type parameter with a similar name exists
|
||||
|
|
||||
LL | let _: I = x.boo();
|
||||
| ^
|
||||
help: you might be missing a type parameter
|
||||
|
|
||||
LL | fn foo2<I: Foo, A>(x: I) {
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
9
src/test/ui/suggestions/type-not-found-in-adt-field.rs
Normal file
9
src/test/ui/suggestions/type-not-found-in-adt-field.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
struct Struct {
|
||||
m: Vec<Someunknownname<String, ()>>, //~ ERROR cannot find type `Someunknownname` in this scope
|
||||
//~^ NOTE not found in this scope
|
||||
}
|
||||
struct OtherStruct { //~ HELP you might be missing a type parameter
|
||||
m: K, //~ ERROR cannot find type `K` in this scope
|
||||
//~^ NOTE not found in this scope
|
||||
}
|
||||
fn main() {}
|
||||
17
src/test/ui/suggestions/type-not-found-in-adt-field.stderr
Normal file
17
src/test/ui/suggestions/type-not-found-in-adt-field.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0412]: cannot find type `Someunknownname` in this scope
|
||||
--> $DIR/type-not-found-in-adt-field.rs:2:12
|
||||
|
|
||||
LL | m: Vec<Someunknownname<String, ()>>,
|
||||
| ^^^^^^^^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0412]: cannot find type `K` in this scope
|
||||
--> $DIR/type-not-found-in-adt-field.rs:6:8
|
||||
|
|
||||
LL | struct OtherStruct {
|
||||
| - help: you might be missing a type parameter: `<K>`
|
||||
LL | m: K,
|
||||
| ^ not found in this scope
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0412`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue