Skip to content

fix: prevent ICE on lifetime-only macro arguments - #7100

Open
saberoueslati wants to merge 1 commit into
rust-lang:mainfrom
saberoueslati:parser/fix-issue-7034
Open

fix: prevent ICE on lifetime-only macro arguments#7100
saberoueslati wants to merge 1 commit into
rust-lang:mainfrom
saberoueslati:parser/fix-issue-7034

Conversation

@saberoueslati

Copy link
Copy Markdown

Fixes #7034.

Problem

Malformed macro arguments ending in &'a trigger rustc’s pattern parser, which creates an empty suggestion span at EOF and trips a debug assertion. &&'a variants are also affected because && is parsed as nested & tokens.

Fix

Skip speculative pattern parsing when a run of &/&& tokens is followed by a lifetime. Valid types remain unaffected, and rustfmt uses its existing unparseable-macro fallback.

Testing

Added &'a, &&'a, and &&&'a cases to dont_emit_ICE. Full cargo test passes.

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

LLM was used to understand the issue and as an extra reviewer for my code

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE with debug-assertions]: Span must not be empty and have no suggestion

2 participants