diff options
| author | Philipp Hansch <dev@phansch.net> | 2018-09-13 08:42:19 +0200 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2018-09-13 21:26:45 +0200 |
| commit | 7249a1b1ae075e3a955fda69cdea5161d0eb1aa5 (patch) | |
| tree | f02a6cb97c40d94a899d94b7835b6b6cb7cf129d /src/test/ui | |
| parent | d8af8b66d948ff394db1b3a50e2e4fbe02512239 (diff) | |
| download | rust-7249a1b1ae075e3a955fda69cdea5161d0eb1aa5.tar.gz rust-7249a1b1ae075e3a955fda69cdea5161d0eb1aa5.zip | |
Suggest valid crate type if invalid
This adds a suggestion to the `invalid_crate_types` lint. The suggestion is based on the Levenshtein distance to existing crate types. If no suggestion is found it will show the lint without any suggestions.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/invalid/invalid-crate-type.rs | 42 | ||||
| -rw-r--r-- | src/test/ui/invalid/invalid-crate-type.stderr | 54 |
2 files changed, 93 insertions, 3 deletions
diff --git a/src/test/ui/invalid/invalid-crate-type.rs b/src/test/ui/invalid/invalid-crate-type.rs index 4b6b6c2fe76..e7f4e32dc7c 100644 --- a/src/test/ui/invalid/invalid-crate-type.rs +++ b/src/test/ui/invalid/invalid-crate-type.rs @@ -11,6 +11,48 @@ // regression test for issue 11256 #![crate_type="foo"] //~ ERROR invalid `crate_type` value +// Tests for suggestions (#53958) + +#![crate_type="statoclib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION staticlib + +#![crate_type="procmacro"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION proc-macro + +#![crate_type="static-lib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION staticlib + +#![crate_type="drylib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION dylib + +#![crate_type="dlib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION rlib + +#![crate_type="lob"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION lib + +#![crate_type="bon"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION bin + +#![crate_type="cdalib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION cdylib + fn main() { return } diff --git a/src/test/ui/invalid/invalid-crate-type.stderr b/src/test/ui/invalid/invalid-crate-type.stderr index 6dc8a0f2bbb..c82da865f33 100644 --- a/src/test/ui/invalid/invalid-crate-type.stderr +++ b/src/test/ui/invalid/invalid-crate-type.stderr @@ -1,10 +1,58 @@ error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:12:1 + --> $DIR/invalid-crate-type.rs:12:15 | LL | #![crate_type="foo"] //~ ERROR invalid `crate_type` value - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | = note: #[deny(unknown_crate_types)] on by default -error: aborting due to previous error +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:16:15 + | +LL | #![crate_type="statoclib"] + | ^^^^^^^^^^^ help: did you mean: `"staticlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:21:15 + | +LL | #![crate_type="procmacro"] + | ^^^^^^^^^^^ help: did you mean: `"proc-macro"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:26:15 + | +LL | #![crate_type="static-lib"] + | ^^^^^^^^^^^^ help: did you mean: `"staticlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:31:15 + | +LL | #![crate_type="drylib"] + | ^^^^^^^^ help: did you mean: `"dylib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:36:15 + | +LL | #![crate_type="dlib"] + | ^^^^^^ help: did you mean: `"rlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:41:15 + | +LL | #![crate_type="lob"] + | ^^^^^ help: did you mean: `"lib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:46:15 + | +LL | #![crate_type="bon"] + | ^^^^^ help: did you mean: `"bin"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:51:15 + | +LL | #![crate_type="cdalib"] + | ^^^^^^^^ help: did you mean: `"cdylib"` + +error: aborting due to 9 previous errors |
