Skip to content

Avoid ICE when cfg_eval recovers no item from derive input#158417

Open
TaKO8Ki wants to merge 2 commits into
rust-lang:mainfrom
TaKO8Ki:fix-cfg-eval-derive-reparse-ice
Open

Avoid ICE when cfg_eval recovers no item from derive input#158417
TaKO8Ki wants to merge 2 commits into
rust-lang:mainfrom
TaKO8Ki:fix-cfg-eval-derive-reparse-ice

Conversation

@TaKO8Ki

@TaKO8Ki TaKO8Ki commented Jun 25, 2026

Copy link
Copy Markdown
Member

Fixes #148891

cfg_eval reparses derive input when it contains #[cfg] or #[cfg_attr] so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return Ok(None) when parser recovery cannot reconstruct an item.

This pr changes the reparse path to return Option<Annotatable> and fall back to the original annotatable when recovery produces no node.

@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 Jun 25, 2026
@rustbot

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 17 candidates

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 14e5371 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 29, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 29, 2026
…e-ice, r=petrochenkov

Avoid ICE when cfg_eval recovers no item from derive input

Fixes rust-lang#148891

`cfg_eval` reparses derive input when it contains `#[cfg]` or `#[cfg_attr]` so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return `Ok(None)` when parser recovery cannot reconstruct an item.

This pr changes the reparse path to return `Option<Annotatable>` and fall back to the original annotatable when recovery produces no node.
rust-bors Bot pushed a commit that referenced this pull request Jun 29, 2026
Rollup of 12 pull requests

Successful merges:

 - #158073 (bootstrap: fix panic when repo path contains spaces by switching to CARGO_ENCODED_RUSTFLAGS)
 - #158169 (Fix debuginfo compression in bootstrap)
 - #158256 (Avoid parser panics bubbling out to proc macros)
 - #158375 (Support `DefKind::InlineConst` in `ConstKind::Unevaluated`)
 - #158417 (Avoid ICE when cfg_eval recovers no item from derive input)
 - #158556 (delegation: store child segment flag in `PathSegment`)
 - #158561 (Avoid building rustdoc for tests without doctests)
 - #158562 (Improve tracing of steps in bootstrap)
 - #157445 (Allow section override when using patchable-function-entries)
 - #158081 (trait-system: Recover deferred closure calls after errors)
 - #158327 (Move attribute and keyword docs from `std` to `core`)
 - #158468 (Include default-stability info in rustdoc JSON.)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 29, 2026
…e-ice, r=petrochenkov

Avoid ICE when cfg_eval recovers no item from derive input

Fixes rust-lang#148891

`cfg_eval` reparses derive input when it contains `#[cfg]` or `#[cfg_attr]` so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return `Ok(None)` when parser recovery cannot reconstruct an item.

This pr changes the reparse path to return `Option<Annotatable>` and fall back to the original annotatable when recovery produces no node.
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #158578 (comment)

Seems like somebody sneaked in a crashtest while this PR was open

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 29, 2026
@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#158578), which was unapproved.

View changes since this unapproval

@rust-bors

This comment has been minimized.

@TaKO8Ki
TaKO8Ki force-pushed the fix-cfg-eval-derive-reparse-ice branch from 14e5371 to 3f88370 Compare July 27, 2026 07:23
@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@TaKO8Ki

TaKO8Ki commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@bors r=petrochenkov

@rust-bors

rust-bors Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3f88370 has been approved by petrochenkov

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 27, 2026
…e-ice, r=petrochenkov

Avoid ICE when cfg_eval recovers no item from derive input

Fixes rust-lang#148891

`cfg_eval` reparses derive input when it contains `#[cfg]` or `#[cfg_attr]` so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return `Ok(None)` when parser recovery cannot reconstruct an item.

This pr changes the reparse path to return `Option<Annotatable>` and fall back to the original annotatable when recovery produces no node.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 27, 2026
…e-ice, r=petrochenkov

Avoid ICE when cfg_eval recovers no item from derive input

Fixes rust-lang#148891

`cfg_eval` reparses derive input when it contains `#[cfg]` or `#[cfg_attr]` so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return `Ok(None)` when parser recovery cannot reconstruct an item.

This pr changes the reparse path to return `Option<Annotatable>` and fall back to the original annotatable when recovery produces no node.
rust-bors Bot pushed a commit that referenced this pull request Jul 27, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #158417 (Avoid ICE when cfg_eval recovers no item from derive input)
 - #159085 (Fix decoding attributes of `SyntheticCoroutineBody`)
 - #159554 (feat: Update method signature of int_from_ascii)
 - #159637 (Some place analysis tweaks)
 - #159649 (Normalize region obligations before regionck)
 - #159961 (sanitize_standard_fds: Miri supports poll now)
 - #159967 (rustc_target: callconv: mips64: Return structs with single f128 in FPRs)
 - #159253 (Add suggestions for using `#[export_name]` instead of `#[link_name]` on static)
 - #159804 (Expand docs for fs::metadata and fs::symlink_metadata)
 - #159821 (Update expect message using the recommended style in binary_heap module)
 - #159840 (Fix opaque type ICE in late lints under the next-generation trait solver)
 - #159956 (Fix observable intermediate state in `thread::add_spawn_hook`)
 - #159991 (std: make send_process_group_signal unsupported on VxWorks)
 - #159996 (Detect when a macro without exclamation mark uses square brackets)
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: None in compiler/rustc_builtin_macros/src/cfg_eval.rs

4 participants