Skip to content

ICE: inconsistent resolution for an import #153842

@Anonymous1-design

Description

@Anonymous1-design

I tried this code:

mod a {
    pub(crate) trait STrait {}
    pub(crate) use crate::s::STrait as s;
}

mod b {
    pub mod s {
        pub trait STrait {}
    }
}

use self::b::*;
use self::a::s;

fn main() {}

Meta

rustc --version --verbose:

rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: x86_64-unknown-linux-gnu
release: 1.94.0
LLVM version: 21.1.8
Backtrace

error: internal compiler error: /rustc-dev/4a4ef493e3a1488c6e321570238084b38948f6db/compiler/rustc_resolve/src/imports.rs:997:25: inconsistent resolution for an import
 --> bug.rs:3:20
  |
3 |     pub(crate) use crate::s::STrait as s;
  |                    ^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (501379) panicked at /rustc-dev/4a4ef493e3a1488c6e321570238084b38948f6db/compiler/rustc_resolve/src/imports.rs:997:25:
Box<dyn Any>
stack backtrace:
   0:     0x7f0e745bb603 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h93773fc827e3113d
   1:     0x7f0e74b6d488 - core::fmt::write::hed7b5c73d82ecb7c
   2:     0x7f0e76057142 - std::io::Write::write_fmt::h6f0185aecf0ed75f
   3:     0x7f0e74588b65 - std::panicking::default_hook::{{closure}}::h2be84df4f189ae36
   4:     0x7f0e74588993 - std::panicking::default_hook::hf0ea8939246f43a9
   5:     0x7f0e7356faea - std[765ed69a96918746]::panicking::update_hook::<alloc[7a43974b6697a11c]::boxed::Box<rustc_driver_impl[252c3262fddb99f]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0e74588e92 - std::panicking::panic_with_hook::hb4bd9ac1123582a0
   7:     0x7f0e735ace01 - std[765ed69a96918746]::panicking::begin_panic::<rustc_errors[45351c624685c6c4]::ExplicitBug>::{closure#0}
   8:     0x7f0e7359d226 - std[765ed69a96918746]::sys::backtrace::__rust_end_short_backtrace::<std[765ed69a96918746]::panicking::begin_panic<rustc_errors[45351c624685c6c4]::ExplicitBug>::{closure#0}, !>
   9:     0x7f0e7359cebf - std[765ed69a96918746]::panicking::begin_panic::<rustc_errors[45351c624685c6c4]::ExplicitBug>
  10:     0x7f0e735cab41 - <rustc_errors[45351c624685c6c4]::diagnostic::BugAbort as rustc_errors[45351c624685c6c4]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f0e73b5d6bc - <rustc_errors[45351c624685c6c4]::DiagCtxtHandle>::span_bug::<rustc_span[56e001752d96add4]::span_encoding::Span, alloc[7a43974b6697a11c]::string::String>
  12:     0x7f0e73b80246 - rustc_middle[f9db403ed88df217]::util::bug::opt_span_bug_fmt::<rustc_span[56e001752d96add4]::span_encoding::Span>::{closure#0}
  13:     0x7f0e73b803f2 - rustc_middle[f9db403ed88df217]::ty::context::tls::with_opt::<rustc_middle[f9db403ed88df217]::util::bug::opt_span_bug_fmt<rustc_span[56e001752d96add4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f0e73b71a1b - rustc_middle[f9db403ed88df217]::ty::context::tls::with_context_opt::<rustc_middle[f9db403ed88df217]::ty::context::tls::with_opt<rustc_middle[f9db403ed88df217]::util::bug::opt_span_bug_fmt<rustc_span[56e001752d96add4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f0e71bcf498 - rustc_middle[f9db403ed88df217]::util::bug::span_bug_fmt::<rustc_span[56e001752d96add4]::span_encoding::Span>
  16:     0x7f0e75256690 - <rustc_resolve[d253235bfa1f2b45]::Resolver>::resolve_crate::{closure#0}
  17:     0x7f0e7524f54d - <rustc_resolve[d253235bfa1f2b45]::Resolver>::resolve_crate
  18:     0x7f0e75322eb0 - rustc_interface[c6a26c9f392246cf]::passes::configure_and_expand
  19:     0x7f0e75d61895 - rustc_interface[c6a26c9f392246cf]::passes::resolver_for_lowering_raw
  20:     0x7f0e75d6160d - rustc_query_impl[d9e05d596e7fb2e4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d9e05d596e7fb2e4]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f9db403ed88df217]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7f0e75d615e7 - <rustc_query_impl[d9e05d596e7fb2e4]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[32850a7867c2faaf]::ops::function::FnOnce<(rustc_middle[f9db403ed88df217]::ty::context::TyCtxt, ())>>::call_once
  22:     0x7f0e75d60cdc - rustc_query_system[5bf9c757c7651d1c]::query::plumbing::try_execute_query::<rustc_query_impl[d9e05d596e7fb2e4]::DynamicConfig<rustc_query_system[5bf9c757c7651d1c]::query::caches::SingleCache<rustc_middle[f9db403ed88df217]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[d9e05d596e7fb2e4]::plumbing::QueryCtxt, false>
  23:     0x7f0e75d60846 - rustc_query_impl[d9e05d596e7fb2e4]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f0e75eef038 - <rustc_interface[c6a26c9f392246cf]::passes::create_and_enter_global_ctxt<core[32850a7867c2faaf]::option::Option<rustc_interface[c6a26c9f392246cf]::queries::Linker>, rustc_driver_impl[252c3262fddb99f]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[32850a7867c2faaf]::ops::function::FnOnce<(&rustc_session[eab982bd009dcc5a]::session::Session, rustc_middle[f9db403ed88df217]::ty::context::CurrentGcx, alloc[7a43974b6697a11c]::sync::Arc<rustc_data_structures[721127a3047d6cb5]::jobserver::Proxy>, &std[765ed69a96918746]::sync::once_lock::OnceLock<rustc_middle[f9db403ed88df217]::ty::context::GlobalCtxt>, &rustc_data_structures[721127a3047d6cb5]::sync::worker_local::WorkerLocal<rustc_middle[f9db403ed88df217]::arena::Arena>, &rustc_data_structures[721127a3047d6cb5]::sync::worker_local::WorkerLocal<rustc_hir[41466cadac454391]::Arena>, rustc_driver_impl[252c3262fddb99f]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  25:     0x7f0e75ce00b4 - rustc_interface[c6a26c9f392246cf]::interface::run_compiler::<(), rustc_driver_impl[252c3262fddb99f]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7f0e75c88b7a - std[765ed69a96918746]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c6a26c9f392246cf]::util::run_in_thread_with_globals<rustc_interface[c6a26c9f392246cf]::util::run_in_thread_pool_with_globals<rustc_interface[c6a26c9f392246cf]::interface::run_compiler<(), rustc_driver_impl[252c3262fddb99f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7f0e75c8893e - <std[765ed69a96918746]::thread::lifecycle::spawn_unchecked<rustc_interface[c6a26c9f392246cf]::util::run_in_thread_with_globals<rustc_interface[c6a26c9f392246cf]::util::run_in_thread_pool_with_globals<rustc_interface[c6a26c9f392246cf]::interface::run_compiler<(), rustc_driver_impl[252c3262fddb99f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[32850a7867c2faaf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f0e75c8a702 - std::sys::thread::unix::Thread::new::thread_start::h982f9ea829d1b5fb
  29:     0x7f0e6f906609 - start_thread
                               at /build/glibc-B3wQXB/glibc-2.31/nptl/pthread_create.c:477:8
  30:     0x7f0e6f82b353 - clone
                               at /build/glibc-B3wQXB/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
  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: rustc 1.94.0 (4a4ef493e 2026-03-02) running on x86_64-unknown-linux-gnu

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

Metadata

Metadata

Assignees

Labels

C-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