From b20df8f5cc02e8e3fb04f1b76cb9a0a28e547aa4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Nov 2024 15:32:23 +0100 Subject: [PATCH] make forbidden_lint_groups a hard error --- compiler/rustc_lint/src/levels.rs | 26 +++++++++++--------------- compiler/rustc_lint/src/lints.rs | 14 +------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 4b1dafbdbeea2..3db3d38e46e7c 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -15,8 +15,8 @@ use rustc_middle::query::Providers; use rustc_middle::ty::{RegisteredTools, TyCtxt}; use rustc_session::Session; use rustc_session::lint::builtin::{ - self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES, - UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES, + self, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES, UNFULFILLED_LINT_EXPECTATIONS, + UNKNOWN_LINTS, UNUSED_ATTRIBUTES, }; use rustc_session::lint::{Level, Lint, LintExpectationId, LintId}; use rustc_span::symbol::{Symbol, sym}; @@ -34,9 +34,8 @@ use crate::fluent_generated as fluent; use crate::late::unerased_lint_store; use crate::lints::{ DeprecatedLintName, DeprecatedLintNameFromCommandLine, IgnoredUnlessCrateSpecified, - OverruledAttributeLint, RemovedLint, RemovedLintFromCommandLine, RenamedLint, - RenamedLintFromCommandLine, RenamedLintSuggestion, UnknownLint, UnknownLintFromCommandLine, - UnknownLintSuggestion, + RemovedLint, RemovedLintFromCommandLine, RenamedLint, RenamedLintFromCommandLine, + RenamedLintSuggestion, UnknownLint, UnknownLintFromCommandLine, UnknownLintSuggestion, }; /// Collection of lint levels for the whole crate. @@ -645,16 +644,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { sub, }); } else { - self.emit_span_lint( - FORBIDDEN_LINT_GROUPS, - src.span().into(), - OverruledAttributeLint { - overruled: src.span(), - lint_level: level.as_str(), - lint_source: src.name(), - sub, - }, - ); + self.sess.dcx().emit_err(OverruledAttribute { + span: src.span(), + overruled: src.span(), + lint_level: level.as_str(), + lint_source: src.name(), + sub, + }); } // Retain the forbid lint level, unless we are diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index dce6010a2c10e..d2d95ed04b123 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -20,7 +20,7 @@ use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; use rustc_span::{Span, Symbol, sym}; use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds}; -use crate::errors::{OverruledAttributeSub, RequestedLevel}; +use crate::errors::RequestedLevel; use crate::{LateContext, fluent_generated as fluent}; // array_into_iter.rs @@ -1023,18 +1023,6 @@ impl Subdiagnostic for NonBindingLetSub { } } -// levels.rs -#[derive(LintDiagnostic)] -#[diag(lint_overruled_attribute)] -pub(crate) struct OverruledAttributeLint<'a> { - #[label] - pub overruled: Span, - pub lint_level: &'a str, - pub lint_source: Symbol, - #[subdiagnostic] - pub sub: OverruledAttributeSub, -} - #[derive(LintDiagnostic)] #[diag(lint_deprecated_lint_name)] pub(crate) struct DeprecatedLintName<'a> {