From ecff1c012e9e78a0a85ece64a0823ef69fc56363 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 30 Aug 2023 14:19:53 +0100 Subject: [PATCH 1/3] test(ui/lint): demonstrate the current cmdline lint behavior This demonstrates the current behavior of adding lint form the command line. generally the lint levels are ignored as the current implementation unconditionally emit errors for those lints. --- tests/ui/lint/lint-removed-cmdline-deny.rs | 12 +++++++++ .../ui/lint/lint-removed-cmdline-deny.stderr | 27 +++++++++++++++++++ tests/ui/lint/lint-renamed-cmdline-deny.rs | 8 ++++++ .../ui/lint/lint-renamed-cmdline-deny.stderr | 27 +++++++++++++++++++ .../lint/lint-unknown-lint-cmdline-allow.rs | 3 +++ .../lint-unknown-lint-cmdline-allow.stderr | 21 +++++++++++++++ .../ui/lint/lint-unknown-lint-cmdline-deny.rs | 8 ++++++ .../lint-unknown-lint-cmdline-deny.stderr | 21 +++++++++++++++ 8 files changed, 127 insertions(+) create mode 100644 tests/ui/lint/lint-removed-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-removed-cmdline-deny.stderr create mode 100644 tests/ui/lint/lint-renamed-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-renamed-cmdline-deny.stderr create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-allow.rs create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr diff --git a/tests/ui/lint/lint-removed-cmdline-deny.rs b/tests/ui/lint/lint-removed-cmdline-deny.rs new file mode 100644 index 0000000000000..82dce61869ba5 --- /dev/null +++ b/tests/ui/lint/lint-removed-cmdline-deny.rs @@ -0,0 +1,12 @@ +// The raw_pointer_derived lint warns about its removal +// cc #30346 + +// compile-flags:-D renamed-and-removed-lints -D raw_pointer_derive + +// error-pattern:lint `raw_pointer_derive` has been removed +// error-pattern:requested on the command line with `-D raw_pointer_derive` + +#![warn(unused)] + +#[deny(warnings)] +fn main() { let unused = (); } diff --git a/tests/ui/lint/lint-removed-cmdline-deny.stderr b/tests/ui/lint/lint-removed-cmdline-deny.stderr new file mode 100644 index 0000000000000..61bf9890d4925 --- /dev/null +++ b/tests/ui/lint/lint-removed-cmdline-deny.stderr @@ -0,0 +1,27 @@ +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + +error: unused variable: `unused` + --> $DIR/lint-removed-cmdline-deny.rs:12:17 + | +LL | fn main() { let unused = (); } + | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` + | +note: the lint level is defined here + --> $DIR/lint-removed-cmdline-deny.rs:11:8 + | +LL | #[deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` + +error: aborting due to previous error; 3 warnings emitted + diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.rs b/tests/ui/lint/lint-renamed-cmdline-deny.rs new file mode 100644 index 0000000000000..f313ffd425441 --- /dev/null +++ b/tests/ui/lint/lint-renamed-cmdline-deny.rs @@ -0,0 +1,8 @@ +// compile-flags:-D renamed-and-removed-lints -D bare_trait_object + +// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects` +// error-pattern:requested on the command line with `-D bare_trait_object` +// error-pattern:unused + +#[deny(unused)] +fn main() { let unused = (); } diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.stderr b/tests/ui/lint/lint-renamed-cmdline-deny.stderr new file mode 100644 index 0000000000000..2b360e5f3d8eb --- /dev/null +++ b/tests/ui/lint/lint-renamed-cmdline-deny.stderr @@ -0,0 +1,27 @@ +warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` + | + = note: requested on the command line with `-D bare_trait_object` + +warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` + | + = note: requested on the command line with `-D bare_trait_object` + +warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` + | + = note: requested on the command line with `-D bare_trait_object` + +error: unused variable: `unused` + --> $DIR/lint-renamed-cmdline-deny.rs:8:17 + | +LL | fn main() { let unused = (); } + | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` + | +note: the lint level is defined here + --> $DIR/lint-renamed-cmdline-deny.rs:7:8 + | +LL | #[deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]` + +error: aborting due to previous error; 3 warnings emitted + diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs new file mode 100644 index 0000000000000..7549d076710da --- /dev/null +++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs @@ -0,0 +1,3 @@ +// compile-flags:-A unknown-lints -D bogus -D dead_cod + +fn main() { } diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr new file mode 100644 index 0000000000000..3855d55279291 --- /dev/null +++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr @@ -0,0 +1,21 @@ +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0602`. diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs new file mode 100644 index 0000000000000..461984239a8b3 --- /dev/null +++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs @@ -0,0 +1,8 @@ +// compile-flags:-D unknown-lints -D bogus -D dead_cod + +// error-pattern:unknown lint: `bogus` +// error-pattern:requested on the command line with `-D bogus` +// error-pattern:requested on the command line with `-D dead_cod` +// error-pattern:did you mean: `dead_code` + +fn main() { } diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr new file mode 100644 index 0000000000000..3855d55279291 --- /dev/null +++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr @@ -0,0 +1,21 @@ +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0602`. From cdbad43aba4805ca67de043dd74f617ce5f982a4 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 28 Aug 2023 19:16:54 +0100 Subject: [PATCH 2/3] refactor(rustc_lint): inline `check_lint_name_cmdline` --- compiler/rustc_lint/src/context.rs | 67 ------------------------------ compiler/rustc_lint/src/levels.rs | 63 +++++++++++++++++++++++++++- compiler/rustc_lint/src/tests.rs | 2 +- 3 files changed, 62 insertions(+), 70 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 9dfde84b55263..7a336a8f69474 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -16,10 +16,6 @@ use self::TargetLint::*; -use crate::errors::{ - CheckNameDeprecated, CheckNameRemoved, CheckNameRenamed, CheckNameUnknown, - CheckNameUnknownTool, RequestedLevel, UnsupportedGroup, -}; use crate::levels::LintLevelsBuilder; use crate::passes::{EarlyLintPassObject, LateLintPassObject}; use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS; @@ -330,58 +326,6 @@ impl LintStore { } } - /// Checks the validity of lint names derived from the command line. - pub fn check_lint_name_cmdline( - &self, - sess: &Session, - lint_name: &str, - level: Level, - registered_tools: &RegisteredTools, - ) { - let (tool_name, lint_name_only) = parse_lint_and_tool_name(lint_name); - if lint_name_only == crate::WARNINGS.name_lower() && matches!(level, Level::ForceWarn(_)) { - sess.emit_err(UnsupportedGroup { lint_group: crate::WARNINGS.name_lower() }); - return; - } - match self.check_lint_name(lint_name_only, tool_name, registered_tools) { - CheckLintNameResult::Renamed(replace) => { - sess.emit_warning(CheckNameRenamed { - lint_name, - replace: &replace, - sub: RequestedLevel { level, lint_name }, - }); - } - CheckLintNameResult::Removed(reason) => { - sess.emit_warning(CheckNameRemoved { - lint_name, - reason: &reason, - sub: RequestedLevel { level, lint_name }, - }); - } - CheckLintNameResult::NoLint(suggestion) => { - sess.emit_err(CheckNameUnknown { - lint_name, - suggestion, - sub: RequestedLevel { level, lint_name }, - }); - } - CheckLintNameResult::Tool(Err((Some(_), new_name))) => { - sess.emit_warning(CheckNameDeprecated { - lint_name, - new_name: &new_name, - sub: RequestedLevel { level, lint_name }, - }); - } - CheckLintNameResult::NoTool => { - sess.emit_err(CheckNameUnknownTool { - tool_name: tool_name.unwrap(), - sub: RequestedLevel { level, lint_name }, - }); - } - _ => {} - }; - } - /// True if this symbol represents a lint group name. pub fn is_lint_group(&self, lint_name: Symbol) -> bool { debug!( @@ -1402,14 +1346,3 @@ impl<'tcx> LayoutOfHelpers<'tcx> for LateContext<'tcx> { err } } - -pub fn parse_lint_and_tool_name(lint_name: &str) -> (Option, &str) { - match lint_name.split_once("::") { - Some((tool_name, lint_name)) => { - let tool_name = Symbol::intern(tool_name); - - (Some(tool_name), lint_name) - } - None => (None, lint_name), - } -} diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index f58782c0f2244..13419ae05da90 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -1,3 +1,7 @@ +use crate::errors::{ + CheckNameDeprecated, CheckNameRemoved, CheckNameRenamed, CheckNameUnknown, + CheckNameUnknownTool, RequestedLevel, UnsupportedGroup, +}; use crate::{ builtin::MISSING_DOCS, context::{CheckLintNameResult, LintStore}, @@ -552,12 +556,56 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { fn add_command_line(&mut self) { for &(ref lint_name, level) in &self.sess.opts.lint_opts { - self.store.check_lint_name_cmdline(self.sess, &lint_name, level, self.registered_tools); + // Checks the validity of lint names derived from the command line. + let (tool_name, lint_name_only) = parse_lint_and_tool_name(lint_name); + if lint_name_only == crate::WARNINGS.name_lower() + && matches!(level, Level::ForceWarn(_)) + { + self.sess.emit_err(UnsupportedGroup { lint_group: crate::WARNINGS.name_lower() }); + } + match self.store.check_lint_name(lint_name_only, tool_name, self.registered_tools) { + CheckLintNameResult::Renamed(replace) => { + self.sess.emit_warning(CheckNameRenamed { + lint_name, + replace: &replace, + sub: RequestedLevel { level, lint_name }, + }); + } + CheckLintNameResult::Removed(reason) => { + self.sess.emit_warning(CheckNameRemoved { + lint_name, + reason: &reason, + sub: RequestedLevel { level, lint_name }, + }); + } + CheckLintNameResult::NoLint(suggestion) => { + self.sess.emit_err(CheckNameUnknown { + lint_name, + suggestion, + sub: RequestedLevel { level, lint_name }, + }); + } + CheckLintNameResult::Tool(Err((Some(_), new_name))) => { + self.sess.emit_warning(CheckNameDeprecated { + lint_name, + new_name: &new_name, + sub: RequestedLevel { level, lint_name }, + }); + } + CheckLintNameResult::NoTool => { + self.sess.emit_err(CheckNameUnknownTool { + tool_name: tool_name.unwrap(), + sub: RequestedLevel { level, lint_name }, + }); + } + _ => {} + }; + let orig_level = level; let lint_flag_val = Symbol::intern(lint_name); let Ok(ids) = self.store.find_lints(&lint_name) else { - // errors handled in check_lint_name_cmdline above + // errors already handled above continue; }; for id in ids { @@ -1092,3 +1140,14 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { shallow_lint_levels_on, lint_expectations, ..*providers }; } + +pub fn parse_lint_and_tool_name(lint_name: &str) -> (Option, &str) { + match lint_name.split_once("::") { + Some((tool_name, lint_name)) => { + let tool_name = Symbol::intern(tool_name); + + (Some(tool_name), lint_name) + } + None => (None, lint_name), + } +} diff --git a/compiler/rustc_lint/src/tests.rs b/compiler/rustc_lint/src/tests.rs index fc9d6f636b214..4fd054cb7179f 100644 --- a/compiler/rustc_lint/src/tests.rs +++ b/compiler/rustc_lint/src/tests.rs @@ -1,4 +1,4 @@ -use crate::context::parse_lint_and_tool_name; +use crate::levels::parse_lint_and_tool_name; use rustc_span::{create_default_session_globals_then, Symbol}; #[test] From a11805ae46b23d1cc80f7332417cb809ff1c6d64 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 28 Aug 2023 20:28:51 +0100 Subject: [PATCH 3/3] feat(rustc_lint): make `CheckLintName` respect lint level --- compiler/rustc_lint/messages.ftl | 11 +-- compiler/rustc_lint/src/errors.rs | 54 +----------- compiler/rustc_lint/src/levels.rs | 84 +++++++++---------- compiler/rustc_lint/src/lints.rs | 68 ++++++++++++--- .../plugin/lint-tool-cmdline-allow.stderr | 10 ++- tests/ui/error-codes/E0602.rs | 2 + tests/ui/error-codes/E0602.stderr | 11 ++- tests/ui/lint/cli-unknown-force-warn.rs | 6 +- tests/ui/lint/cli-unknown-force-warn.stderr | 11 ++- tests/ui/lint/lint-removed-cmdline-deny.rs | 1 + .../ui/lint/lint-removed-cmdline-deny.stderr | 13 +-- tests/ui/lint/lint-removed-cmdline.rs | 1 + tests/ui/lint/lint-removed-cmdline.stderr | 5 +- tests/ui/lint/lint-renamed-cmdline-deny.rs | 2 + .../ui/lint/lint-renamed-cmdline-deny.stderr | 16 ++-- tests/ui/lint/lint-renamed-cmdline.rs | 1 + tests/ui/lint/lint-renamed-cmdline.stderr | 8 +- .../ui/lint/lint-unexported-no-mangle.stderr | 1 + .../lint/lint-unknown-lint-cmdline-allow.rs | 1 + .../lint-unknown-lint-cmdline-allow.stderr | 21 ----- .../ui/lint/lint-unknown-lint-cmdline-deny.rs | 1 + .../lint-unknown-lint-cmdline-deny.stderr | 12 ++- tests/ui/lint/lint-unknown-lint-cmdline.rs | 2 + .../ui/lint/lint-unknown-lint-cmdline.stderr | 20 +++-- 24 files changed, 191 insertions(+), 171 deletions(-) delete mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 7f7f36ca170dd..ba50c9e00e3f8 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -156,15 +156,6 @@ lint_builtin_unused_doc_comment = unused doc comment lint_builtin_while_true = denote infinite loops with `loop {"{"} ... {"}"}` .suggestion = use `loop` -lint_check_name_deprecated = lint name `{$lint_name}` is deprecated and does not have an effect anymore. Use: {$new_name} - -lint_check_name_removed = lint `{$lint_name}` has been removed: {$reason} - -lint_check_name_renamed = lint `{$lint_name}` has been renamed to `{$replace}` - -lint_check_name_unknown = unknown lint: `{$lint_name}` - .help = did you mean: `{$suggestion}` - lint_check_name_unknown_tool = unknown lint tool: `{$tool_name}` lint_command_line_source = `forbid` lint level was set on command line @@ -187,6 +178,7 @@ lint_default_source = `forbid` lint level is the default for {$id} lint_deprecated_lint_name = lint name `{$name}` is deprecated and may not have an effect in the future. .suggestion = change it to + .help = change it to {$replace} lint_diag_out_of_impl = diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls @@ -528,6 +520,7 @@ lint_unknown_gated_lint = lint_unknown_lint = unknown lint: `{$name}` .suggestion = did you mean + .help = did you mean: `{$replace}` lint_unknown_tool_in_scoped_lint = unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}` .help = add `#![register_tool({$tool_name})]` to the crate root diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index 607875b3faa2f..eccea35c702e0 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -1,7 +1,5 @@ use crate::fluent_generated as fluent; -use rustc_errors::{ - AddToDiagnostic, Diagnostic, ErrorGuaranteed, Handler, IntoDiagnostic, SubdiagnosticMessage, -}; +use rustc_errors::{AddToDiagnostic, Diagnostic, SubdiagnosticMessage}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_session::lint::Level; use rustc_span::{Span, Symbol}; @@ -102,29 +100,6 @@ pub struct UnsupportedGroup { pub lint_group: String, } -pub struct CheckNameUnknown<'a> { - pub lint_name: &'a str, - pub suggestion: Option, - pub sub: RequestedLevel<'a>, -} - -impl IntoDiagnostic<'_> for CheckNameUnknown<'_> { - fn into_diagnostic( - self, - handler: &Handler, - ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { - let mut diag = handler.struct_err(fluent::lint_check_name_unknown); - diag.code(rustc_errors::error_code!(E0602)); - if let Some(suggestion) = self.suggestion { - diag.help(fluent::lint_help); - diag.set_arg("suggestion", suggestion); - } - diag.set_arg("lint_name", self.lint_name); - diag.subdiagnostic(self.sub); - diag - } -} - #[derive(Diagnostic)] #[diag(lint_check_name_unknown_tool, code = "E0602")] pub struct CheckNameUnknownTool<'a> { @@ -132,30 +107,3 @@ pub struct CheckNameUnknownTool<'a> { #[subdiagnostic] pub sub: RequestedLevel<'a>, } - -#[derive(Diagnostic)] -#[diag(lint_check_name_renamed)] -pub struct CheckNameRenamed<'a> { - pub lint_name: &'a str, - pub replace: &'a str, - #[subdiagnostic] - pub sub: RequestedLevel<'a>, -} - -#[derive(Diagnostic)] -#[diag(lint_check_name_removed)] -pub struct CheckNameRemoved<'a> { - pub lint_name: &'a str, - pub reason: &'a str, - #[subdiagnostic] - pub sub: RequestedLevel<'a>, -} - -#[derive(Diagnostic)] -#[diag(lint_check_name_deprecated)] -pub struct CheckNameDeprecated<'a> { - pub lint_name: &'a str, - pub new_name: &'a str, - #[subdiagnostic] - pub sub: RequestedLevel<'a>, -} diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 13419ae05da90..df67cf5d12ff9 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -1,6 +1,7 @@ -use crate::errors::{ - CheckNameDeprecated, CheckNameRemoved, CheckNameRenamed, CheckNameUnknown, - CheckNameUnknownTool, RequestedLevel, UnsupportedGroup, +use crate::errors::{CheckNameUnknownTool, RequestedLevel, UnsupportedGroup}; +use crate::lints::{ + DeprecatedLintNameFromCommandLine, RemovedLintFromCommandLine, RenamedLintFromCommandLine, + UnknownLintFromCommandLine, }; use crate::{ builtin::MISSING_DOCS, @@ -564,33 +565,32 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { self.sess.emit_err(UnsupportedGroup { lint_group: crate::WARNINGS.name_lower() }); } match self.store.check_lint_name(lint_name_only, tool_name, self.registered_tools) { - CheckLintNameResult::Renamed(replace) => { - self.sess.emit_warning(CheckNameRenamed { - lint_name, - replace: &replace, - sub: RequestedLevel { level, lint_name }, - }); + CheckLintNameResult::Renamed(ref replace) => { + let name = lint_name.as_str(); + let suggestion = RenamedLintSuggestion::WithoutSpan { replace }; + let requested_level = RequestedLevel { level, lint_name }; + let lint = RenamedLintFromCommandLine { name, suggestion, requested_level }; + self.emit_lint(RENAMED_AND_REMOVED_LINTS, lint); } - CheckLintNameResult::Removed(reason) => { - self.sess.emit_warning(CheckNameRemoved { - lint_name, - reason: &reason, - sub: RequestedLevel { level, lint_name }, - }); + CheckLintNameResult::Removed(ref reason) => { + let name = lint_name.as_str(); + let requested_level = RequestedLevel { level, lint_name }; + let lint = RemovedLintFromCommandLine { name, reason, requested_level }; + self.emit_lint(RENAMED_AND_REMOVED_LINTS, lint); } CheckLintNameResult::NoLint(suggestion) => { - self.sess.emit_err(CheckNameUnknown { - lint_name, - suggestion, - sub: RequestedLevel { level, lint_name }, - }); + let name = lint_name.clone(); + let suggestion = + suggestion.map(|replace| UnknownLintSuggestion::WithoutSpan { replace }); + let requested_level = RequestedLevel { level, lint_name }; + let lint = UnknownLintFromCommandLine { name, suggestion, requested_level }; + self.emit_lint(UNKNOWN_LINTS, lint); } - CheckLintNameResult::Tool(Err((Some(_), new_name))) => { - self.sess.emit_warning(CheckNameDeprecated { - lint_name, - new_name: &new_name, - sub: RequestedLevel { level, lint_name }, - }); + CheckLintNameResult::Tool(Err((Some(_), ref replace))) => { + let name = lint_name.clone(); + let requested_level = RequestedLevel { level, lint_name }; + let lint = DeprecatedLintNameFromCommandLine { name, replace, requested_level }; + self.emit_lint(RENAMED_AND_REMOVED_LINTS, lint); } CheckLintNameResult::NoTool => { self.sess.emit_err(CheckNameUnknownTool { @@ -963,24 +963,18 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { _ if !self.warn_about_weird_lints => {} - CheckLintNameResult::Renamed(new_name) => { + CheckLintNameResult::Renamed(ref replace) => { let suggestion = - RenamedLintSuggestion { suggestion: sp, replace: new_name.as_str() }; + RenamedLintSuggestion::WithSpan { suggestion: sp, replace }; let name = tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name); - self.emit_spanned_lint( - RENAMED_AND_REMOVED_LINTS, - sp.into(), - RenamedLint { name: name.as_str(), suggestion }, - ); + let lint = RenamedLint { name: name.as_str(), suggestion }; + self.emit_spanned_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); } - CheckLintNameResult::Removed(reason) => { + CheckLintNameResult::Removed(ref reason) => { let name = tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name); - self.emit_spanned_lint( - RENAMED_AND_REMOVED_LINTS, - sp.into(), - RemovedLint { name: name.as_str(), reason: reason.as_str() }, - ); + let lint = RemovedLint { name: name.as_str(), reason }; + self.emit_spanned_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); } CheckLintNameResult::NoLint(suggestion) => { @@ -989,13 +983,11 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { } else { name.to_string() }; - let suggestion = suggestion - .map(|replace| UnknownLintSuggestion { suggestion: sp, replace }); - self.emit_spanned_lint( - UNKNOWN_LINTS, - sp.into(), - UnknownLint { name, suggestion }, - ); + let suggestion = suggestion.map(|replace| { + UnknownLintSuggestion::WithSpan { suggestion: sp, replace } + }); + let lint = UnknownLint { name, suggestion }; + self.emit_spanned_lint(UNKNOWN_LINTS, sp.into(), lint); } } // If this lint was renamed, apply the new lint instead of ignoring the attribute. diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 0e942d774a7fe..3e26d6dc32d40 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2,6 +2,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] use std::num::NonZeroU32; +use crate::errors::RequestedLevel; use crate::fluent_generated as fluent; use rustc_errors::{ AddToDiagnostic, Applicability, DecorateLint, DiagnosticMessage, DiagnosticStyledString, @@ -1012,6 +1013,16 @@ pub struct DeprecatedLintName<'a> { pub replace: &'a str, } +#[derive(LintDiagnostic)] +#[diag(lint_deprecated_lint_name)] +#[help] +pub struct DeprecatedLintNameFromCommandLine<'a> { + pub name: String, + pub replace: &'a str, + #[subdiagnostic] + pub requested_level: RequestedLevel<'a>, +} + #[derive(LintDiagnostic)] #[diag(lint_renamed_lint)] pub struct RenamedLint<'a> { @@ -1021,11 +1032,25 @@ pub struct RenamedLint<'a> { } #[derive(Subdiagnostic)] -#[suggestion(lint_suggestion, code = "{replace}", applicability = "machine-applicable")] -pub struct RenamedLintSuggestion<'a> { - #[primary_span] - pub suggestion: Span, - pub replace: &'a str, +pub enum RenamedLintSuggestion<'a> { + #[suggestion(lint_suggestion, code = "{replace}", applicability = "machine-applicable")] + WithSpan { + #[primary_span] + suggestion: Span, + replace: &'a str, + }, + #[help(lint_help)] + WithoutSpan { replace: &'a str }, +} + +#[derive(LintDiagnostic)] +#[diag(lint_renamed_lint)] +pub struct RenamedLintFromCommandLine<'a> { + pub name: &'a str, + #[subdiagnostic] + pub suggestion: RenamedLintSuggestion<'a>, + #[subdiagnostic] + pub requested_level: RequestedLevel<'a>, } #[derive(LintDiagnostic)] @@ -1035,6 +1060,15 @@ pub struct RemovedLint<'a> { pub reason: &'a str, } +#[derive(LintDiagnostic)] +#[diag(lint_removed_lint)] +pub struct RemovedLintFromCommandLine<'a> { + pub name: &'a str, + pub reason: &'a str, + #[subdiagnostic] + pub requested_level: RequestedLevel<'a>, +} + #[derive(LintDiagnostic)] #[diag(lint_unknown_lint)] pub struct UnknownLint { @@ -1044,11 +1078,25 @@ pub struct UnknownLint { } #[derive(Subdiagnostic)] -#[suggestion(lint_suggestion, code = "{replace}", applicability = "maybe-incorrect")] -pub struct UnknownLintSuggestion { - #[primary_span] - pub suggestion: Span, - pub replace: Symbol, +pub enum UnknownLintSuggestion { + #[suggestion(lint_suggestion, code = "{replace}", applicability = "maybe-incorrect")] + WithSpan { + #[primary_span] + suggestion: Span, + replace: Symbol, + }, + #[help(lint_help)] + WithoutSpan { replace: Symbol }, +} + +#[derive(LintDiagnostic)] +#[diag(lint_unknown_lint, code = "E0602")] +pub struct UnknownLintFromCommandLine<'a> { + pub name: String, + #[subdiagnostic] + pub suggestion: Option, + #[subdiagnostic] + pub requested_level: RequestedLevel<'a>, } #[derive(LintDiagnostic)] diff --git a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr index b060e3a3e38b4..0e66179599989 100644 --- a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr +++ b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr @@ -1,9 +1,12 @@ -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint +warning: lint name `test_lint` is deprecated and may not have an effect in the future. | + = help: change it to clippy::test_lint = note: requested on the command line with `-A test_lint` + = note: `#[warn(renamed_and_removed_lints)]` on by default -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint +warning: lint name `test_lint` is deprecated and may not have an effect in the future. | + = help: change it to clippy::test_lint = note: requested on the command line with `-A test_lint` warning: item is named 'lintme' @@ -22,8 +25,9 @@ LL | #![plugin(lint_tool_test)] | = note: `#[warn(deprecated)]` on by default -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint +warning: lint name `test_lint` is deprecated and may not have an effect in the future. | + = help: change it to clippy::test_lint = note: requested on the command line with `-A test_lint` warning: 5 warnings emitted diff --git a/tests/ui/error-codes/E0602.rs b/tests/ui/error-codes/E0602.rs index 8fadce526d9aa..77d28838a10c2 100644 --- a/tests/ui/error-codes/E0602.rs +++ b/tests/ui/error-codes/E0602.rs @@ -1,6 +1,8 @@ // compile-flags:-D bogus +// check-pass // error-pattern:E0602 // error-pattern:requested on the command line with `-D bogus` +// error-pattern:`#[warn(unknown_lints)]` on by default fn main() {} diff --git a/tests/ui/error-codes/E0602.stderr b/tests/ui/error-codes/E0602.stderr index 2b37226334586..60ecec7cdd7c5 100644 --- a/tests/ui/error-codes/E0602.stderr +++ b/tests/ui/error-codes/E0602.stderr @@ -1,11 +1,16 @@ -error[E0602]: unknown lint: `bogus` +warning[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` + = note: `#[warn(unknown_lints)]` on by default -error[E0602]: unknown lint: `bogus` +warning[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` -error: aborting due to 2 previous errors +warning[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +warning: 3 warnings emitted For more information about this error, try `rustc --explain E0602`. diff --git a/tests/ui/lint/cli-unknown-force-warn.rs b/tests/ui/lint/cli-unknown-force-warn.rs index f3dea87a6b69a..a9e4e4a60179e 100644 --- a/tests/ui/lint/cli-unknown-force-warn.rs +++ b/tests/ui/lint/cli-unknown-force-warn.rs @@ -1,7 +1,11 @@ // Checks that rustc correctly errors when passed an invalid lint with // `--force-warn`. This is a regression test for issue #86958. -// + +// check-pass // compile-flags: --force-warn foo-qux + // error-pattern: unknown lint: `foo_qux` +// error-pattern: requested on the command line with `--force-warn foo_qux` +// error-pattern: `#[warn(unknown_lints)]` on by default fn main() {} diff --git a/tests/ui/lint/cli-unknown-force-warn.stderr b/tests/ui/lint/cli-unknown-force-warn.stderr index 9ce9f405aee69..2ee718a8c8e11 100644 --- a/tests/ui/lint/cli-unknown-force-warn.stderr +++ b/tests/ui/lint/cli-unknown-force-warn.stderr @@ -1,11 +1,16 @@ -error[E0602]: unknown lint: `foo_qux` +warning[E0602]: unknown lint: `foo_qux` | = note: requested on the command line with `--force-warn foo_qux` + = note: `#[warn(unknown_lints)]` on by default -error[E0602]: unknown lint: `foo_qux` +warning[E0602]: unknown lint: `foo_qux` | = note: requested on the command line with `--force-warn foo_qux` -error: aborting due to 2 previous errors +warning[E0602]: unknown lint: `foo_qux` + | + = note: requested on the command line with `--force-warn foo_qux` + +warning: 3 warnings emitted For more information about this error, try `rustc --explain E0602`. diff --git a/tests/ui/lint/lint-removed-cmdline-deny.rs b/tests/ui/lint/lint-removed-cmdline-deny.rs index 82dce61869ba5..8cf91cf60eb1d 100644 --- a/tests/ui/lint/lint-removed-cmdline-deny.rs +++ b/tests/ui/lint/lint-removed-cmdline-deny.rs @@ -5,6 +5,7 @@ // error-pattern:lint `raw_pointer_derive` has been removed // error-pattern:requested on the command line with `-D raw_pointer_derive` +// error-pattern:requested on the command line with `-D renamed-and-removed-lints` #![warn(unused)] diff --git a/tests/ui/lint/lint-removed-cmdline-deny.stderr b/tests/ui/lint/lint-removed-cmdline-deny.stderr index 61bf9890d4925..80c85d01e53c0 100644 --- a/tests/ui/lint/lint-removed-cmdline-deny.stderr +++ b/tests/ui/lint/lint-removed-cmdline-deny.stderr @@ -1,27 +1,28 @@ -warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok +error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok | = note: requested on the command line with `-D raw_pointer_derive` + = note: requested on the command line with `-D renamed-and-removed-lints` -warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok +error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok | = note: requested on the command line with `-D raw_pointer_derive` -warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok +error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok | = note: requested on the command line with `-D raw_pointer_derive` error: unused variable: `unused` - --> $DIR/lint-removed-cmdline-deny.rs:12:17 + --> $DIR/lint-removed-cmdline-deny.rs:13:17 | LL | fn main() { let unused = (); } | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` | note: the lint level is defined here - --> $DIR/lint-removed-cmdline-deny.rs:11:8 + --> $DIR/lint-removed-cmdline-deny.rs:12:8 | LL | #[deny(warnings)] | ^^^^^^^^ = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` -error: aborting due to previous error; 3 warnings emitted +error: aborting due to 4 previous errors diff --git a/tests/ui/lint/lint-removed-cmdline.rs b/tests/ui/lint/lint-removed-cmdline.rs index 462beabb9451c..34373df3a9c62 100644 --- a/tests/ui/lint/lint-removed-cmdline.rs +++ b/tests/ui/lint/lint-removed-cmdline.rs @@ -4,6 +4,7 @@ // compile-flags:-D raw_pointer_derive // error-pattern:lint `raw_pointer_derive` has been removed +// error-pattern:`#[warn(renamed_and_removed_lints)]` on by default // error-pattern:requested on the command line with `-D raw_pointer_derive` #![warn(unused)] diff --git a/tests/ui/lint/lint-removed-cmdline.stderr b/tests/ui/lint/lint-removed-cmdline.stderr index 9be532ef234d1..ebfae34ade92f 100644 --- a/tests/ui/lint/lint-removed-cmdline.stderr +++ b/tests/ui/lint/lint-removed-cmdline.stderr @@ -1,6 +1,7 @@ warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok | = note: requested on the command line with `-D raw_pointer_derive` + = note: `#[warn(renamed_and_removed_lints)]` on by default warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok | @@ -11,13 +12,13 @@ warning: lint `raw_pointer_derive` has been removed: using derive with raw point = note: requested on the command line with `-D raw_pointer_derive` error: unused variable: `unused` - --> $DIR/lint-removed-cmdline.rs:12:17 + --> $DIR/lint-removed-cmdline.rs:13:17 | LL | fn main() { let unused = (); } | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` | note: the lint level is defined here - --> $DIR/lint-removed-cmdline.rs:11:8 + --> $DIR/lint-removed-cmdline.rs:12:8 | LL | #[deny(warnings)] | ^^^^^^^^ diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.rs b/tests/ui/lint/lint-renamed-cmdline-deny.rs index f313ffd425441..01629aaca80d4 100644 --- a/tests/ui/lint/lint-renamed-cmdline-deny.rs +++ b/tests/ui/lint/lint-renamed-cmdline-deny.rs @@ -1,7 +1,9 @@ // compile-flags:-D renamed-and-removed-lints -D bare_trait_object // error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects` +// error-pattern:use the new name `bare_trait_objects` // error-pattern:requested on the command line with `-D bare_trait_object` +// error-pattern:requested on the command line with `-D renamed-and-removed-lints` // error-pattern:unused #[deny(unused)] diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.stderr b/tests/ui/lint/lint-renamed-cmdline-deny.stderr index 2b360e5f3d8eb..df22ef60daf13 100644 --- a/tests/ui/lint/lint-renamed-cmdline-deny.stderr +++ b/tests/ui/lint/lint-renamed-cmdline-deny.stderr @@ -1,27 +1,31 @@ -warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` +error: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` + = note: requested on the command line with `-D renamed-and-removed-lints` -warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` +error: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` -warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` +error: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` error: unused variable: `unused` - --> $DIR/lint-renamed-cmdline-deny.rs:8:17 + --> $DIR/lint-renamed-cmdline-deny.rs:10:17 | LL | fn main() { let unused = (); } | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` | note: the lint level is defined here - --> $DIR/lint-renamed-cmdline-deny.rs:7:8 + --> $DIR/lint-renamed-cmdline-deny.rs:9:8 | LL | #[deny(unused)] | ^^^^^^ = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]` -error: aborting due to previous error; 3 warnings emitted +error: aborting due to 4 previous errors diff --git a/tests/ui/lint/lint-renamed-cmdline.rs b/tests/ui/lint/lint-renamed-cmdline.rs index c873771e3081c..fba7c33311df4 100644 --- a/tests/ui/lint/lint-renamed-cmdline.rs +++ b/tests/ui/lint/lint-renamed-cmdline.rs @@ -2,6 +2,7 @@ // error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects` // error-pattern:requested on the command line with `-D bare_trait_object` +// error-pattern:`#[warn(renamed_and_removed_lints)]` on by default // error-pattern:unused #[deny(unused)] diff --git a/tests/ui/lint/lint-renamed-cmdline.stderr b/tests/ui/lint/lint-renamed-cmdline.stderr index 8dfd61ac927a9..a41284003ed64 100644 --- a/tests/ui/lint/lint-renamed-cmdline.stderr +++ b/tests/ui/lint/lint-renamed-cmdline.stderr @@ -1,23 +1,27 @@ warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` + = note: `#[warn(renamed_and_removed_lints)]` on by default warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` | + = help: use the new name `bare_trait_objects` = note: requested on the command line with `-D bare_trait_object` error: unused variable: `unused` - --> $DIR/lint-renamed-cmdline.rs:8:17 + --> $DIR/lint-renamed-cmdline.rs:9:17 | LL | fn main() { let unused = (); } | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` | note: the lint level is defined here - --> $DIR/lint-renamed-cmdline.rs:7:8 + --> $DIR/lint-renamed-cmdline.rs:8:8 | LL | #[deny(unused)] | ^^^^^^ diff --git a/tests/ui/lint/lint-unexported-no-mangle.stderr b/tests/ui/lint/lint-unexported-no-mangle.stderr index a11ee769c7c18..858527822220a 100644 --- a/tests/ui/lint/lint-unexported-no-mangle.stderr +++ b/tests/ui/lint/lint-unexported-no-mangle.stderr @@ -1,6 +1,7 @@ warning: lint `private_no_mangle_fns` has been removed: no longer a warning, `#[no_mangle]` functions always exported | = note: requested on the command line with `-F private_no_mangle_fns` + = note: `#[warn(renamed_and_removed_lints)]` on by default warning: lint `private_no_mangle_statics` has been removed: no longer a warning, `#[no_mangle]` statics always exported | diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs index 7549d076710da..c7f8d434c0401 100644 --- a/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs +++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs @@ -1,3 +1,4 @@ +// check-pass // compile-flags:-A unknown-lints -D bogus -D dead_cod fn main() { } diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr deleted file mode 100644 index 3855d55279291..0000000000000 --- a/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0602]: unknown lint: `bogus` - | - = note: requested on the command line with `-D bogus` - -error[E0602]: unknown lint: `dead_cod` - | - = help: did you mean: `dead_code` - = note: requested on the command line with `-D dead_cod` - -error[E0602]: unknown lint: `bogus` - | - = note: requested on the command line with `-D bogus` - -error[E0602]: unknown lint: `dead_cod` - | - = help: did you mean: `dead_code` - = note: requested on the command line with `-D dead_cod` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0602`. diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs index 461984239a8b3..31bc204735664 100644 --- a/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs +++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs @@ -3,6 +3,7 @@ // error-pattern:unknown lint: `bogus` // error-pattern:requested on the command line with `-D bogus` // error-pattern:requested on the command line with `-D dead_cod` +// error-pattern:requested on the command line with `-D unknown-lints` // error-pattern:did you mean: `dead_code` fn main() { } diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr index 3855d55279291..677b5edc894b3 100644 --- a/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr +++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr @@ -1,6 +1,7 @@ error[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` + = note: requested on the command line with `-D unknown-lints` error[E0602]: unknown lint: `dead_cod` | @@ -16,6 +17,15 @@ error[E0602]: unknown lint: `dead_cod` = help: did you mean: `dead_code` = note: requested on the command line with `-D dead_cod` -error: aborting due to 4 previous errors +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0602`. diff --git a/tests/ui/lint/lint-unknown-lint-cmdline.rs b/tests/ui/lint/lint-unknown-lint-cmdline.rs index 7f3f55fbad0f4..81539cb6dc15a 100644 --- a/tests/ui/lint/lint-unknown-lint-cmdline.rs +++ b/tests/ui/lint/lint-unknown-lint-cmdline.rs @@ -1,7 +1,9 @@ +// check-pass // compile-flags:-D bogus -D dead_cod // error-pattern:unknown lint: `bogus` // error-pattern:requested on the command line with `-D bogus` +// error-pattern:`#[warn(unknown_lints)]` on by default // error-pattern:unknown lint: `dead_cod` // error-pattern:requested on the command line with `-D dead_cod` // error-pattern:did you mean: `dead_code` diff --git a/tests/ui/lint/lint-unknown-lint-cmdline.stderr b/tests/ui/lint/lint-unknown-lint-cmdline.stderr index 3855d55279291..10db76ac4f16b 100644 --- a/tests/ui/lint/lint-unknown-lint-cmdline.stderr +++ b/tests/ui/lint/lint-unknown-lint-cmdline.stderr @@ -1,21 +1,31 @@ -error[E0602]: unknown lint: `bogus` +warning[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` + = note: `#[warn(unknown_lints)]` on by default -error[E0602]: unknown lint: `dead_cod` +warning[E0602]: unknown lint: `dead_cod` | = help: did you mean: `dead_code` = note: requested on the command line with `-D dead_cod` -error[E0602]: unknown lint: `bogus` +warning[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` -error[E0602]: unknown lint: `dead_cod` +warning[E0602]: unknown lint: `dead_cod` | = help: did you mean: `dead_code` = note: requested on the command line with `-D dead_cod` -error: aborting due to 4 previous errors +warning[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +warning[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +warning: 6 warnings emitted For more information about this error, try `rustc --explain E0602`.