Skip to content

Commit 78019fd

Browse files
authored
Unrolled build for #155706
Rollup merge of #155706 - GuillaumeGomez:rm-attributelintkind, r=JonathanBrouwer Remove `AttributeLintKind` variants - part 7 Part of #153099. It's the last easy one. Next one will require to get the crate name and to pass `Session` to the remaining lints. Fun times ahead. :) r? @JonathanBrouwer
2 parents d493b7c + 7a07b79 commit 78019fd

5 files changed

Lines changed: 27 additions & 35 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::attrs::diagnostic::{
66
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
77
OnUnimplementedCondition, Piece, Predicate,
88
};
9-
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
9+
use rustc_hir::lints::FormatWarning;
1010
use rustc_macros::Diagnostic;
1111
use rustc_parse_format::{
1212
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
@@ -20,7 +20,8 @@ use thin_vec::{ThinVec, thin_vec};
2020
use crate::context::{AcceptContext, Stage};
2121
use crate::errors::{
2222
DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption,
23-
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, WrappedParserError,
23+
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, MissingOptionsForDiagnosticAttribute,
24+
NonMetaItemDiagnosticAttribute, WrappedParserError,
2425
};
2526
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
2627

@@ -144,18 +145,21 @@ fn parse_list<'p, S: Stage>(
144145
// We're dealing with `#[diagnostic::attr()]`.
145146
// This can be because that is what the user typed, but that's also what we'd see
146147
// if the user used non-metaitem syntax. See `ArgParser::from_attr_args`.
147-
cx.emit_lint(
148+
cx.emit_dyn_lint(
148149
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
149-
AttributeLintKind::NonMetaItemDiagnosticAttribute,
150+
move |dcx, level| NonMetaItemDiagnosticAttribute.into_diag(dcx, level),
150151
list.span,
151152
);
152153
}
153154
ArgParser::NoArgs => {
154-
cx.emit_lint(
155+
cx.emit_dyn_lint(
155156
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
156-
AttributeLintKind::MissingOptionsForDiagnosticAttribute {
157-
attribute: mode.as_str(),
158-
options: mode.expected_options(),
157+
move |dcx, level| {
158+
MissingOptionsForDiagnosticAttribute {
159+
attribute: mode.as_str(),
160+
options: mode.expected_options(),
161+
}
162+
.into_diag(dcx, level)
159163
},
160164
span,
161165
);

compiler/rustc_attr_parsing/src/errors.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,18 @@ pub(crate) struct IgnoredDiagnosticOption {
392392
#[label("`{$option_name}` is later redundantly declared here")]
393393
pub later_span: Span,
394394
}
395+
396+
#[derive(Diagnostic)]
397+
#[diag("missing options for `{$attribute}` attribute")]
398+
#[help("{$options}")]
399+
pub(crate) struct MissingOptionsForDiagnosticAttribute {
400+
pub attribute: &'static str,
401+
pub options: &'static str,
402+
}
403+
404+
#[derive(Diagnostic)]
405+
#[diag("expected a literal or missing delimiter")]
406+
#[help(
407+
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
408+
)]
409+
pub(crate) struct NonMetaItemDiagnosticAttribute;

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use rustc_hir::lints::AttributeLintKind;
66
use rustc_middle::ty::TyCtxt;
77
use rustc_session::Session;
88

9-
use crate::lints;
10-
119
mod check_cfg;
1210

1311
pub struct DiagAndSess<'sess> {
@@ -42,14 +40,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> {
4240
check_cfg::unexpected_cfg_value(self.sess, self.tcx, name, value)
4341
.into_diag(dcx, level)
4442
}
45-
46-
&AttributeLintKind::MissingOptionsForDiagnosticAttribute { attribute, options } => {
47-
lints::MissingOptionsForDiagnosticAttribute { attribute, options }
48-
.into_diag(dcx, level)
49-
}
50-
&AttributeLintKind::NonMetaItemDiagnosticAttribute => {
51-
lints::NonMetaItemDiagnosticAttribute.into_diag(dcx, level)
52-
}
5343
}
5444
}
5545
}

compiler/rustc_lint/src/lints.rs

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

3285-
#[derive(Diagnostic)]
3286-
#[diag("missing options for `{$attribute}` attribute")]
3287-
#[help("{$options}")]
3288-
pub(crate) struct MissingOptionsForDiagnosticAttribute {
3289-
pub attribute: &'static str,
3290-
pub options: &'static str,
3291-
}
3292-
32933285
#[derive(Diagnostic)]
32943286
#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
32953287
#[note("this method was used to add checks to the `Eq` derive macro")]
32963288
pub(crate) struct EqInternalMethodImplemented;
3297-
3298-
#[derive(Diagnostic)]
3299-
#[diag("expected a literal or missing delimiter")]
3300-
#[help(
3301-
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
3302-
)]
3303-
pub(crate) struct NonMetaItemDiagnosticAttribute;

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,6 @@ pub enum DeprecatedSinceKind {
656656
pub enum AttributeLintKind {
657657
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
658658
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
659-
MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str },
660-
NonMetaItemDiagnosticAttribute,
661659
}
662660

663661
#[derive(Debug, Clone, HashStable_Generic)]

0 commit comments

Comments
 (0)