Skip to content

ICE inconsistent resolution for an import #149821

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
mod m {
    use crate::*;
    use core;
}
macro_rules! define_other_core {
    () => {
        extern crate std as core;
    };
}
define_other_core! {}

original:

mod m {
    use core;
    use crate::*;
}
macro_rules! define_other_core {
    () => {
        extern crate std as core;
         }
}
define_other_core!{}

Version information

rustc 1.94.0-nightly (c61a3a44d 2025-12-09)
binary: rustc
commit-hash: c61a3a44d1a5bee35914cada6c788a05e0808f5b
commit-date: 2025-12-09
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5

Possibly related line of code:

this.dcx()
.span_delayed_bug(import.span, "some error happened for an import");
return;
}
if let Some(initial_res) = initial_res {
if res != initial_res {
span_bug!(import.span, "inconsistent resolution for an import");
}
} else if this.privacy_errors.is_empty() {
this.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.iqvP99JQGbyv/rustc_testrunner_tmpdir_reporting.G71YLUvIqo8J/mvce.rs:7:9
   |
 7 |         extern crate std as core;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
...
10 | define_other_core! {}
   | --------------------- in this macro invocation
   |
   = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: compiler/rustc_resolve/src/imports.rs:1174:33: inconsistent resolution for an import
 --> /tmp/icemaker_global_tempdir.iqvP99JQGbyv/rustc_testrunner_tmpdir_reporting.G71YLUvIqo8J/mvce.rs:3:9
  |
3 |     use core;
  |         ^^^^


thread 'rustc' (474302) panicked at compiler/rustc_resolve/src/imports.rs:1174:33:
Box<dyn Any>
stack backtrace:
   0:     0x7f7801892133 - <<std[4e041eb9831d95d2]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f9b0cf5fccb69ea1]::fmt::Display>::fmt
   1:     0x7f78020106c8 - core[f9b0cf5fccb69ea1]::fmt::write
   2:     0x7f78018a8846 - <std[4e041eb9831d95d2]::sys::stdio::unix::Stderr as std[4e041eb9831d95d2]::io::Write>::write_fmt
   3:     0x7f78018688f8 - std[4e041eb9831d95d2]::panicking::default_hook::{closure#0}
   4:     0x7f7801886003 - std[4e041eb9831d95d2]::panicking::default_hook
   5:     0x7f78008e0e37 - std[4e041eb9831d95d2]::panicking::update_hook::<alloc[10595c53490534ae]::boxed::Box<rustc_driver_impl[d6ef0231697d3f85]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f78018862e2 - std[4e041eb9831d95d2]::panicking::panic_with_hook
   7:     0x7f780091d5d1 - std[4e041eb9831d95d2]::panicking::begin_panic::<rustc_errors[cf5a7345d3a55426]::ExplicitBug>::{closure#0}
   8:     0x7f780090d986 - std[4e041eb9831d95d2]::sys::backtrace::__rust_end_short_backtrace::<std[4e041eb9831d95d2]::panicking::begin_panic<rustc_errors[cf5a7345d3a55426]::ExplicitBug>::{closure#0}, !>
   9:     0x7f780090b16a - std[4e041eb9831d95d2]::panicking::begin_panic::<rustc_errors[cf5a7345d3a55426]::ExplicitBug>
  10:     0x7f780093ac91 - <rustc_errors[cf5a7345d3a55426]::diagnostic::BugAbort as rustc_errors[cf5a7345d3a55426]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f7800e8467c - <rustc_errors[cf5a7345d3a55426]::DiagCtxtHandle>::span_bug::<rustc_span[757017cdd8c0ae22]::span_encoding::Span, alloc[10595c53490534ae]::string::String>
  12:     0x7f7800ea56c6 - rustc_middle[858d3a7a7a03c869]::util::bug::opt_span_bug_fmt::<rustc_span[757017cdd8c0ae22]::span_encoding::Span>::{closure#0}
  13:     0x7f7800ea5872 - rustc_middle[858d3a7a7a03c869]::ty::context::tls::with_opt::<rustc_middle[858d3a7a7a03c869]::util::bug::opt_span_bug_fmt<rustc_span[757017cdd8c0ae22]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f7800e96b4b - rustc_middle[858d3a7a7a03c869]::ty::context::tls::with_context_opt::<rustc_middle[858d3a7a7a03c869]::ty::context::tls::with_opt<rustc_middle[858d3a7a7a03c869]::util::bug::opt_span_bug_fmt<rustc_span[757017cdd8c0ae22]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f77ff4a2c08 - rustc_middle[858d3a7a7a03c869]::util::bug::span_bug_fmt::<rustc_span[757017cdd8c0ae22]::span_encoding::Span>
  16:     0x7f7802e5bb89 - <rustc_resolve[3df6e396ebb8f70f]::Resolver>::finalize_import::{closure#2}
  17:     0x7f7802e538c0 - <rustc_resolve[3df6e396ebb8f70f]::Resolver>::resolve_crate::{closure#0}
  18:     0x7f7802e499bf - <rustc_resolve[3df6e396ebb8f70f]::Resolver>::resolve_crate
  19:     0x7f7802988ae9 - rustc_interface[4a8bddddb5d81cd1]::passes::configure_and_expand
  20:     0x7f78031af698 - rustc_interface[4a8bddddb5d81cd1]::passes::resolver_for_lowering_raw
  21:     0x7f78031af40d - rustc_query_impl[5d540f69866fab08]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d540f69866fab08]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[858d3a7a7a03c869]::query::erase::Erased<[u8; 16usize]>>
  22:     0x7f78031af3e7 - <rustc_query_impl[5d540f69866fab08]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[f9b0cf5fccb69ea1]::ops::function::FnOnce<(rustc_middle[858d3a7a7a03c869]::ty::context::TyCtxt, ())>>::call_once
  23:     0x7f780317631f - rustc_query_system[874ff6747642e62c]::query::plumbing::try_execute_query::<rustc_query_impl[5d540f69866fab08]::DynamicConfig<rustc_query_system[874ff6747642e62c]::query::caches::SingleCache<rustc_middle[858d3a7a7a03c869]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[5d540f69866fab08]::plumbing::QueryCtxt, false>
  24:     0x7f7803175e80 - rustc_query_impl[5d540f69866fab08]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f78033194f7 - <rustc_interface[4a8bddddb5d81cd1]::passes::create_and_enter_global_ctxt<core[f9b0cf5fccb69ea1]::option::Option<rustc_interface[4a8bddddb5d81cd1]::queries::Linker>, rustc_driver_impl[d6ef0231697d3f85]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[f9b0cf5fccb69ea1]::ops::function::FnOnce<(&rustc_session[a5a2d75711ca37ea]::session::Session, rustc_middle[858d3a7a7a03c869]::ty::context::CurrentGcx, alloc[10595c53490534ae]::sync::Arc<rustc_data_structures[2f76b7e71d86dee2]::jobserver::Proxy>, &std[4e041eb9831d95d2]::sync::once_lock::OnceLock<rustc_middle[858d3a7a7a03c869]::ty::context::GlobalCtxt>, &rustc_data_structures[2f76b7e71d86dee2]::sync::worker_local::WorkerLocal<rustc_middle[858d3a7a7a03c869]::arena::Arena>, &rustc_data_structures[2f76b7e71d86dee2]::sync::worker_local::WorkerLocal<rustc_hir[f601393c59240e29]::Arena>, rustc_driver_impl[d6ef0231697d3f85]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  26:     0x7f78031bf945 - rustc_interface[4a8bddddb5d81cd1]::interface::run_compiler::<(), rustc_driver_impl[d6ef0231697d3f85]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7f78031291ca - std[4e041eb9831d95d2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4a8bddddb5d81cd1]::util::run_in_thread_with_globals<rustc_interface[4a8bddddb5d81cd1]::util::run_in_thread_pool_with_globals<rustc_interface[4a8bddddb5d81cd1]::interface::run_compiler<(), rustc_driver_impl[d6ef0231697d3f85]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7f7803128f9d - <std[4e041eb9831d95d2]::thread::lifecycle::spawn_unchecked<rustc_interface[4a8bddddb5d81cd1]::util::run_in_thread_with_globals<rustc_interface[4a8bddddb5d81cd1]::util::run_in_thread_pool_with_globals<rustc_interface[4a8bddddb5d81cd1]::interface::run_compiler<(), rustc_driver_impl[d6ef0231697d3f85]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f9b0cf5fccb69ea1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7f7803127378 - <std[4e041eb9831d95d2]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7f77fca969cb - <unknown>
  31:     0x7f77fcb1aa0c - <unknown>
  32:                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 (c61a3a44d 2025-12-09) 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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions