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
|
.suggestion = try naming the parameter or explicitly ignoring it
|
||||||
|
|
||||||
lint_builtin_asm_labels = avoid using named labels in inline assembly
|
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}
|
lint_builtin_box_pointers = type uses owned (Box type) pointers: {$ty}
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ use crate::{
|
|||||||
BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures,
|
BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures,
|
||||||
BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents,
|
BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents,
|
||||||
BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc,
|
BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc,
|
||||||
BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns,
|
BuiltinMutablesTransmutes, BuiltinNamedAsmLabel, BuiltinNoMangleGeneric,
|
||||||
BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasGenericBounds,
|
BuiltinNonShorthandFieldPatterns, BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds,
|
||||||
BuiltinTypeAliasGenericBoundsSuggestion, BuiltinTypeAliasWhereClause,
|
BuiltinTypeAliasGenericBounds, BuiltinTypeAliasGenericBoundsSuggestion,
|
||||||
BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
|
BuiltinTypeAliasWhereClause, BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
|
||||||
BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe,
|
BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe,
|
||||||
BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
|
BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
|
||||||
BuiltinWhileTrue, SuggestChangingAssocTypes,
|
BuiltinWhileTrue, SuggestChangingAssocTypes,
|
||||||
@ -60,7 +60,7 @@ use rustc_middle::ty::GenericArgKind;
|
|||||||
use rustc_middle::ty::TypeVisitableExt;
|
use rustc_middle::ty::TypeVisitableExt;
|
||||||
use rustc_middle::ty::Upcast;
|
use rustc_middle::ty::Upcast;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
|
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_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
@ -2882,16 +2882,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
|
|||||||
let target_spans: MultiSpan =
|
let target_spans: MultiSpan =
|
||||||
if spans.len() > 0 { spans.into() } else { (*template_span).into() };
|
if spans.len() > 0 { spans.into() } else { (*template_span).into() };
|
||||||
|
|
||||||
cx.span_lint_with_diagnostics(
|
cx.emit_span_lint(NAMED_ASM_LABELS, target_spans, BuiltinNamedAsmLabel);
|
||||||
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(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,10 +179,6 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Di
|
|||||||
Applicability::MachineApplicable,
|
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) => {
|
BuiltinLintDiag::UnexpectedCfgName(name, value) => {
|
||||||
check_cfg::unexpected_cfg_name(sess, diag, name, value)
|
check_cfg::unexpected_cfg_name(sess, diag, name, value)
|
||||||
}
|
}
|
||||||
|
@ -1947,3 +1947,9 @@ pub struct UnitBindingsDiag {
|
|||||||
#[label]
|
#[label]
|
||||||
pub label: Span,
|
pub label: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(lint_builtin_asm_labels)]
|
||||||
|
#[help]
|
||||||
|
#[note]
|
||||||
|
pub struct BuiltinNamedAsmLabel;
|
||||||
|
@ -592,7 +592,6 @@ pub enum BuiltinLintDiag {
|
|||||||
ReservedPrefix(Span),
|
ReservedPrefix(Span),
|
||||||
TrailingMacro(bool, Ident),
|
TrailingMacro(bool, Ident),
|
||||||
BreakWithLabelAndLoop(Span),
|
BreakWithLabelAndLoop(Span),
|
||||||
NamedAsmLabel(String),
|
|
||||||
UnicodeTextFlow(Span, String),
|
UnicodeTextFlow(Span, String),
|
||||||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||||
|
Loading…
Reference in New Issue
Block a user