diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index c1d6a4f1de1ff..cd6a6138c858e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -468,17 +468,17 @@ impl LintStore { fn no_lint_suggestion(&self, lint_name: &str) -> CheckLintNameResult<'_> { let name_lower = lint_name.to_lowercase(); - let symbols = - self.get_lints().iter().map(|l| Symbol::intern(&l.name_lower())).collect::>(); if lint_name.chars().any(char::is_uppercase) && self.find_lints(&name_lower).is_ok() { // First check if the lint name is (partly) in upper case instead of lower case... - CheckLintNameResult::NoLint(Some(Symbol::intern(&name_lower))) - } else { - // ...if not, search for lints with a similar name - let suggestion = find_best_match_for_name(&symbols, Symbol::intern(&name_lower), None); - CheckLintNameResult::NoLint(suggestion) + return CheckLintNameResult::NoLint(Some(Symbol::intern(&name_lower))); } + // ...if not, search for lints with a similar name + let groups = self.lint_groups.keys().copied().map(Symbol::intern); + let lints = self.lints.iter().map(|l| Symbol::intern(&l.name_lower())); + let names: Vec = groups.chain(lints).collect(); + let suggestion = find_best_match_for_name(&names, Symbol::intern(&name_lower), None); + CheckLintNameResult::NoLint(suggestion) } fn check_tool_name_for_backwards_compat( diff --git a/src/test/rustdoc-ui/unknown-renamed-lints.stderr b/src/test/rustdoc-ui/unknown-renamed-lints.stderr index 51e06821cf7ab..13e059c7809fc 100644 --- a/src/test/rustdoc-ui/unknown-renamed-lints.stderr +++ b/src/test/rustdoc-ui/unknown-renamed-lints.stderr @@ -14,7 +14,7 @@ error: unknown lint: `rustdoc::x` --> $DIR/unknown-renamed-lints.rs:7:9 | LL | #![deny(rustdoc::x)] - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: did you mean: `rustdoc::all` error: lint `intra_doc_link_resolution_failure` has been renamed to `rustdoc::broken_intra_doc_links` --> $DIR/unknown-renamed-lints.rs:9:9 diff --git a/src/test/ui/lint/lint-unknown-lint.rs b/src/test/ui/lint/lint-unknown-lint.rs index c36a8b2a4bf8c..2d842d5142097 100644 --- a/src/test/ui/lint/lint-unknown-lint.rs +++ b/src/test/ui/lint/lint-unknown-lint.rs @@ -6,4 +6,8 @@ //~| HELP did you mean //~| SUGGESTION dead_code +#![deny(rust_2018_idiots)] //~ ERROR unknown lint + //~| HELP did you mean + //~| SUGGESTION rust_2018_idioms + fn main() {} diff --git a/src/test/ui/lint/lint-unknown-lint.stderr b/src/test/ui/lint/lint-unknown-lint.stderr index 3a102769e855b..0cb6b49578cf3 100644 --- a/src/test/ui/lint/lint-unknown-lint.stderr +++ b/src/test/ui/lint/lint-unknown-lint.stderr @@ -16,5 +16,11 @@ error: unknown lint: `dead_cod` LL | #![deny(dead_cod)] | ^^^^^^^^ help: did you mean: `dead_code` -error: aborting due to 2 previous errors +error: unknown lint: `rust_2018_idiots` + --> $DIR/lint-unknown-lint.rs:9:9 + | +LL | #![deny(rust_2018_idiots)] + | ^^^^^^^^^^^^^^^^ help: did you mean: `rust_2018_idioms` + +error: aborting due to 3 previous errors