Rollup merge of #57904 - euclio:attribute-typos, r=davidtwco
add typo suggestion to unknown attribute error Provides a suggestion using Levenshtein distance to suggest built-in attributes and attribute macros. Fixes #49270.
This commit is contained in:
commit
d3bb907eff
6 changed files with 108 additions and 8 deletions
|
|
@ -2,7 +2,7 @@ error[E0658]: The attribute `marco_use` is currently unknown to the compiler and
|
|||
--> $DIR/issue-49074.rs:3:3
|
||||
|
|
||||
LL | #[marco_use] // typo
|
||||
| ^^^^^^^^^
|
||||
| ^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_use`
|
||||
|
|
||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ error[E0658]: The attribute `macro_reexport` is currently unknown to the compile
|
|||
--> $DIR/macro-reexport-removed.rs:5:3
|
||||
|
|
||||
LL | #[macro_reexport(macro_one)] //~ ERROR attribute `macro_reexport` is currently unknown
|
||||
| ^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export`
|
||||
|
|
||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0658]: The attribute `derive_A` is currently unknown to the compiler and
|
|||
--> $DIR/derive-still-gated.rs:8:3
|
||||
|
|
||||
LL | #[derive_A] //~ ERROR attribute `derive_A` is currently unknown
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ help: a built-in attribute with a similar name exists: `derive`
|
||||
|
|
||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
13
src/test/ui/suggestions/attribute-typos.rs
Normal file
13
src/test/ui/suggestions/attribute-typos.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#[deprcated] //~ ERROR E0658
|
||||
fn foo() {} //~| HELP a built-in attribute with a similar name exists
|
||||
//~| SUGGESTION deprecated
|
||||
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
#[tests] //~ ERROR E0658
|
||||
fn bar() {} //~| HELP a built-in attribute with a similar name exists
|
||||
//~| SUGGESTION test
|
||||
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
#[rustc_err] //~ ERROR E0658
|
||||
fn main() {} //~| HELP add #![feature(rustc_attrs)] to the crate attributes to enable
|
||||
// don't suggest rustc attributes
|
||||
27
src/test/ui/suggestions/attribute-typos.stderr
Normal file
27
src/test/ui/suggestions/attribute-typos.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
|
||||
--> $DIR/attribute-typos.rs:11:3
|
||||
|
|
||||
LL | #[rustc_err] //~ ERROR E0658
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
|
||||
--> $DIR/attribute-typos.rs:6:3
|
||||
|
|
||||
LL | #[tests] //~ ERROR E0658
|
||||
| ^^^^^ help: a built-in attribute with a similar name exists: `test`
|
||||
|
|
||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: The attribute `deprcated` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
|
||||
--> $DIR/attribute-typos.rs:1:3
|
||||
|
|
||||
LL | #[deprcated] //~ ERROR E0658
|
||||
| ^^^^^^^^^ help: a built-in attribute with a similar name exists: `deprecated`
|
||||
|
|
||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue