Skip to content

Commit b716ebc

Browse files
Remove AttributeLintKind::IgnoredDiagnosticOption variant
1 parent f9cb684 commit b716ebc

5 files changed

Lines changed: 22 additions & 26 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use thin_vec::{ThinVec, thin_vec};
1919

2020
use crate::context::{AcceptContext, Stage};
2121
use crate::errors::{
22-
DisallowedPlaceholder, DisallowedPositionalArgument, InvalidFormatSpecifier,
23-
MalFormedDiagnosticAttributeLint, WrappedParserError,
22+
DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption,
23+
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, WrappedParserError,
2424
};
2525
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
2626

@@ -116,12 +116,12 @@ fn merge<T, S: Stage>(
116116
match (first, later) {
117117
(Some(_) | None, None) => {}
118118
(Some((first_span, _)), Some((later_span, _))) => {
119-
cx.emit_lint(
119+
let first_span = *first_span;
120+
cx.emit_dyn_lint(
120121
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
121-
AttributeLintKind::IgnoredDiagnosticOption {
122-
first_span: *first_span,
123-
later_span,
124-
option_name,
122+
move |dcx, level| {
123+
IgnoredDiagnosticOption { first_span, later_span, option_name }
124+
.into_diag(dcx, level)
125125
},
126126
later_span,
127127
);
@@ -220,13 +220,14 @@ fn parse_directive_items<'p, S: Stage>(
220220
}}
221221

222222
macro duplicate($name: ident, $($first_span:tt)*) {{
223-
cx.emit_lint(
223+
let first_span = $($first_span)*;
224+
cx.emit_dyn_lint(
224225
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
225-
AttributeLintKind::IgnoredDiagnosticOption {
226-
first_span: $($first_span)*,
226+
move |dcx, level| IgnoredDiagnosticOption {
227+
first_span,
227228
later_span: span,
228229
option_name: $name,
229-
},
230+
}.into_diag(dcx, level),
230231
span,
231232
);
232233
}}

compiler/rustc_attr_parsing/src/errors.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,13 @@ pub(crate) struct WrappedParserError<'a> {
382382
pub span: Span,
383383
pub label: &'a str,
384384
}
385+
386+
#[derive(Diagnostic)]
387+
#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
388+
pub(crate) struct IgnoredDiagnosticOption {
389+
pub option_name: Symbol,
390+
#[label("`{$option_name}` is first declared here")]
391+
pub first_span: Span,
392+
#[label("`{$option_name}` is later redundantly declared here")]
393+
pub later_span: Span,
394+
}

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> {
4343
.into_diag(dcx, level)
4444
}
4545

46-
&AttributeLintKind::IgnoredDiagnosticOption { option_name, first_span, later_span } => {
47-
lints::IgnoredDiagnosticOption { option_name, first_span, later_span }
48-
.into_diag(dcx, level)
49-
}
5046
&AttributeLintKind::MissingOptionsForDiagnosticAttribute { attribute, options } => {
5147
lints::MissingOptionsForDiagnosticAttribute { attribute, options }
5248
.into_diag(dcx, level)

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,16 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
32823282
}
32833283
}
32843284

3285-
#[derive(Diagnostic)]
3286-
#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
3287-
pub(crate) struct IgnoredDiagnosticOption {
3288-
pub option_name: Symbol,
3289-
#[label("`{$option_name}` is first declared here")]
3290-
pub first_span: Span,
3291-
#[label("`{$option_name}` is later redundantly declared here")]
3292-
pub later_span: Span,
3293-
}
3294-
32953285
#[derive(Diagnostic)]
32963286
#[diag("missing options for `{$attribute}` attribute")]
32973287
#[help("{$options}")]

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind {
656656
pub enum AttributeLintKind {
657657
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
658658
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
659-
IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span },
660659
MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str },
661660
NonMetaItemDiagnosticAttribute,
662661
}

0 commit comments

Comments
 (0)