Static rustc_lint_defs::builtin::BAD_ASM_STYLE

source ·
pub static BAD_ASM_STYLE: &Lint
Expand description

The bad_asm_style lint detects the use of the .intel_syntax and .att_syntax directives.


use std::arch::asm;

fn main() {
    unsafe {
            "movq %{0}, %{0}", in(reg) 0usize

This will produce:

warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
 --> src/
8 |             ".att_syntax",
  |              ^^^^^^^^^^^
  = note: `#[warn(bad_asm_style)]` on by default


On x86, asm! uses the intel assembly syntax by default. While this can be switched using assembler directives like .att_syntax, using the att_syntax option is recommended instead because it will also properly prefix register placeholders with % as required by AT&T syntax.