rust-lang / rust-lang/rust

[ICE]: inconsistent resolution for an import

Open
#154,296 3 comments 0 reactions 1 assignee View on GitHub

@TaKO8Ki is already working on this.

Since Mar 25, 2026.

A-resolve C-bug I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
mod m1 {
    mod inner {
        pub struct S {}
    }
    pub use self::inner::*;

    #[derive(Debug)]
    pub struct S {}
}






use {
    pub struct S {}
};
use m1::*;



original:

mod m1 {
    mod inner {
        pub struct S {}
    }
    pub use self::inner::*;

    #[derive(Debug)]
    pub struct S {}
}

mod m2 {
    #[derive(Debug)]
    pub struct S {}
}

// First we have a glob ambiguity in this glob (with `m2::*`).
// Then we re-fetch `m1::*` because non-glob `m1::S` materializes from derive,
// and we need to make sure that the glob ambiguity is not lost during re-fetching.
use {
    pub struct S {}
};
use m1::*;

fn main() {
    let _: m1S = S {}; //~ ERROR `S` is ambiguous
                         // Then we re-fetch `m1::*` because non-glob `m1::S` materializes from derive,
}

Version information

rustc 1.96.0-nightly (212b0d480 2026-03-24)
binary: rustc
commit-hash: 212b0d480f337082bbe1132d2b62be20e7e61f8a
commit-date: 2026-03-24
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/212b0d480f337082bbe1132d2b62be20e7e61f8a/compiler/rustc_resolve/src/imports.rs#L1234-L1246

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error: expected identifier, found keyword `pub`
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:5
   |
17 |     pub struct S {}
   |     ^^^ expected identifier, found keyword

error: expected identifier, found keyword `struct`
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:9
   |
17 |     pub struct S {}
   |         ^^^^^^ expected identifier, found keyword

error: expected one of `,`, `::`, `as`, or `}`, found keyword `struct`
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:9
   |
17 |     pub struct S {}
   |        -^^^^^^ expected one of `,`, `::`, `as`, or `}`
   |        |
   |        help: missing `,`

error: expected one of `,`, `::`, `as`, or `}`, found `S`
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:16
   |
17 |     pub struct S {}
   |               -^ expected one of `,`, `::`, `as`, or `}`
   |               |
   |               help: missing `,`

error: expected one of `,`, `::`, `as`, or `}`, found `{`
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:18
   |
17 |     pub struct S {}
   |                 -^ expected one of `,`, `::`, `as`, or `}`
   |                 |
   |                 help: missing `,`

error: internal compiler error: /rustc-dev/212b0d480f337082bbe1132d2b62be20e7e61f8a/compiler/rustc_resolve/src/imports.rs:1240:33: inconsistent resolution for an import
  --> /tmp/icemaker_global_tempdir.OSuV6MRQ4VtL/rustc_testrunner_tmpdir_reporting.M8DISotgagEw/mvce.rs:17:16
   |
17 |     pub struct S {}
   |                ^


thread 'rustc' (2847223) panicked at /rustc-dev/212b0d480f337082bbe1132d2b62be20e7e61f8a/compiler/rustc_resolve/src/imports.rs:1240:33:
Box<dyn Any>
stack backtrace:
   0:     0x7f44fc57f4fb - <<std[ea4077504e0ffae5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9903332b54e895af]::fmt::Display>::fmt
   1:     0x7f44fcc2f608 - core[9903332b54e895af]::fmt::write
   2:     0x7f44fc596506 - <std[ea4077504e0ffae5]::sys::stdio::unix::Stderr as std[ea4077504e0ffae5]::io::Write>::write_fmt
   3:     0x7f44fc555508 - std[ea4077504e0ffae5]::panicking::default_hook::{closure#0}
   4:     0x7f44fc572903 - std[ea4077504e0ffae5]::panicking::default_hook
   5:     0x7f44fb578bcc - std[ea4077504e0ffae5]::panicking::update_hook::<alloc[50c02619db1397b2]::boxed::Box<rustc_driver_impl[caf990db37bd39f4]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f44fc572be2 - std[ea4077504e0ffae5]::panicking::panic_with_hook
   7:     0x7f44fb5a8231 - std[ea4077504e0ffae5]::panicking::begin_panic::<rustc_errors[db30cdc29f09d00]::ExplicitBug>::{closure#0}
   8:     0x7f44fb5a0f16 - std[ea4077504e0ffae5]::sys::backtrace::__rust_end_short_backtrace::<std[ea4077504e0ffae5]::panicking::begin_panic<rustc_errors[db30cdc29f09d00]::ExplicitBug>::{closure#0}, !>
   9:     0x7f44fb5a0c7b - std[ea4077504e0ffae5]::panicking::begin_panic::<rustc_errors[db30cdc29f09d00]::ExplicitBug>
  10:     0x7f44fb5b3871 - <rustc_errors[db30cdc29f09d00]::diagnostic::BugAbort as rustc_errors[db30cdc29f09d00]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f44fbb6971c - <rustc_errors[db30cdc29f09d00]::DiagCtxtHandle>::span_bug::<rustc_span[a1dfc738e0f2d96f]::span_encoding::Span, alloc[50c02619db1397b2]::string::String>
  12:     0x7f44fbb91746 - rustc_middle[74264659555fab5]::util::bug::opt_span_bug_fmt::<rustc_span[a1dfc738e0f2d96f]::span_encoding::Span>::{closure#0}
  13:     0x7f44fbb918f2 - rustc_middle[74264659555fab5]::ty::context::tls::with_opt::<rustc_middle[74264659555fab5]::util::bug::opt_span_bug_fmt<rustc_span[a1dfc738e0f2d96f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f44fbb81ecb - rustc_middle[74264659555fab5]::ty::context::tls::with_context_opt::<rustc_middle[74264659555fab5]::ty::context::tls::with_opt<rustc_middle[74264659555fab5]::util::bug::opt_span_bug_fmt<rustc_span[a1dfc738e0f2d96f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f44f9da00e8 - rustc_middle[74264659555fab5]::util::bug::span_bug_fmt::<rustc_span[a1dfc738e0f2d96f]::span_encoding::Span>
  16:     0x7f44fd151bc9 - <rustc_resolve[4858795a5514e6eb]::Resolver>::finalize_import::{closure#2}
  17:     0x7f44fd149776 - <rustc_resolve[4858795a5514e6eb]::Resolver>::resolve_crate::{closure#0}
  18:     0x7f44fd144e07 - <rustc_resolve[4858795a5514e6eb]::Resolver>::resolve_crate
  19:     0x7f44fd12bb88 - rustc_interface[64e4eefc34cc1822]::passes::configure_and_expand
  20:     0x7f44fd8f7752 - rustc_interface[64e4eefc34cc1822]::passes::resolver_for_lowering_raw
  21:     0x7f44fd8f74cd - rustc_query_impl[8681e81019ae3337]::query_impl::resolver_for_lowering_raw::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f44fde0e1a9 - rustc_query_impl[8681e81019ae3337]::execution::try_execute_query::<rustc_middle[74264659555fab5]::query::caches::SingleCache<rustc_middle[74264659555fab5]::query::erase::ErasedData<[u8; 16usize]>>, false>
  23:     0x7f44fde0dd0e - rustc_query_impl[8681e81019ae3337]::query_impl::resolver_for_lowering_raw::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f44fde326be - rustc_interface[64e4eefc34cc1822]::interface::run_compiler::<(), rustc_driver_impl[caf990db37bd39f4]::run_compiler::{closure#0}>::{closure#1}
  25:     0x7f44fddfb87e - std[ea4077504e0ffae5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[64e4eefc34cc1822]::util::run_in_thread_with_globals<rustc_interface[64e4eefc34cc1822]::util::run_in_thread_pool_with_globals<rustc_interface[64e4eefc34cc1822]::interface::run_compiler<(), rustc_driver_impl[caf990db37bd39f4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7f44fddfc120 - <std[ea4077504e0ffae5]::thread::lifecycle::spawn_unchecked<rustc_interface[64e4eefc34cc1822]::util::run_in_thread_with_globals<rustc_interface[64e4eefc34cc1822]::util::run_in_thread_pool_with_globals<rustc_interface[64e4eefc34cc1822]::interface::run_compiler<(), rustc_driver_impl[caf990db37bd39f4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9903332b54e895af]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f44fddfcfac - <std[ea4077504e0ffae5]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7f44f78a597a - <unknown>
  29:     0x7f44f79292bc - <unknown>
  30:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.96.0-nightly (212b0d480 2026-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 6 previous errors


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.