mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Convert NAMED_ASM_LABELS lint to diag struct
This commit is contained in:
parent
36902fbcf6
commit
bac6b6248b
@ -30,6 +30,8 @@ lint_builtin_anonymous_params = anonymous parameters are deprecated and will be
|
||||
.suggestion = try naming the parameter or explicitly ignoring it
|
||||
|
||||
lint_builtin_asm_labels = avoid using named labels in inline assembly
|
||||
.help = only local labels of the form `<number>:` should be used in inline asm
|
||||
.note = see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
|
||||
|
||||
lint_builtin_box_pointers = type uses owned (Box type) pointers: {$ty}
|
||||
|
||||
|
@ -30,10 +30,10 @@ use crate::{
|
||||
BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures,
|
||||
BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents,
|
||||
BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc,
|
||||
BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns,
|
||||
BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasGenericBounds,
|
||||
BuiltinTypeAliasGenericBoundsSuggestion, BuiltinTypeAliasWhereClause,
|
||||
BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
|
||||
BuiltinMutablesTransmutes, BuiltinNamedAsmLabel, BuiltinNoMangleGeneric,
|
||||
BuiltinNonShorthandFieldPatterns, BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds,
|
||||
BuiltinTypeAliasGenericBounds, BuiltinTypeAliasGenericBoundsSuggestion,
|
||||
BuiltinTypeAliasWhereClause, BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
|
||||
BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe,
|
||||
BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
|
||||
BuiltinWhileTrue, SuggestChangingAssocTypes,
|
||||
@ -60,7 +60,7 @@ use rustc_middle::ty::GenericArgKind;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::Upcast;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
|
||||
use rustc_session::lint::{BuiltinLintDiag, FutureIncompatibilityReason};
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
@ -2882,16 +2882,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
|
||||
let target_spans: MultiSpan =
|
||||
if spans.len() > 0 { spans.into() } else { (*template_span).into() };
|
||||
|
||||
cx.span_lint_with_diagnostics(
|
||||
NAMED_ASM_LABELS,
|
||||
Some(target_spans),
|
||||
fluent::lint_builtin_asm_labels,
|
||||
|_| {},
|
||||
BuiltinLintDiag::NamedAsmLabel(
|
||||
"only local labels of the form `<number>:` should be used in inline asm"
|
||||
.to_string(),
|
||||
),
|
||||
);
|
||||
cx.emit_span_lint(NAMED_ASM_LABELS, target_spans, BuiltinNamedAsmLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,10 +179,6 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Di
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
BuiltinLintDiag::NamedAsmLabel(help) => {
|
||||
diag.help(help);
|
||||
diag.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
|
||||
}
|
||||
BuiltinLintDiag::UnexpectedCfgName(name, value) => {
|
||||
check_cfg::unexpected_cfg_name(sess, diag, name, value)
|
||||
}
|
||||
|
@ -1947,3 +1947,9 @@ pub struct UnitBindingsDiag {
|
||||
#[label]
|
||||
pub label: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_builtin_asm_labels)]
|
||||
#[help]
|
||||
#[note]
|
||||
pub struct BuiltinNamedAsmLabel;
|
||||
|
@ -592,7 +592,6 @@ pub enum BuiltinLintDiag {
|
||||
ReservedPrefix(Span),
|
||||
TrailingMacro(bool, Ident),
|
||||
BreakWithLabelAndLoop(Span),
|
||||
NamedAsmLabel(String),
|
||||
UnicodeTextFlow(Span, String),
|
||||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||
|
Loading…
Reference in New Issue
Block a user