pub static BINARY_ASM_LABELS: &Lint
Expand description
The binary_asm_labels
lint detects the use of numeric labels containing only binary
digits in the inline asm!
macro.
§Example
ⓘ
#![cfg(target_arch = "x86_64")]
use std::arch::asm;
fn main() {
unsafe {
asm!("0: jmp 0b");
}
}
This will produce:
error: avoid using labels containing only the digits `0` and `1` in inline assembly
--> <source>:7:15
|
7 | asm!("0: jmp 0b");
| ^ use a different label that doesn't start with `0` or `1`
|
= help: start numbering with `2` instead
= note: an LLVM bug makes these labels ambiguous with a binary literal number on x86
= note: see <https://github.com/llvm/llvm-project/issues/99547> for more information
= note: `#[deny(binary_asm_labels)]` on by default
§Explanation
An LLVM bug causes this code to fail to compile because it interprets the 0b
as a binary
literal instead of a reference to the previous local label 0
. To work around this bug,
don’t use labels that could be confused with a binary literal.
This behavior is platform-specific to x86 and x86-64.
See the explanation in Rust By Example for more details.