Lint against named asm labels
This commit is contained in:
parent
7f3dc04644
commit
75915ad16f
6 changed files with 506 additions and 6 deletions
|
@ -2470,6 +2470,38 @@ declare_lint! {
|
|||
"incorrect use of inline assembly",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `named_asm_labels` lint detects the use of named labels in the
|
||||
/// inline `asm!` macro.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// fn main() {
|
||||
/// unsafe {
|
||||
/// asm!("foo: bar");
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// LLVM's assembler is allowed to duplicate inline assembly blocks for any
|
||||
/// reason, for example when it is in a function that gets inlined. Because
|
||||
/// of this, GNU assembler [local labels] *must* be used instead of labels
|
||||
/// with a name. Using named labels might cause assembler or linker errors.
|
||||
///
|
||||
/// See the [unstable book] for more details.
|
||||
///
|
||||
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
|
||||
/// [unstable book]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels
|
||||
pub NAMED_ASM_LABELS,
|
||||
Deny,
|
||||
"named labels in inline assembly",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
|
||||
/// functions without an explicit unsafe block.
|
||||
|
|
|
@ -274,7 +274,7 @@ impl<HCX> ToStableHashKey<HCX> for LintId {
|
|||
}
|
||||
|
||||
// Duplicated from rustc_session::config::ExternDepSpec to avoid cyclic dependency
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq)]
|
||||
pub enum ExternDepSpec {
|
||||
Json(Json),
|
||||
Raw(String),
|
||||
|
@ -282,7 +282,7 @@ pub enum ExternDepSpec {
|
|||
|
||||
// This could be a closure, but then implementing derive trait
|
||||
// becomes hacky (and it gets allocated).
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq)]
|
||||
pub enum BuiltinLintDiagnostics {
|
||||
Normal,
|
||||
BareTraitObject(Span, /* is_global */ bool),
|
||||
|
@ -305,6 +305,7 @@ pub enum BuiltinLintDiagnostics {
|
|||
ReservedPrefix(Span),
|
||||
TrailingMacro(bool, Ident),
|
||||
BreakWithLabelAndLoop(Span),
|
||||
NamedAsmLabel(String),
|
||||
}
|
||||
|
||||
/// Lints that are buffered up early on in the `Session` before the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue