Skip to content

ICE 'compiler/rustc_resolve/src/imports.rs:309:9: 'assertion left == right failed' #150928

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

mod b {
    pub mod http {

        pub struct HeaderMap;
    }

    pub(crate) use self::http::*;
    #[derive(Debug)]
    pub struct HeaderMap;
}

mod a {
    pub use crate::b::*;
}

original:

//@ check-pass

use crate::a::HeaderMap;

mod b {
    pub mod http {
        #[derive(Clone)]
        pub struct HeaderMap;
    }

    pub(crate) use self::http::*;
    #[derive(Debug)]
    pub struct HeaderMap;
}

mod a {
    pub use crate::b::*;
}

fn main() {
    let h: crate::b::HeaderMap = HeaderMap;
}

Version information

rustc 1.94.0-nightly (1b9ae9edd 2026-01-10)
binary: rustc
commit-hash: 1b9ae9eddcbd3b0105a0828e323c6db5f1e6ad0c
commit-date: 2026-01-10
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

&& d1.warn_ambiguity.get() == d2.warn_ambiguity.get()
{
assert_eq!(d1.ambiguity.get(), d2.ambiguity.get());
assert!(!d1.warn_ambiguity.get());
assert_eq!(d1.expansion, d2.expansion);
assert_eq!(d1.span, d2.span);
assert_eq!(d1.vis(), d2.vis());
remove_same_import(d1_next, d2_next)
} else {
(d1, d2)
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output


thread 'rustc' (4097620) panicked at /rustc-dev/1b9ae9eddcbd3b0105a0828e323c6db5f1e6ad0c/compiler/rustc_resolve/src/imports.rs:309:9:
assertion `left == right` failed
  left: Public
 right: Restricted(DefId(0:0 ~ mvce[4475]))
stack backtrace:
   0:     0x7f2fdcc3a273 - <<std[6938aa076b36c5ac]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bccd4b2d6cdb7e20]::fmt::Display>::fmt
   1:     0x7f2fdd20fa08 - core[bccd4b2d6cdb7e20]::fmt::write
   2:     0x7f2fdcc504f6 - <std[6938aa076b36c5ac]::sys::stdio::unix::Stderr as std[6938aa076b36c5ac]::io::Write>::write_fmt
   3:     0x7f2fdcc0fe68 - std[6938aa076b36c5ac]::panicking::default_hook::{closure#0}
   4:     0x7f2fdcc2db03 - std[6938aa076b36c5ac]::panicking::default_hook
   5:     0x7f2fdbc1089a - std[6938aa076b36c5ac]::panicking::update_hook::<alloc[86015bdb52244da1]::boxed::Box<rustc_driver_impl[350e86f741145418]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f2fdcc2dde2 - std[6938aa076b36c5ac]::panicking::panic_with_hook
   7:     0x7f2fdcc0ff28 - std[6938aa076b36c5ac]::panicking::panic_handler::{closure#0}
   8:     0x7f2fdcc06be9 - std[6938aa076b36c5ac]::sys::backtrace::__rust_end_short_backtrace::<std[6938aa076b36c5ac]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f2fdcc119fd - __rustc[3c543be16ed5e038]::rust_begin_unwind
  10:     0x7f2fda027eec - core[bccd4b2d6cdb7e20]::panicking::panic_fmt
  11:     0x7f2fdb59b2e3 - core[bccd4b2d6cdb7e20]::panicking::assert_failed_inner
  12:     0x7f2fdc76b2f6 - core[bccd4b2d6cdb7e20]::panicking::assert_failed::<rustc_middle[11388d43b036737e]::ty::Visibility<rustc_span[a5ddb00b71f5b042]::def_id::DefId>, rustc_middle[11388d43b036737e]::ty::Visibility<rustc_span[a5ddb00b71f5b042]::def_id::DefId>>
  13:     0x7f2fdd23aa4f - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  14:     0x7f2fdd2398cc - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  15:     0x7f2fdd9045fa - <rustc_resolve[51f9131d78059eb1]::build_reduced_graph::BuildReducedGraphVisitor as rustc_ast[85e5d7c876d0cc7f]::visit::Visitor>::visit_item
  16:     0x7f2fdd9105b5 - <rustc_resolve[51f9131d78059eb1]::Resolver as rustc_expand[c61a0465d3b74d74]::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  17:     0x7f2fde830e0e - <rustc_expand[c61a0465d3b74d74]::expand::MacroExpander>::fully_expand_fragment
  18:     0x7f2fde81c052 - <rustc_expand[c61a0465d3b74d74]::expand::MacroExpander>::expand_crate
  19:     0x7f2fdd878474 - rustc_interface[9706804fe87156b4]::passes::configure_and_expand
  20:     0x7f2fde3f2718 - rustc_interface[9706804fe87156b4]::passes::resolver_for_lowering_raw
  21:     0x7f2fde3f248d - rustc_query_impl[283934abf3e4e915]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[283934abf3e4e915]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[11388d43b036737e]::query::erase::Erased<[u8; 16usize]>>
  22:     0x7f2fde3f246b - <rustc_query_impl[283934abf3e4e915]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[bccd4b2d6cdb7e20]::ops::function::FnOnce<(rustc_middle[11388d43b036737e]::ty::context::TyCtxt, ())>>::call_once
  23:     0x7f2fde3ca81f - rustc_query_system[38817e29eb7d5b8b]::query::plumbing::try_execute_query::<rustc_query_impl[283934abf3e4e915]::DynamicConfig<rustc_query_system[38817e29eb7d5b8b]::query::caches::SingleCache<rustc_middle[11388d43b036737e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[283934abf3e4e915]::plumbing::QueryCtxt, false>
  24:     0x7f2fde3ca37c - rustc_query_impl[283934abf3e4e915]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f2fde58917b - <rustc_interface[9706804fe87156b4]::passes::create_and_enter_global_ctxt<core[bccd4b2d6cdb7e20]::option::Option<rustc_interface[9706804fe87156b4]::queries::Linker>, rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[bccd4b2d6cdb7e20]::ops::function::FnOnce<(&rustc_session[f9d61e7a9f67467e]::session::Session, rustc_middle[11388d43b036737e]::ty::context::CurrentGcx, alloc[86015bdb52244da1]::sync::Arc<rustc_data_structures[4857a5955d067035]::jobserver::Proxy>, &std[6938aa076b36c5ac]::sync::once_lock::OnceLock<rustc_middle[11388d43b036737e]::ty::context::GlobalCtxt>, &rustc_data_structures[4857a5955d067035]::sync::worker_local::WorkerLocal<rustc_middle[11388d43b036737e]::arena::Arena>, &rustc_data_structures[4857a5955d067035]::sync::worker_local::WorkerLocal<rustc_hir[bde87669acea4e53]::Arena>, rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  26:     0x7f2fde47f698 - rustc_interface[9706804fe87156b4]::interface::run_compiler::<(), rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7f2fde3966fa - std[6938aa076b36c5ac]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9706804fe87156b4]::util::run_in_thread_with_globals<rustc_interface[9706804fe87156b4]::util::run_in_thread_pool_with_globals<rustc_interface[9706804fe87156b4]::interface::run_compiler<(), rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7f2fde3964be - <std[6938aa076b36c5ac]::thread::lifecycle::spawn_unchecked<rustc_interface[9706804fe87156b4]::util::run_in_thread_with_globals<rustc_interface[9706804fe87156b4]::util::run_in_thread_pool_with_globals<rustc_interface[9706804fe87156b4]::interface::run_compiler<(), rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bccd4b2d6cdb7e20]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7f2fde398282 - <std[6938aa076b36c5ac]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7f2fd7c9698b - <unknown>
  31:     0x7f2fd7d1a9cc - <unknown>
  32:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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 (1b9ae9edd 2026-01-10) 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

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) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions