Change binary_asm_labels
to only fire on x86 and x86_64
In <https://github.com/rust-lang/rust/pull/126922>, the `binary_asm_labels` lint was added which flags labels such as `0:` and `1:`. Before that change, LLVM was giving a confusing error on x86/x86_64 because of an incorrect interpretation. However, targets other than x86 and x86_64 never had the error message and have not been a problem. This means that the lint was causing code that previously worked to start failing (e.g. `compiler_builtins`), rather than only providing a more clear messages where there has always been an error. Adjust the lint to only fire on x86 and x86_64 assembly to avoid this regression.
This commit is contained in:
parent
5753b30676
commit
9387a7523e
2 changed files with 33 additions and 9 deletions
|
@ -66,6 +66,7 @@ use rustc_span::source_map::Spanned;
|
|||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{BytePos, InnerSpan, Span};
|
||||
use rustc_target::abi::Abi;
|
||||
use rustc_target::asm::InlineAsmArch;
|
||||
use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt};
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy};
|
||||
|
@ -2908,16 +2909,22 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
|
|||
InvalidAsmLabel::FormatArg { missing_precise_span },
|
||||
);
|
||||
}
|
||||
AsmLabelKind::Binary => {
|
||||
// the binary asm issue only occurs when using intel syntax
|
||||
if !options.contains(InlineAsmOptions::ATT_SYNTAX) {
|
||||
cx.emit_span_lint(
|
||||
BINARY_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::Binary { missing_precise_span, span },
|
||||
)
|
||||
}
|
||||
// the binary asm issue only occurs when using intel syntax on x86 targets
|
||||
AsmLabelKind::Binary
|
||||
if !options.contains(InlineAsmOptions::ATT_SYNTAX)
|
||||
&& matches!(
|
||||
cx.tcx.sess.asm_arch,
|
||||
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) | None
|
||||
) =>
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
BINARY_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::Binary { missing_precise_span, span },
|
||||
)
|
||||
}
|
||||
// No lint on anything other than x86
|
||||
AsmLabelKind::Binary => (),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue