rust/tests/ui/asm/ice-bad-err-span-in-template-129503.rs
Gurinder Singh 3dd583d540 Fix error span when arg to asm!() is a macro call
When the template string passed to asm!() is produced by
a macro call like concat!() we were producing wrong error
spans. Now in the case of a macro call we just use the entire
arg to asm!(), macro call and all, as the error span.
2024-09-27 09:49:15 +05:30

27 lines
731 B
Rust
Raw Blame History

// Regression test for ICE #129503
// Tests that we come up with decent error spans
// when the template fed to `asm!()` is itself a
// macro call like `concat!()` and should not ICE
use std::arch::asm;
fn main() {
// Should not ICE
asm!(concat!(r#"lJ𐏿Æ<F0908FBF>.𐏿<>"#, "r} {}"));
//~^ ERROR invalid asm template string: unmatched `}` found
// Macro call template: should point to
// everything within `asm!()` as error span
asm!(concat!("abc", "r} {}"));
//~^ ERROR invalid asm template string: unmatched `}` found
// Literal template: should point precisely to
// just the `}` as error span
asm!("abc", "r} {}");
//~^ ERROR invalid asm template string: unmatched `}` found
}