Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

gurry
Copy link
Contributor

@gurry gurry commented Sep 27, 2024

Fixes #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").

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
Copy link
Collaborator

rustbot commented Sep 27, 2024

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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
@chenyukang
Copy link
Member

will this fix also fix #114865 ?
if so please link it so this PR can close 114865.

@chenyukang
Copy link
Member

seems this fix only specific for asm!.

@chenyukang
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 27, 2024

📌 Commit 3dd583d has been approved by chenyukang

It is now in the queue for this repository.

@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
@gurry
Copy link
Contributor Author

gurry commented Sep 27, 2024

seems this fix only specific for asm!.

Yeah it's asm only.

@gurry
Copy link
Contributor Author

gurry commented Sep 27, 2024

#114865 seems to be the exact same issue but with format! instead of asm!. I'll fix it as well.

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
@bors bors merged commit 01fecf6 into rust-lang:master Sep 27, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 27, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
4 participants