Skip to content

Fix ICE when macro-expanded extern crate shadows std#153187

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
is57primenumber:fix-ice-on-shadowing
Feb 28, 2026
Merged

Fix ICE when macro-expanded extern crate shadows std#153187
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
is57primenumber:fix-ice-on-shadowing

Conversation

@is57primenumber
Copy link
Contributor

@is57primenumber is57primenumber commented Feb 27, 2026

Fixes #152895

This PR fixes an ICE that occurs when a macro-expanded extern crate shadows a prelude name, which leaves the resolver in an inconsistent state due to issue_145575_hack.

I disabled the assertion when the issue_145575_hack flag is enabled.
The fix is applied in two locations to cover both cases (whether is_error_from_last_segment is true or false).
This approach was inspired by the context and fix discussed in #151213.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2026

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 68 candidates
  • Random selection from 15 candidates

@jieyouxu
Copy link
Member

jieyouxu commented Feb 27, 2026

r? petrochenkov

@rust-lang rust-lang deleted a comment from rustbot Feb 27, 2026
@rustbot rustbot assigned petrochenkov and unassigned jieyouxu Feb 27, 2026
@petrochenkov
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 27, 2026

📌 Commit 54c505f 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 Feb 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 28, 2026
…ng, r=petrochenkov

Fix ICE when macro-expanded extern crate shadows std

Fixes rust-lang#152895

This PR fixes an ICE that occurs when a macro-expanded `extern crate` shadows a prelude name, which leaves the resolver in an inconsistent state due to `issue_145575_hack`.

I disabled the assertion when the `issue_145575_hack` flag is enabled.
The fix is applied in two locations to cover both cases (whether `is_error_from_last_segment` is true or false).
This approach was inspired by the context and fix discussed in rust-lang#151213.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 28, 2026
…ng, r=petrochenkov

Fix ICE when macro-expanded extern crate shadows std

Fixes rust-lang#152895

This PR fixes an ICE that occurs when a macro-expanded `extern crate` shadows a prelude name, which leaves the resolver in an inconsistent state due to `issue_145575_hack`.

I disabled the assertion when the `issue_145575_hack` flag is enabled.
The fix is applied in two locations to cover both cases (whether `is_error_from_last_segment` is true or false).
This approach was inspired by the context and fix discussed in rust-lang#151213.
rust-bors bot pushed a commit that referenced this pull request Feb 28, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #153211 (`rust-analyzer` subtree update)
 - #149027 (Improve cross-crate trait impl param mismatch suggestions )
 - #152730 (add field representing types)
 - #153136 (Correctly handle `#[doc(alias = "...")]` attribute on inlined reexports)
 - #152165 (Normalize capture place `ty`s to prevent ICE)
 - #152615 (refactor 'valid for read/write' definition: exclude null)
 - #153109 (Fix LegacyKeyValueFormat report from docker build: aarch64-gnu-debug)
 - #153172 (Fix comment about placeholders)
 - #153187 (Fix ICE when macro-expanded extern crate shadows std)
 - #153190 (Don't allow subdiagnostic to use variables from their parent)
 - #153200 (Remove redundant clone)
 - #153216 (mark two polonius tests as known-bug)
@rust-bors rust-bors bot merged commit d0a2fe8 into rust-lang:main Feb 28, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Feb 28, 2026
rust-timer added a commit that referenced this pull request Feb 28, 2026
Rollup merge of #153187 - is57primenumber:fix-ice-on-shadowing, r=petrochenkov

Fix ICE when macro-expanded extern crate shadows std

Fixes #152895

This PR fixes an ICE that occurs when a macro-expanded `extern crate` shadows a prelude name, which leaves the resolver in an inconsistent state due to `issue_145575_hack`.

I disabled the assertion when the `issue_145575_hack` flag is enabled.
The fix is applied in two locations to cover both cases (whether `is_error_from_last_segment` is true or false).
This approach was inspired by the context and fix discussed in #151213.
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]: import.imported_module.get().is_none()

4 participants