Skip to content

Avoid prematurely choosing a glob import#153912

Open
mu001999 wants to merge 1 commit intorust-lang:mainfrom
mu001999-contrib:fix-153842
Open

Avoid prematurely choosing a glob import#153912
mu001999 wants to merge 1 commit intorust-lang:mainfrom
mu001999-contrib:fix-153842

Conversation

@mu001999
Copy link
Contributor

@mu001999 mu001999 commented Mar 15, 2026

Fixes #153842

Use the following without introducing trait to explain:

mod a {
    pub use crate::x::y as x; // single import #1
}

mod b {
    pub mod x {
        pub mod y {}
    }
}

use a::x; // single import #2
use b::*; // glob import #3

fn main() {}

In current implementation, when #1 is first resolved, crate::x is temporarily taken from glob import #3 as crate::b::x. This happens because single_import_can_define_name will see that #2 cannot define x (because it depends on #1 and #1 is ignored) and then return false. Later, during finalization, crate::x in #1 resolves through single import #2 instead, which no longer matches the initially cached module crate::b::x and triggers the ICE.

I think the resolver should keep this unresolved because #2 may still define x to avoid prematurely choosing a glob import.

r? petrochenkov

@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 Mar 15, 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. 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: inconsistent resolution for an import

3 participants