Skip to content

ICE: inconsistent resolution for an import #151213

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
#[attr]
extern crate core as std;
mod inner {
    use crate::*;
    use std::str;
}

original:

#[attr]
extern crate core as std;
mod inner {
    use crate::*;
    use std::str;
}

fn main() {}

Version information

rustc 1.94.0-nightly (c40c51f9f 2026-01-16)
binary: rustc
commit-hash: c40c51f9fdfa90b9c91c1601ec1442225c6b5c36
commit-date: 2026-01-16
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

let module = match path_res {
PathResult::Module(module) => {
// Consistency checks, analogous to `finalize_macro_resolutions`.
if let Some(initial_module) = import.imported_module.get() {
if module != initial_module && no_ambiguity {
span_bug!(import.span, "inconsistent resolution for an import");
}
} else if self.privacy_errors.is_empty() {
self.dcx()
.create_err(CannotDetermineImportResolution { span: import.span })
.emit();
}

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

Program output

error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
 --> /tmp/icemaker_global_tempdir.hfnno3PHhNdh/rustc_testrunner_tmpdir_reporting.C97rsuOxrjHi/mvce.rs:2:1
  |
2 | extern crate core as std;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: /rustc-dev/c40c51f9fdfa90b9c91c1601ec1442225c6b5c36/compiler/rustc_resolve/src/imports.rs:993:25: inconsistent resolution for an import
 --> /tmp/icemaker_global_tempdir.hfnno3PHhNdh/rustc_testrunner_tmpdir_reporting.C97rsuOxrjHi/mvce.rs:5:9
  |
5 |     use std::str;
  |         ^^^^^^^^


thread 'rustc' (426846) panicked at /rustc-dev/c40c51f9fdfa90b9c91c1601ec1442225c6b5c36/compiler/rustc_resolve/src/imports.rs:993:25:
Box<dyn Any>
stack backtrace:
   0:     0x7f3a5e240603 - <<std[f622e66a55618eae]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[be3feee406a90aeb]::fmt::Display>::fmt
   1:     0x7f3a5e80e248 - core[be3feee406a90aeb]::fmt::write
   2:     0x7f3a5e256ff6 - <std[f622e66a55618eae]::sys::stdio::unix::Stderr as std[f622e66a55618eae]::io::Write>::write_fmt
   3:     0x7f3a5e216678 - std[f622e66a55618eae]::panicking::default_hook::{closure#0}
   4:     0x7f3a5e233d33 - std[f622e66a55618eae]::panicking::default_hook
   5:     0x7f3a5d21654a - std[f622e66a55618eae]::panicking::update_hook::<alloc[8b71d3ac274d215d]::boxed::Box<rustc_driver_impl[a0f67e3dee385421]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f3a5e234012 - std[f622e66a55618eae]::panicking::panic_with_hook
   7:     0x7f3a5d253251 - std[f622e66a55618eae]::panicking::begin_panic::<rustc_errors[e28256f605e4d5d1]::ExplicitBug>::{closure#0}
   8:     0x7f3a5d2438b6 - std[f622e66a55618eae]::sys::backtrace::__rust_end_short_backtrace::<std[f622e66a55618eae]::panicking::begin_panic<rustc_errors[e28256f605e4d5d1]::ExplicitBug>::{closure#0}, !>
   9:     0x7f3a5d2434ef - std[f622e66a55618eae]::panicking::begin_panic::<rustc_errors[e28256f605e4d5d1]::ExplicitBug>
  10:     0x7f3a5d270f91 - <rustc_errors[e28256f605e4d5d1]::diagnostic::BugAbort as rustc_errors[e28256f605e4d5d1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f3a5d7fe1cc - <rustc_errors[e28256f605e4d5d1]::DiagCtxtHandle>::span_bug::<rustc_span[d27ca469e4b8b40e]::span_encoding::Span, alloc[8b71d3ac274d215d]::string::String>
  12:     0x7f3a5d820d76 - rustc_middle[78f8af8a8877d77a]::util::bug::opt_span_bug_fmt::<rustc_span[d27ca469e4b8b40e]::span_encoding::Span>::{closure#0}
  13:     0x7f3a5d820f22 - rustc_middle[78f8af8a8877d77a]::ty::context::tls::with_opt::<rustc_middle[78f8af8a8877d77a]::util::bug::opt_span_bug_fmt<rustc_span[d27ca469e4b8b40e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f3a5d81203b - rustc_middle[78f8af8a8877d77a]::ty::context::tls::with_context_opt::<rustc_middle[78f8af8a8877d77a]::ty::context::tls::with_opt<rustc_middle[78f8af8a8877d77a]::util::bug::opt_span_bug_fmt<rustc_span[d27ca469e4b8b40e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f3a5b0810e8 - rustc_middle[78f8af8a8877d77a]::util::bug::span_bug_fmt::<rustc_span[d27ca469e4b8b40e]::span_encoding::Span>
  16:     0x7f3a5eb83890 - <rustc_resolve[9beffee41aaa4225]::Resolver>::resolve_crate::{closure#0}
  17:     0x7f3a5eb7c74d - <rustc_resolve[9beffee41aaa4225]::Resolver>::resolve_crate
  18:     0x7f3a5ef9b2b0 - rustc_interface[6d717de30288940c]::passes::configure_and_expand
  19:     0x7f3a5fac8455 - rustc_interface[6d717de30288940c]::passes::resolver_for_lowering_raw
  20:     0x7f3a5fac81cd - rustc_query_impl[7552aa53f4db63cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7552aa53f4db63cf]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[78f8af8a8877d77a]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7f3a5fac81a7 - <rustc_query_impl[7552aa53f4db63cf]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[be3feee406a90aeb]::ops::function::FnOnce<(rustc_middle[78f8af8a8877d77a]::ty::context::TyCtxt, ())>>::call_once
  22:     0x7f3a5f9edf5f - rustc_query_system[f40d58239e2a6620]::query::plumbing::try_execute_query::<rustc_query_impl[7552aa53f4db63cf]::DynamicConfig<rustc_query_system[f40d58239e2a6620]::query::caches::SingleCache<rustc_middle[78f8af8a8877d77a]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7552aa53f4db63cf]::plumbing::QueryCtxt, false>
  23:     0x7f3a5f9edac4 - rustc_query_impl[7552aa53f4db63cf]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f3a5fbc02b8 - <rustc_interface[6d717de30288940c]::passes::create_and_enter_global_ctxt<core[be3feee406a90aeb]::option::Option<rustc_interface[6d717de30288940c]::queries::Linker>, rustc_driver_impl[a0f67e3dee385421]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[be3feee406a90aeb]::ops::function::FnOnce<(&rustc_session[38436ce9d989dd68]::session::Session, rustc_middle[78f8af8a8877d77a]::ty::context::CurrentGcx, alloc[8b71d3ac274d215d]::sync::Arc<rustc_data_structures[f9d44375c8b6ec42]::jobserver::Proxy>, &std[f622e66a55618eae]::sync::once_lock::OnceLock<rustc_middle[78f8af8a8877d77a]::ty::context::GlobalCtxt>, &rustc_data_structures[f9d44375c8b6ec42]::sync::worker_local::WorkerLocal<rustc_middle[78f8af8a8877d77a]::arena::Arena>, &rustc_data_structures[f9d44375c8b6ec42]::sync::worker_local::WorkerLocal<rustc_hir[7389e80e5507f357]::Arena>, rustc_driver_impl[a0f67e3dee385421]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  25:     0x7f3a5faf4c18 - rustc_interface[6d717de30288940c]::interface::run_compiler::<(), rustc_driver_impl[a0f67e3dee385421]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7f3a5f9ad90e - std[f622e66a55618eae]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6d717de30288940c]::util::run_in_thread_with_globals<rustc_interface[6d717de30288940c]::util::run_in_thread_pool_with_globals<rustc_interface[6d717de30288940c]::interface::run_compiler<(), rustc_driver_impl[a0f67e3dee385421]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7f3a5f9ad6e0 - <std[f622e66a55618eae]::thread::lifecycle::spawn_unchecked<rustc_interface[6d717de30288940c]::util::run_in_thread_with_globals<rustc_interface[6d717de30288940c]::util::run_in_thread_pool_with_globals<rustc_interface[6d717de30288940c]::interface::run_compiler<(), rustc_driver_impl[a0f67e3dee385421]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[be3feee406a90aeb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f3a5f9af4f8 - <std[f622e66a55618eae]::sys::thread::unix::Thread>::new::thread_start
  29:     0x7f3a5929698b - <unknown>
  30:     0x7f3a5931a9cc - <unknown>
  31:                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.94.0-nightly (c40c51f9f 2026-01-16) 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 2 previous errors


Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions