Skip to content

Commit a51a592

Browse files
Render missing generics suggestion verbosely
1 parent 89e0576 commit a51a592

14 files changed

+97
-49
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'a> Resolver<'a> {
164164
);
165165
err.emit();
166166
} else if let Some((span, msg, sugg, appl)) = suggestion {
167-
err.span_suggestion(span, msg, sugg, appl);
167+
err.span_suggestion_verbose(span, msg, sugg, appl);
168168
err.emit();
169169
} else if let [segment] = path.as_slice() && is_call {
170170
err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);

src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
22
--> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
33
|
44
LL | impl Struct<T>
5-
| - ^ not found in this scope
6-
| |
7-
| help: you might be missing a type parameter: `<T>`
5+
| ^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | impl<T> Struct<T>
10+
| +++
811

912
error[E0412]: cannot find type `T` in this scope
1013
--> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5

src/test/ui/issues/issue-58712.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `DeviceId` in this scope
22
--> $DIR/issue-58712.rs:6:20
33
|
44
LL | impl<H> AddrVec<H, DeviceId> {
5-
| - ^^^^^^^^ not found in this scope
6-
| |
7-
| help: you might be missing a type parameter: `, DeviceId`
5+
| ^^^^^^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | impl<H, DeviceId> AddrVec<H, DeviceId> {
10+
| ++++++++++
811

912
error[E0412]: cannot find type `DeviceId` in this scope
1013
--> $DIR/issue-58712.rs:8:29

src/test/ui/issues/issue-77919.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ error[E0412]: cannot find type `VAL` in this scope
1313
--> $DIR/issue-77919.rs:11:63
1414
|
1515
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
16-
| - ^^^ not found in this scope
17-
| |
18-
| help: you might be missing a type parameter: `, VAL`
16+
| ^^^ not found in this scope
17+
|
18+
help: you might be missing a type parameter
19+
|
20+
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
21+
| +++++
1922

2023
error[E0046]: not all trait items implemented, missing: `VAL`
2124
--> $DIR/issue-77919.rs:11:1

src/test/ui/issues/issue-86756.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ LL | trait Foo<T, T = T> {}
99
error[E0412]: cannot find type `dyn` in this scope
1010
--> $DIR/issue-86756.rs:5:10
1111
|
12-
LL | fn eq<A, B>() {
13-
| - help: you might be missing a type parameter: `, dyn`
1412
LL | eq::<dyn, Foo>
1513
| ^^^ not found in this scope
14+
|
15+
help: you might be missing a type parameter
16+
|
17+
LL | fn eq<A, B, dyn>() {
18+
| +++++
1619

1720
warning: trait objects without an explicit `dyn` are deprecated
1821
--> $DIR/issue-86756.rs:5:15

src/test/ui/parser/dyn-trait-compatibility.stderr

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@ error[E0412]: cannot find type `dyn` in this scope
2626
--> $DIR/dyn-trait-compatibility.rs:5:15
2727
|
2828
LL | type A2 = dyn<dyn, dyn>;
29-
| - ^^^ not found in this scope
30-
| |
31-
| help: you might be missing a type parameter: `<dyn>`
29+
| ^^^ not found in this scope
30+
|
31+
help: you might be missing a type parameter
32+
|
33+
LL | type A2<dyn> = dyn<dyn, dyn>;
34+
| +++++
3235

3336
error[E0412]: cannot find type `dyn` in this scope
3437
--> $DIR/dyn-trait-compatibility.rs:5:20
3538
|
3639
LL | type A2 = dyn<dyn, dyn>;
37-
| - ^^^ not found in this scope
38-
| |
39-
| help: you might be missing a type parameter: `<dyn>`
40+
| ^^^ not found in this scope
41+
|
42+
help: you might be missing a type parameter
43+
|
44+
LL | type A2<dyn> = dyn<dyn, dyn>;
45+
| +++++
4046

4147
error[E0412]: cannot find type `dyn` in this scope
4248
--> $DIR/dyn-trait-compatibility.rs:9:11
@@ -48,9 +54,12 @@ error[E0412]: cannot find type `dyn` in this scope
4854
--> $DIR/dyn-trait-compatibility.rs:9:16
4955
|
5056
LL | type A3 = dyn<<dyn as dyn>::dyn>;
51-
| - ^^^ not found in this scope
52-
| |
53-
| help: you might be missing a type parameter: `<dyn>`
57+
| ^^^ not found in this scope
58+
|
59+
help: you might be missing a type parameter
60+
|
61+
LL | type A3<dyn> = dyn<<dyn as dyn>::dyn>;
62+
| +++++
5463

5564
error: aborting due to 8 previous errors
5665

src/test/ui/suggestions/type-not-found-in-adt-field.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ LL | m: Vec<Someunknownname<String, ()>>,
77
error[E0412]: cannot find type `K` in this scope
88
--> $DIR/type-not-found-in-adt-field.rs:6:8
99
|
10-
LL | struct OtherStruct {
11-
| - help: you might be missing a type parameter: `<K>`
1210
LL | m: K,
1311
| ^ not found in this scope
12+
|
13+
help: you might be missing a type parameter
14+
|
15+
LL | struct OtherStruct<K> {
16+
| +++
1417

1518
error: aborting due to 2 previous errors
1619

src/test/ui/traits/issue-50480.stderr

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `N` in this scope
22
--> $DIR/issue-50480.rs:3:12
33
|
44
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
5-
| -^ not found in this scope
6-
| |
7-
| help: you might be missing a type parameter: `<N>`
5+
| ^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
10+
| +++
811

912
error[E0412]: cannot find type `NotDefined` in this scope
1013
--> $DIR/issue-50480.rs:3:15
@@ -16,17 +19,23 @@ error[E0412]: cannot find type `N` in this scope
1619
--> $DIR/issue-50480.rs:3:12
1720
|
1821
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
19-
| -^ not found in this scope
20-
| |
21-
| help: you might be missing a type parameter: `<N>`
22+
| ^ not found in this scope
23+
|
24+
help: you might be missing a type parameter
25+
|
26+
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
27+
| +++
2228

2329
error[E0412]: cannot find type `NotDefined` in this scope
2430
--> $DIR/issue-50480.rs:3:15
2531
|
2632
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
27-
| - ^^^^^^^^^^ not found in this scope
28-
| |
29-
| help: you might be missing a type parameter: `<NotDefined>`
33+
| ^^^^^^^^^^ not found in this scope
34+
|
35+
help: you might be missing a type parameter
36+
|
37+
LL | struct Foo<NotDefined>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
38+
| ++++++++++++
3039

3140
error[E0412]: cannot find type `N` in this scope
3241
--> $DIR/issue-50480.rs:12:18

src/test/ui/traits/issue-75627.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
22
--> $DIR/issue-75627.rs:3:26
33
|
44
LL | unsafe impl Send for Foo<T> {}
5-
| - ^ not found in this scope
6-
| |
7-
| help: you might be missing a type parameter: `<T>`
5+
| ^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | unsafe impl<T> Send for Foo<T> {}
10+
| +++
811

912
error: aborting due to previous error
1013

src/test/ui/traits/issue-78372.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ error[E0412]: cannot find type `MISC` in this scope
3030
--> $DIR/issue-78372.rs:3:34
3131
|
3232
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
33-
| - ^^^^ not found in this scope
34-
| |
35-
| help: you might be missing a type parameter: `, MISC`
33+
| ^^^^ not found in this scope
34+
|
35+
help: you might be missing a type parameter
36+
|
37+
LL | impl<T, MISC> DispatchFromDyn<Smaht<U, MISC>> for T {}
38+
| ++++++
3639

3740
error[E0658]: use of unstable library feature 'dispatch_from_dyn'
3841
--> $DIR/issue-78372.rs:1:5

src/test/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
error[E0412]: cannot find type `Dst` in this scope
22
--> $DIR/unknown_dst.rs:20:36
33
|
4-
LL | fn should_gracefully_handle_unknown_dst() {
5-
| - help: you might be missing a type parameter: `<Dst>`
6-
...
74
LL | assert::is_transmutable::<Src, Dst, Context>();
85
| ^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | fn should_gracefully_handle_unknown_dst<Dst>() {
10+
| +++++
911

1012
error: aborting due to previous error
1113

src/test/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
error[E0412]: cannot find type `Src` in this scope
22
--> $DIR/unknown_src.rs:20:31
33
|
4-
LL | fn should_gracefully_handle_unknown_src() {
5-
| - help: you might be missing a type parameter: `<Src>`
6-
...
74
LL | assert::is_transmutable::<Src, Dst, Context>();
85
| ^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | fn should_gracefully_handle_unknown_src<Src>() {
10+
| +++++
911

1012
error: aborting due to previous error
1113

src/test/ui/typeck/autoderef-with-param-env-error.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
error[E0412]: cannot find type `T` in this scope
22
--> $DIR/autoderef-with-param-env-error.rs:3:5
33
|
4-
LL | fn foo()
5-
| - help: you might be missing a type parameter: `<T>`
6-
LL | where
74
LL | T: Send,
85
| ^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | fn foo<T>()
10+
| +++
911

1012
error: aborting due to previous error
1113

src/test/ui/typeck/issue-104513-ice.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
error[E0405]: cannot find trait `Oops` in this scope
22
--> $DIR/issue-104513-ice.rs:3:19
33
|
4-
LL | fn f() {
5-
| - help: you might be missing a type parameter: `<Oops>`
64
LL | let _: S<impl Oops> = S;
75
| ^^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | fn f<Oops>() {
10+
| ++++++
811

912
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
1013
--> $DIR/issue-104513-ice.rs:3:14

0 commit comments

Comments
 (0)