diff options
| author | Martin Nordholts <martin.nordholts@codetale.se> | 2023-12-28 19:09:03 +0100 |
|---|---|---|
| committer | Martin Nordholts <martin.nordholts@codetale.se> | 2023-12-28 19:46:51 +0100 |
| commit | 7ca4e9fcb24e8f1c1e2d0af2fbb2ffab22df0a8b (patch) | |
| tree | ee29a16839f9644de11f3bef0bc64e75304bf622 /compiler | |
| parent | 741884dab2f4fba532f15be05c85bd94983405e6 (diff) | |
| download | rust-7ca4e9fcb24e8f1c1e2d0af2fbb2ffab22df0a8b.tar.gz rust-7ca4e9fcb24e8f1c1e2d0af2fbb2ffab22df0a8b.zip | |
rustc_lint: Prevent triplication of 'unknown lint' lint
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/levels.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index c781033a261..c229728cb79 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -1054,33 +1054,33 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { /// Checks if the lint is gated on a feature that is not enabled. /// /// Returns `true` if the lint's feature is enabled. - // FIXME only emit this once for each attribute, instead of repeating it 4 times for - // pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`. #[track_caller] fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool { if let Some(feature) = lint_id.lint.feature_gate { if !self.features.active(feature) { - let lint = builtin::UNKNOWN_LINTS; - let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS); - struct_lint_level( - self.sess, - lint, - level, - src, - Some(span.into()), - fluent::lint_unknown_gated_lint, - |lint| { - lint.set_arg("name", lint_id.lint.name_lower()); - lint.note(fluent::lint_note); - rustc_session::parse::add_feature_diagnostics_for_issue( - lint, - &self.sess.parse_sess, - feature, - GateIssue::Language, - lint_from_cli, - ); - }, - ); + if self.lint_added_lints { + let lint = builtin::UNKNOWN_LINTS; + let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS); + struct_lint_level( + self.sess, + lint, + level, + src, + Some(span.into()), + fluent::lint_unknown_gated_lint, + |lint| { + lint.set_arg("name", lint_id.lint.name_lower()); + lint.note(fluent::lint_note); + rustc_session::parse::add_feature_diagnostics_for_issue( + lint, + &self.sess.parse_sess, + feature, + GateIssue::Language, + lint_from_cli, + ); + }, + ); + } return false; } } |
