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: Overlapping spans in delimited meta-vars #118928

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

EliseZeroTwo
Copy link
Contributor

Closes #118786

Delimited meta-vars inside of MBE's spans were set to have the same opening and closing position resulting in an ICE when debug assertions were enabled and an error was present in the templated code.

This ensures that the spans do not overlap, whilst still having the spans point at the usage of the meta-var inside the macro definition.

It includes a regression test.

🖤

@rustbot
Copy link
Collaborator

rustbot commented Dec 14, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@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 Dec 14, 2023
@petrochenkov
Copy link
Contributor

I have a PR in progress that removes this pile of hacks (if tts.len() == rhs.tts.len() { ... }) entirely.
It should be fine to land this for the test though.

@cjgillot
Copy link
Contributor

I'd have asked for a comment explaining the logic, but let's avoid the bother if this code is going away soon.
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 17, 2023

📌 Commit 770013d has been approved by cjgillot

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 Dec 17, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 17, 2023
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#118880 (More expressions correctly are marked to end with curly braces)
 - rust-lang#118928 (fix: Overlapping spans in delimited meta-vars)
 - rust-lang#119022 (Remove unnecessary constness from ProjectionCandidate)
 - rust-lang#119052 (Avoid overflow in GVN constant indexing.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 93d3a42 into rust-lang:master Dec 17, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 17, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 17, 2023
Rollup merge of rust-lang#118928 - EliseZeroTwo:EliseZeroTwo/fix-issue-118786, r=cjgillot

fix: Overlapping spans in delimited meta-vars

Closes rust-lang#118786

Delimited meta-vars inside of MBE's spans were set to have the same opening and closing position resulting in an ICE when debug assertions were enabled and an error was present in the templated code.

This ensures that the spans do not overlap, whilst still having the spans point at the usage of the meta-var inside the macro definition.

It includes a regression test.

🖤
@EliseZeroTwo
Copy link
Contributor Author

I'd have asked for a comment explaining the logic, but let's avoid the bother if this code is going away soon. @bors r+ rollup

The branch taken in the match statement without this change set both the open and close of the dspan to the entire span of the metavar which resulted in an overlapping span. With this change it sets open to the entire span of the metavar, and the close to the metavar span shrunk to just hi, which no longer resulted in an overlapping span.

Sorry for not providing more of an explanation of the changes in my pull request, I will try to make more of an explanation of the changes in future PRs.

@EliseZeroTwo EliseZeroTwo deleted the EliseZeroTwo/fix-issue-118786 branch December 19, 2023 15:58
@petrochenkov
Copy link
Contributor

I have a PR in progress that removes this pile of hacks (if tts.len() == rhs.tts.len() { ... }) entirely.

Submitted in #119204.

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 suggestion must not have overlapping parts with nested, malformed macro decl
5 participants