Fix error span if arg to `asm!()` is a macro call by gurry · Pull Request #130917 · rust-lang/rust

@gurry

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.

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Sep 27, 2024

@gurry gurry changed the title Fix error span if arg to asm!() is a macro call Fix error span if arg to asm!() is a macro call

Sep 27, 2024

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Sep 27, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Sep 27, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#129087 (Stabilize `option_get_or_insert_default`)
 - rust-lang#130435 (Move Apple linker args from `rustc_target` to `rustc_codegen_ssa`)
 - rust-lang#130459 (delete sub build directory "debug" to not delete the change-id file)
 - rust-lang#130873 (rustc_target: Add powerpc64 atomic-related features)
 - rust-lang#130916 (Use `&raw` in the compiler)
 - rust-lang#130917 (Fix error span if arg to `asm!()` is a macro call)
 - rust-lang#130927 (update outdated comments)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Sep 27, 2024
Rollup merge of rust-lang#130917 - gurry:129503-ice-wrong-span-in-macros, r=chenyukang

Fix error span if arg to `asm!()` is a macro call

Fixes rust-lang#129503

When the argument to `asm!()` is a macro call, e.g. `asm!(concat!("abc", "{} pqr"))`, and there's an error in the resulting template string, we do not take into account the presence of this macro call while computing the error span. This PR fixes that. Now we will use the entire thing between the parenthesis of `asm!()` as the error span in this situation e.g. for `asm!(concat!("abc", "{} pqr"))` the error span will be `concat!("abc", "{} pqr")`.

@gurry gurry deleted the 129503-ice-wrong-span-in-macros branch

September 27, 2024 23:36

@gurry gurry mentioned this pull request

Feb 5, 2026

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request

Feb 9, 2026

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request

Feb 9, 2026

rust-timer added a commit that referenced this pull request

Feb 10, 2026