Uh oh!
There was an error while loading. Please reload this page.
Suggest valid crate type if invalid crate type is found - #54173
Conversation
rust-highfive
commented
Sep 13, 2018
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
phansch
commented
Sep 13, 2018
Should this be a machine applicable suggestion? I'm not really sure if the Levenshtein candidate is good enough in this case because |
rust-highfive
commented
Sep 13, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
davidtwco
commented
Sep 13, 2018
I think Otherwise, this looks good to me. Assigning someone else to take another look who might be more familiar with this part of the code. r? @oli-obk (based on github's suggestions) |
estebank
left a comment
There was a problem hiding this comment.
Minor changes requested. r=me after changing.
There was a problem hiding this comment.
Notice that the span includes the "s, but the suggestion doesn't, which would make applying this suggestion generate the code #![crate_type=staticlib], which is incorrect. Easiest solution is to include the quotes in the suggestion.
There was a problem hiding this comment.
Change to
lint::builtin::BuiltinLintDiagnostics::UnknownCrateTypes(
span,
"did you mean".to_string(),
format!("\"{}\"", candidate),
);
There was a problem hiding this comment.
As noted in the prior discussion, use span_suggestion_with_applicability. MaybeIncorrect is always a safe bet to use, MachineApplicable is not consistently used throughout the codebase. It sometimes means 100% certainty, while others it means "95% of the cases this error fires, this suggestion is correct". I'm ok with the overly restrictive reading of the meaning.
There was a problem hiding this comment.
This line is too long, reformat.
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.
8830670 to
7249a1bComparephansch
commented
Sep 13, 2018
I sort of did a rebase by accident instead of adding new commits, but it should be all good now 👍 |
estebank
commented
Sep 13, 2018
@bors r+ rollup |
bors
commented
Sep 13, 2018
📌 Commit 7249a1b has been approved by |
…=estebank Suggest valid crate type if invalid crate type is found 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. Closesrust-lang#53958
Rollup of 8 pull requests Successful merges: - #53218 (Add a implementation of `From` for converting `&'a Option<T>` into `Option<&'a T>`) - #54024 (Fix compiling some rustc crates to wasm) - #54095 (Rename all mentions of `nil` to `unit`) - #54173 (Suggest valid crate type if invalid crate type is found) - #54194 (Remove println!() statement from HashMap unit test) - #54203 (Fix the stable release of os_str_str_ref_eq) - #54207 (re-mark the never docs as unstable) - #54210 (Update Cargo) Failed merges: r? @ghost
This adds a suggestion to the
invalid_crate_typeslint.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.
Closes#53958