Remove AttributeLintKind::NonMetaItemDiagnosticAttribute variant

This commit is contained in:
Guillaume Gomez
2026-04-23 23:08:40 +02:00
parent 87b0ce595c
commit 7a07b79573
5 changed files with 11 additions and 18 deletions
@@ -6,7 +6,7 @@
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
OnUnimplementedCondition, Piece, Predicate,
};
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
use rustc_hir::lints::FormatWarning;
use rustc_macros::Diagnostic;
use rustc_parse_format::{
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
@@ -21,7 +21,7 @@
use crate::errors::{
DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption,
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, MissingOptionsForDiagnosticAttribute,
WrappedParserError,
NonMetaItemDiagnosticAttribute, WrappedParserError,
};
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
@@ -145,9 +145,9 @@ fn parse_list<'p, S: Stage>(
// We're dealing with `#[diagnostic::attr()]`.
// This can be because that is what the user typed, but that's also what we'd see
// if the user used non-metaitem syntax. See `ArgParser::from_attr_args`.
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::NonMetaItemDiagnosticAttribute,
move |dcx, level| NonMetaItemDiagnosticAttribute.into_diag(dcx, level),
list.span,
);
}
@@ -400,3 +400,10 @@ pub(crate) struct MissingOptionsForDiagnosticAttribute {
pub attribute: &'static str,
pub options: &'static str,
}
#[derive(Diagnostic)]
#[diag("expected a literal or missing delimiter")]
#[help(
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
)]
pub(crate) struct NonMetaItemDiagnosticAttribute;
@@ -6,8 +6,6 @@
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use crate::lints;
mod check_cfg;
pub struct DiagAndSess<'sess> {
@@ -42,10 +40,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
check_cfg::unexpected_cfg_value(self.sess, self.tcx, name, value)
.into_diag(dcx, level)
}
&AttributeLintKind::NonMetaItemDiagnosticAttribute => {
lints::NonMetaItemDiagnosticAttribute.into_diag(dcx, level)
}
}
}
}
-7
View File
@@ -3286,10 +3286,3 @@ fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
#[note("this method was used to add checks to the `Eq` derive macro")]
pub(crate) struct EqInternalMethodImplemented;
#[derive(Diagnostic)]
#[diag("expected a literal or missing delimiter")]
#[help(
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
)]
pub(crate) struct NonMetaItemDiagnosticAttribute;
-1
View File
@@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind {
pub enum AttributeLintKind {
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
NonMetaItemDiagnosticAttribute,
}
#[derive(Debug, Clone, HashStable_Generic)]