Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions compiler/rustc_attr_parsing/src/attributes/crate_level.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_hir::attrs::{CrateType, WindowsSubsystemKind};
use rustc_session::lint::builtin::UNKNOWN_CRATE_TYPES;
use rustc_span::Symbol;
Expand Down Expand Up @@ -61,12 +60,8 @@ impl CombineAttributeParser for CrateTypeParser {
let span = n.value_span;
cx.emit_lint(
UNKNOWN_CRATE_TYPES,
move |dcx, level| {
UnknownCrateTypes {
sugg: candidate
.map(|s| UnknownCrateTypesSuggestion { span, snippet: s }),
}
.into_diag(dcx, level)
UnknownCrateTypes {
sugg: candidate.map(|s| UnknownCrateTypesSuggestion { span, snippet: s }),
},
span,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_feature::{AttributeTemplate, template};
use rustc_hir::Target;
use rustc_hir::attrs::AttributeKind;
Expand Down Expand Up @@ -26,7 +25,7 @@ impl SingleAttributeParser for DoNotRecommendParser {
if !matches!(args, ArgParser::NoArgs) {
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|dcx, level| crate::errors::DoNotRecommendDoesNotExpectArgs.into_diag(dcx, level),
crate::errors::DoNotRecommendDoesNotExpectArgs,
attr_span,
);
}
Expand All @@ -35,9 +34,7 @@ impl SingleAttributeParser for DoNotRecommendParser {
let target_span = cx.target_span;
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
IncorrectDoNotRecommendLocation { target_span }.into_diag(dcx, level)
},
IncorrectDoNotRecommendLocation { target_span },
attr_span,
);
return None;
Expand Down
61 changes: 21 additions & 40 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::Range;

use rustc_errors::{Diagnostic, E0232};
use rustc_errors::E0232;
use rustc_hir::AttrPath;
use rustc_hir::attrs::diagnostic::{
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
Expand Down Expand Up @@ -142,10 +142,7 @@ fn merge<T>(
let first_span = *first_span;
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
IgnoredDiagnosticOption { first_span, later_span, option_name }
.into_diag(dcx, level)
},
IgnoredDiagnosticOption { first_span, later_span, option_name },
later_span,
);
}
Expand All @@ -169,33 +166,27 @@ fn parse_list<'p>(
// if the user used non-metaitem syntax. See `ArgParser::from_attr_args`.
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| NonMetaItemDiagnosticAttribute.into_diag(dcx, level),
NonMetaItemDiagnosticAttribute,
list.span,
);
}
ArgParser::NoArgs => {
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
MissingOptionsForDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.expected_options(),
}
.into_diag(dcx, level)
MissingOptionsForDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.expected_options(),
},
span,
);
}
ArgParser::NameValue(_) => {
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
}
.into_diag(dcx, level)
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
},
span,
);
Expand Down Expand Up @@ -223,13 +214,10 @@ fn parse_directive_items<'p>(
macro malformed() {{
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
}
.into_diag(dcx, level)
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
},
span,
);
Expand All @@ -251,11 +239,11 @@ fn parse_directive_items<'p>(
let first_span = $($first_span)*;
cx.emit_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| IgnoredDiagnosticOption {
IgnoredDiagnosticOption {
first_span,
later_span: span,
option_name: $name,
}.into_diag(dcx, level),
},
span,
);
}}
Expand Down Expand Up @@ -285,25 +273,18 @@ fn parse_directive_items<'p>(
| FormatWarning::PositionalArgument { span }
| FormatWarning::IndexedArgument { span }
| FormatWarning::DisallowedPlaceholder { span, .. }) = warning;
cx.emit_lint(
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
move |dcx, level| warning.into_diag(dcx, level),
span,
);
cx.emit_lint(MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, warning, span);
}

f
}
Err(e) => {
cx.emit_lint(
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
move |dcx, level| {
WrappedParserError {
description: &e.description,
label: &e.label,
span: slice_span(input.span, e.span.clone(), is_snippet),
}
.into_diag(dcx, level)
WrappedParserError {
description: e.description,
label: e.label,
span: slice_span(input.span, e.span.clone(), is_snippet),
},
input.span,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_hir::attrs::diagnostic::Directive;
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;

Expand Down Expand Up @@ -30,9 +29,7 @@ impl AttributeParser for OnConstParser {
let target_span = cx.target_span;
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
DiagnosticOnConstOnlyForTraitImpls { target_span }.into_diag(dcx, level)
},
DiagnosticOnConstOnlyForTraitImpls { target_span },
span,
);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_feature::template;
use rustc_hir::attrs::AttributeKind;
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
Expand Down Expand Up @@ -28,11 +27,7 @@ impl OnMoveParser {
self.span = Some(span);

if !matches!(cx.target, Target::Enum | Target::Struct | Target::Union) {
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| DiagnosticOnMoveOnlyForAdt.into_diag(dcx, level),
span,
);
cx.emit_lint(MISPLACED_DIAGNOSTIC_ATTRIBUTES, DiagnosticOnMoveOnlyForAdt, span);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_hir::attrs::diagnostic::Directive;
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;

Expand All @@ -20,7 +19,7 @@ impl OnUnimplementedParser {
if !matches!(cx.target, Target::Trait) {
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| DiagnosticOnUnimplementedOnlyForTraits.into_diag(dcx, level),
DiagnosticOnUnimplementedOnlyForTraits,
span,
);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_hir::attrs::diagnostic::Directive;
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;

Expand Down Expand Up @@ -32,9 +31,7 @@ impl OnUnknownParser {
let target_span = cx.target_span;
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| {
DiagnosticOnUnknownOnlyForImports { target_span }.into_diag(dcx, level)
},
DiagnosticOnUnknownOnlyForImports { target_span },
span,
);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::Diagnostic;
use rustc_hir::attrs::diagnostic::Directive;
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;

Expand Down Expand Up @@ -27,7 +26,7 @@ impl AttributeParser for OnUnmatchArgsParser {
if !matches!(cx.target, Target::MacroDef) {
cx.emit_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
move |dcx, level| DiagnosticOnUnmatchArgsOnlyForMacros.into_diag(dcx, level),
DiagnosticOnUnmatchArgsOnlyForMacros,
span,
);
return;
Expand Down
Loading
Loading