Make suggestion verbose and tweak error message
This commit is contained in:
parent
8e344ae127
commit
7601adb4a0
10 changed files with 178 additions and 119 deletions
|
@ -467,9 +467,9 @@ fn infer_placeholder_type<'tcx>(
|
|||
|
||||
if !ty.references_error() {
|
||||
if let Some(ty) = ty.make_suggestable(tcx, false, None) {
|
||||
diag.span_suggestion(
|
||||
diag.span_suggestion_verbose(
|
||||
span,
|
||||
"replace with the correct type",
|
||||
"replace this with a fully-specified type",
|
||||
ty,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
|
|
@ -2,37 +2,45 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/suggest-array-length.rs:5:22
|
||||
|
|
||||
LL | const Foo: [i32; _] = [1, 2, 3];
|
||||
| ------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `[i32; 3]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const Foo: [i32; 3] = [1, 2, 3];
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
||||
--> $DIR/suggest-array-length.rs:7:26
|
||||
|
|
||||
LL | const REF_FOO: &[u8; _] = &[1];
|
||||
| ------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `&[u8; 1]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const REF_FOO: &[u8; 1] = &[1];
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/suggest-array-length.rs:9:26
|
||||
|
|
||||
LL | static Statik: [i32; _] = [1, 2, 3];
|
||||
| ------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `[i32; 3]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static Statik: [i32; 3] = [1, 2, 3];
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/suggest-array-length.rs:11:30
|
||||
|
|
||||
LL | static REF_STATIK: &[u8; _] = &[1];
|
||||
| ------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `&[u8; 1]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static REF_STATIK: &[u8; 1] = &[1];
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0658]: using `_` for array lengths is unstable
|
||||
--> $DIR/suggest-array-length.rs:13:20
|
||||
|
|
|
@ -30,57 +30,71 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/in-signature.rs:22:20
|
||||
|
|
||||
LL | const ARR_CT: [u8; _] = [0; 3];
|
||||
| -----^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `[u8; 3]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const ARR_CT: [u8; 3] = [0; 3];
|
||||
| ~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/in-signature.rs:24:25
|
||||
|
|
||||
LL | static ARR_STATIC: [u8; _] = [0; 3];
|
||||
| -----^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `[u8; 3]`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static ARR_STATIC: [u8; 3] = [0; 3];
|
||||
| ~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
||||
--> $DIR/in-signature.rs:26:23
|
||||
|
|
||||
LL | const TY_CT: Bar<i32, _> = Bar::<i32, 3>(0);
|
||||
| ---------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Bar<i32, 3>`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TY_CT: Bar<i32, 3> = Bar::<i32, 3>(0);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/in-signature.rs:28:28
|
||||
|
|
||||
LL | static TY_STATIC: Bar<i32, _> = Bar::<i32, 3>(0);
|
||||
| ---------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Bar<i32, 3>`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static TY_STATIC: Bar<i32, 3> = Bar::<i32, 3>(0);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
||||
--> $DIR/in-signature.rs:30:24
|
||||
|
|
||||
LL | const TY_CT_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
|
||||
| ----^--^-
|
||||
| | | |
|
||||
| | | not allowed in type signatures
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Bar<i32, 3>`
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TY_CT_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/in-signature.rs:32:29
|
||||
|
|
||||
LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
|
||||
| ----^--^-
|
||||
| | | |
|
||||
| | | not allowed in type signatures
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Bar<i32, 3>`
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static TY_STATIC_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types
|
||||
--> $DIR/in-signature.rs:51:23
|
||||
|
|
|
@ -15,10 +15,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/issue-104768.rs:1:11
|
||||
|
|
||||
LL | const A: &_ = 0_u32;
|
||||
| -^
|
||||
| ||
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct type: `u32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const A: u32 = 0_u32;
|
||||
| ~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -11,10 +11,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/E0121.rs:3:13
|
||||
|
|
||||
LL | static BAR: _ = "test";
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `&str`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static BAR: &str = "test";
|
||||
| ~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -31,10 +31,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:20
|
||||
|
|
||||
LL | const A = "A".$fn();
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `bool`
|
||||
| ^ not allowed in type signatures
|
||||
...
|
||||
LL | / suite! {
|
||||
LL | | len;
|
||||
|
@ -43,6 +40,10 @@ LL | | }
|
|||
| |_- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const Abool = "A".$fn();
|
||||
| ++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const A = 5;
|
|||
static B: _ = "abc";
|
||||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
//~| NOTE: not allowed in type signatures
|
||||
//~| HELP: replace with the correct type
|
||||
//~| HELP: replace this with a fully-specified type
|
||||
|
||||
|
||||
// FIXME: this should also suggest a function pointer, as the closure is non-capturing
|
||||
|
|
|
@ -8,10 +8,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/unnamable-types.rs:10:11
|
||||
|
|
||||
LL | static B: _ = "abc";
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `&str`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static B: &str = "abc";
|
||||
| ~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
||||
--> $DIR/unnamable-types.rs:17:10
|
||||
|
|
|
@ -67,29 +67,36 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item.rs:13:15
|
||||
|
|
||||
LL | static TEST3: _ = "test";
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `&str`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static TEST3: &str = "test";
|
||||
| ~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/typeck_type_placeholder_item.rs:16:15
|
||||
|
|
||||
LL | static TEST4: _ = 145;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static TEST4: i32 = 145;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/typeck_type_placeholder_item.rs:19:16
|
||||
|
|
||||
LL | static TEST5: (_, _) = (1, 2);
|
||||
| -^--^-
|
||||
| || |
|
||||
| || not allowed in type signatures
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct type: `(i32, i32)`
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static TEST5: (i32, i32) = (1, 2);
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:22:13
|
||||
|
@ -224,19 +231,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item.rs:75:15
|
||||
|
|
||||
LL | static B: _ = 42;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static B: i32 = 42;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/typeck_type_placeholder_item.rs:77:22
|
||||
|
|
||||
LL | static C: Option<_> = Some(42);
|
||||
| -------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Option<i32>`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static C: Option<i32> = Some(42);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
|
||||
--> $DIR/typeck_type_placeholder_item.rs:79:21
|
||||
|
@ -261,29 +272,36 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item.rs:85:22
|
||||
|
|
||||
LL | static FN_TEST3: _ = "test";
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `&str`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static FN_TEST3: &str = "test";
|
||||
| ~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/typeck_type_placeholder_item.rs:88:22
|
||||
|
|
||||
LL | static FN_TEST4: _ = 145;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static FN_TEST4: i32 = 145;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
|
||||
--> $DIR/typeck_type_placeholder_item.rs:91:23
|
||||
|
|
||||
LL | static FN_TEST5: (_, _) = (1, 2);
|
||||
| -^--^-
|
||||
| || |
|
||||
| || not allowed in type signatures
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct type: `(i32, i32)`
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | static FN_TEST5: (i32, i32) = (1, 2);
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:94:20
|
||||
|
@ -550,10 +568,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item.rs:194:14
|
||||
|
|
||||
LL | const D: _ = 42;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const D: i32 = 42;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||
--> $DIR/typeck_type_placeholder_item.rs:209:14
|
||||
|
@ -583,10 +603,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item.rs:222:17
|
||||
|
|
||||
LL | const _: Option<_> = map(value);
|
||||
| -------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct type: `Option<u8>`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const _: Option<u8> = map(value);
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
|
||||
--> $DIR/typeck_type_placeholder_item.rs:226:31
|
||||
|
|
|
@ -11,19 +11,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item_help.rs:7:14
|
||||
|
|
||||
LL | const TEST2: _ = 42u32;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `u32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TEST2: u32 = 42u32;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
||||
--> $DIR/typeck_type_placeholder_item_help.rs:10:14
|
||||
|
|
||||
LL | const TEST3: _ = Some(42);
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `Option<i32>`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TEST3: Option<i32> = Some(42);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item_help.rs:13:22
|
||||
|
@ -41,19 +45,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||
--> $DIR/typeck_type_placeholder_item_help.rs:25:18
|
||||
|
|
||||
LL | const TEST6: _ = 13;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TEST6: i32 = 13;
|
||||
| ~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||
--> $DIR/typeck_type_placeholder_item_help.rs:18:18
|
||||
|
|
||||
LL | const TEST5: _ = 42;
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct type: `i32`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: replace this with a fully-specified type
|
||||
|
|
||||
LL | const TEST5: i32 = 42;
|
||||
| ~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/typeck_type_placeholder_item_help.rs:30:28
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue