Rollup merge of #106608 - compiler-errors:missing-generics-verbose, r=estebank
Render missing generics suggestion verbosely It's a bit easier to read like this, especially ones that are appending new generics onto an existing list, like ": `, T`" which render somewhat poorly inline. Also don't suggest `dyn` as a type parameter to add, even if technically that's valid in edition 2015.
This commit is contained in:
commit
9a2f3937fc
17 changed files with 94 additions and 56 deletions
|
@ -167,7 +167,7 @@ impl<'a> Resolver<'a> {
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
} else if let Some((span, msg, sugg, appl)) = suggestion {
|
} else if let Some((span, msg, sugg, appl)) = suggestion {
|
||||||
err.span_suggestion(span, msg, sugg, appl);
|
err.span_suggestion_verbose(span, msg, sugg, appl);
|
||||||
err.emit();
|
err.emit();
|
||||||
} else if let [segment] = path.as_slice() && is_call {
|
} else if let [segment] = path.as_slice() && is_call {
|
||||||
err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);
|
err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);
|
||||||
|
|
|
@ -2065,7 +2065,11 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
path: &[Segment],
|
path: &[Segment],
|
||||||
) -> Option<(Span, &'static str, String, Applicability)> {
|
) -> Option<(Span, &'static str, String, Applicability)> {
|
||||||
let (ident, span) = match path {
|
let (ident, span) = match path {
|
||||||
[segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => {
|
[segment]
|
||||||
|
if !segment.has_generic_args
|
||||||
|
&& segment.ident.name != kw::SelfUpper
|
||||||
|
&& segment.ident.name != kw::Dyn =>
|
||||||
|
{
|
||||||
(segment.ident.to_string(), segment.ident.span)
|
(segment.ident.to_string(), segment.ident.span)
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
|
|
@ -17,9 +17,12 @@ error[E0412]: cannot find type `VAL` in this scope
|
||||||
--> $DIR/ice-6252.rs:10:63
|
--> $DIR/ice-6252.rs:10:63
|
||||||
|
|
|
|
||||||
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
||||||
| - ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `, VAL`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0046]: not all trait items implemented, missing: `VAL`
|
error[E0046]: not all trait items implemented, missing: `VAL`
|
||||||
--> $DIR/ice-6252.rs:10:1
|
--> $DIR/ice-6252.rs:10:1
|
||||||
|
|
|
@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
|
||||||
--> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
|
--> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
|
||||||
|
|
|
|
||||||
LL | impl Struct<T>
|
LL | impl Struct<T>
|
||||||
| - ^ not found in this scope
|
| ^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<T>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<T> Struct<T>
|
||||||
|
| +++
|
||||||
|
|
||||||
error[E0412]: cannot find type `T` in this scope
|
error[E0412]: cannot find type `T` in this scope
|
||||||
--> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5
|
--> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5
|
||||||
|
|
|
@ -2,9 +2,12 @@ error[E0412]: cannot find type `DeviceId` in this scope
|
||||||
--> $DIR/issue-58712.rs:6:20
|
--> $DIR/issue-58712.rs:6:20
|
||||||
|
|
|
|
||||||
LL | impl<H> AddrVec<H, DeviceId> {
|
LL | impl<H> AddrVec<H, DeviceId> {
|
||||||
| - ^^^^^^^^ not found in this scope
|
| ^^^^^^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `, DeviceId`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<H, DeviceId> AddrVec<H, DeviceId> {
|
||||||
|
| ++++++++++
|
||||||
|
|
||||||
error[E0412]: cannot find type `DeviceId` in this scope
|
error[E0412]: cannot find type `DeviceId` in this scope
|
||||||
--> $DIR/issue-58712.rs:8:29
|
--> $DIR/issue-58712.rs:8:29
|
||||||
|
|
|
@ -13,9 +13,12 @@ error[E0412]: cannot find type `VAL` in this scope
|
||||||
--> $DIR/issue-77919.rs:11:63
|
--> $DIR/issue-77919.rs:11:63
|
||||||
|
|
|
|
||||||
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
||||||
| - ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `, VAL`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
|
||||||
|
| +++++
|
||||||
|
|
||||||
error[E0046]: not all trait items implemented, missing: `VAL`
|
error[E0046]: not all trait items implemented, missing: `VAL`
|
||||||
--> $DIR/issue-77919.rs:11:1
|
--> $DIR/issue-77919.rs:11:1
|
||||||
|
|
|
@ -9,8 +9,6 @@ LL | trait Foo<T, T = T> {}
|
||||||
error[E0412]: cannot find type `dyn` in this scope
|
error[E0412]: cannot find type `dyn` in this scope
|
||||||
--> $DIR/issue-86756.rs:5:10
|
--> $DIR/issue-86756.rs:5:10
|
||||||
|
|
|
|
||||||
LL | fn eq<A, B>() {
|
|
||||||
| - help: you might be missing a type parameter: `, dyn`
|
|
||||||
LL | eq::<dyn, Foo>
|
LL | eq::<dyn, Foo>
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,13 @@ error[E0412]: cannot find type `dyn` in this scope
|
||||||
--> $DIR/dyn-trait-compatibility.rs:5:15
|
--> $DIR/dyn-trait-compatibility.rs:5:15
|
||||||
|
|
|
|
||||||
LL | type A2 = dyn<dyn, dyn>;
|
LL | type A2 = dyn<dyn, dyn>;
|
||||||
| - ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
| |
|
|
||||||
| help: you might be missing a type parameter: `<dyn>`
|
|
||||||
|
|
||||||
error[E0412]: cannot find type `dyn` in this scope
|
error[E0412]: cannot find type `dyn` in this scope
|
||||||
--> $DIR/dyn-trait-compatibility.rs:5:20
|
--> $DIR/dyn-trait-compatibility.rs:5:20
|
||||||
|
|
|
|
||||||
LL | type A2 = dyn<dyn, dyn>;
|
LL | type A2 = dyn<dyn, dyn>;
|
||||||
| - ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
| |
|
|
||||||
| help: you might be missing a type parameter: `<dyn>`
|
|
||||||
|
|
||||||
error[E0412]: cannot find type `dyn` in this scope
|
error[E0412]: cannot find type `dyn` in this scope
|
||||||
--> $DIR/dyn-trait-compatibility.rs:9:11
|
--> $DIR/dyn-trait-compatibility.rs:9:11
|
||||||
|
@ -48,9 +44,7 @@ error[E0412]: cannot find type `dyn` in this scope
|
||||||
--> $DIR/dyn-trait-compatibility.rs:9:16
|
--> $DIR/dyn-trait-compatibility.rs:9:16
|
||||||
|
|
|
|
||||||
LL | type A3 = dyn<<dyn as dyn>::dyn>;
|
LL | type A3 = dyn<<dyn as dyn>::dyn>;
|
||||||
| - ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
| |
|
|
||||||
| help: you might be missing a type parameter: `<dyn>`
|
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,13 @@ LL | m: Vec<Someunknownname<String, ()>>,
|
||||||
error[E0412]: cannot find type `K` in this scope
|
error[E0412]: cannot find type `K` in this scope
|
||||||
--> $DIR/type-not-found-in-adt-field.rs:6:8
|
--> $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,
|
LL | m: K,
|
||||||
| ^ not found in this scope
|
| ^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | struct OtherStruct<K> {
|
||||||
|
| +++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,12 @@ error[E0412]: cannot find type `Type` in this scope
|
||||||
--> $DIR/ignore-err-impls.rs:6:14
|
--> $DIR/ignore-err-impls.rs:6:14
|
||||||
|
|
|
|
||||||
LL | impl Generic<Type> for S {}
|
LL | impl Generic<Type> for S {}
|
||||||
| - ^^^^ not found in this scope
|
| ^^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<Type>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<Type> Generic<Type> for S {}
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,12 @@ error[E0412]: cannot find type `N` in this scope
|
||||||
--> $DIR/issue-50480.rs:3:12
|
--> $DIR/issue-50480.rs:3:12
|
||||||
|
|
|
|
||||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
| -^ not found in this scope
|
| ^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<N>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
|
| +++
|
||||||
|
|
||||||
error[E0412]: cannot find type `NotDefined` in this scope
|
error[E0412]: cannot find type `NotDefined` in this scope
|
||||||
--> $DIR/issue-50480.rs:3:15
|
--> $DIR/issue-50480.rs:3:15
|
||||||
|
@ -16,17 +19,23 @@ error[E0412]: cannot find type `N` in this scope
|
||||||
--> $DIR/issue-50480.rs:3:12
|
--> $DIR/issue-50480.rs:3:12
|
||||||
|
|
|
|
||||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
| -^ not found in this scope
|
| ^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<N>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
|
| +++
|
||||||
|
|
||||||
error[E0412]: cannot find type `NotDefined` in this scope
|
error[E0412]: cannot find type `NotDefined` in this scope
|
||||||
--> $DIR/issue-50480.rs:3:15
|
--> $DIR/issue-50480.rs:3:15
|
||||||
|
|
|
|
||||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
| - ^^^^^^^^^^ not found in this scope
|
| ^^^^^^^^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<NotDefined>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | struct Foo<NotDefined>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||||
|
| ++++++++++++
|
||||||
|
|
||||||
error[E0412]: cannot find type `N` in this scope
|
error[E0412]: cannot find type `N` in this scope
|
||||||
--> $DIR/issue-50480.rs:12:18
|
--> $DIR/issue-50480.rs:12:18
|
||||||
|
|
|
@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
|
||||||
--> $DIR/issue-75627.rs:3:26
|
--> $DIR/issue-75627.rs:3:26
|
||||||
|
|
|
|
||||||
LL | unsafe impl Send for Foo<T> {}
|
LL | unsafe impl Send for Foo<T> {}
|
||||||
| - ^ not found in this scope
|
| ^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `<T>`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | unsafe impl<T> Send for Foo<T> {}
|
||||||
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,12 @@ error[E0412]: cannot find type `MISC` in this scope
|
||||||
--> $DIR/issue-78372.rs:3:34
|
--> $DIR/issue-78372.rs:3:34
|
||||||
|
|
|
|
||||||
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
|
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
|
||||||
| - ^^^^ not found in this scope
|
| ^^^^ not found in this scope
|
||||||
| |
|
|
|
||||||
| help: you might be missing a type parameter: `, MISC`
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | impl<T, MISC> DispatchFromDyn<Smaht<U, MISC>> for T {}
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'dispatch_from_dyn'
|
error[E0658]: use of unstable library feature 'dispatch_from_dyn'
|
||||||
--> $DIR/issue-78372.rs:1:5
|
--> $DIR/issue-78372.rs:1:5
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
error[E0412]: cannot find type `Dst` in this scope
|
error[E0412]: cannot find type `Dst` in this scope
|
||||||
--> $DIR/unknown_dst.rs:20:36
|
--> $DIR/unknown_dst.rs:20:36
|
||||||
|
|
|
|
||||||
LL | fn should_gracefully_handle_unknown_dst() {
|
|
||||||
| - help: you might be missing a type parameter: `<Dst>`
|
|
||||||
...
|
|
||||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | fn should_gracefully_handle_unknown_dst<Dst>() {
|
||||||
|
| +++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
error[E0412]: cannot find type `Src` in this scope
|
error[E0412]: cannot find type `Src` in this scope
|
||||||
--> $DIR/unknown_src.rs:20:31
|
--> $DIR/unknown_src.rs:20:31
|
||||||
|
|
|
|
||||||
LL | fn should_gracefully_handle_unknown_src() {
|
|
||||||
| - help: you might be missing a type parameter: `<Src>`
|
|
||||||
...
|
|
||||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | fn should_gracefully_handle_unknown_src<Src>() {
|
||||||
|
| +++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
error[E0412]: cannot find type `T` in this scope
|
error[E0412]: cannot find type `T` in this scope
|
||||||
--> $DIR/autoderef-with-param-env-error.rs:3:5
|
--> $DIR/autoderef-with-param-env-error.rs:3:5
|
||||||
|
|
|
|
||||||
LL | fn foo()
|
|
||||||
| - help: you might be missing a type parameter: `<T>`
|
|
||||||
LL | where
|
|
||||||
LL | T: Send,
|
LL | T: Send,
|
||||||
| ^ not found in this scope
|
| ^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<T>()
|
||||||
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
error[E0405]: cannot find trait `Oops` in this scope
|
error[E0405]: cannot find trait `Oops` in this scope
|
||||||
--> $DIR/issue-104513-ice.rs:3:19
|
--> $DIR/issue-104513-ice.rs:3:19
|
||||||
|
|
|
|
||||||
LL | fn f() {
|
|
||||||
| - help: you might be missing a type parameter: `<Oops>`
|
|
||||||
LL | let _: S<impl Oops> = S;
|
LL | let _: S<impl Oops> = S;
|
||||||
| ^^^^ not found in this scope
|
| ^^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | fn f<Oops>() {
|
||||||
|
| ++++++
|
||||||
|
|
||||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
|
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
|
||||||
--> $DIR/issue-104513-ice.rs:3:14
|
--> $DIR/issue-104513-ice.rs:3:14
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue