Skip to content

fix: Prevent infinite loops when parsing items from cfg_select! arms - #7089

Merged
jieyouxu merged 1 commit into
rust-lang:mainfrom
ytmimi:issue_7088
Sep 2, 2026
Merged

fix: Prevent infinite loops when parsing items from cfg_select! arms#7089
jieyouxu merged 1 commit into
rust-lang:mainfrom
ytmimi:issue_7088

Conversation

@ytmimi

@ytmimi ytmimi commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #7088

Before when we failed to parse an item we'd hit an infinite loop because we wouldn't advance the parser. Now we make sure to advance the parser before starting the next loop iteration.

  • 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.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Sep 1, 2026

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself seems reasonable. I'm unsure on the formatting of

cfg_select! {
    _ => {
        {}
        {}
    }
}

to

cfg_select! { _ => {{} {}}}

That seems... a bit curious? Oh I see, that's the source formatting.

@rustbot author

View changes since this review

@jieyouxu jieyouxu self-assigned this Sep 1, 2026
@jieyouxu jieyouxu added the X-impacts-stable-but-broken-formatting Expected formatting impact: affects stable formatting but where broken code was produced label Sep 1, 2026
@rustbot rustbot added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Sep 1, 2026
@rustbot

rustbot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@ytmimi

ytmimi commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Oh I see what's going on. The stable tests are failing because cfg_select! isn't getting formatted at all on stable because of our is_nightly_channel! gate. When comparing the source file with the target file it seems like cfg_select! { _ => {{} {}}} is getting formatted, but its not, and the diff we're seeing is just the diff between the source and target files. At least I'm pretty sure that's what's going on.

-cfg_select! {
-    _ => {
-        {}
-        {}
-    }
-}
+cfg_select! { _ => {{} {}}}

@jieyouxu

jieyouxu commented Sep 1, 2026

Copy link
Copy Markdown
Member

Ah right, yeah that'd make sense

@ytmimi ytmimi removed the X-impacts-stable-but-broken-formatting Expected formatting impact: affects stable formatting but where broken code was produced label Sep 1, 2026
Before when we failed to parse an item we'd hit an infinite loop because we
wouldn't advance the parser. Now we make sure to advance the parser before
starting the next loop iteration.

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jieyouxu
jieyouxu added this pull request to the merge queue Sep 2, 2026
Merged via the queue into rust-lang:main with commit ad6f6a7 Sep 2, 2026
31 checks passed
@rustbot rustbot added release-notes Needs an associated changelog entry and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes Needs an associated changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hang with cfg_select!

3 participants