Skip to content

ICE: assertion failed: !deep_decl.is_glob_import() #150927

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

mod openssl {

    pub use self::handwritten::*;

    mod handwritten {
        mod m1 {
            pub struct S {}
        }
        mod m2 {

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

        pub use self::m1::*;
        pub use self::m2::*;
    }
}

pub use openssl::*;

original:

//@ check-pass
// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883

#![warn(ambiguous_glob_imports)]

macro_rules! m {
    () => {
      pub fn id() {}
    };
}

mod openssl {
    pub use self::evp::*;
    //~^ WARNING ambiguous glob re-exports
    pub use self::handwritten::*;

    mod evp {
      m!();
    }

    mod handwritten {
    mod m1 {
        pub struct S {}
    }
    mod m2 {
        // Note this derive, it makes this struct macro-expanded,
        // so it doesn't appear in time to participate in the initial resolution of `use m::S`,
        // only in the later validation pass.
        #[derive(Default)]
        pub struct S {}
    }

    // Create a glob vs glob ambiguity
    pub use self::m1::*;
    pub use self::m2::*;
}
}

pub use openssl::*;

fn main() {
    id();
    //~^ WARNING `id` is ambiguous
    //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}

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:

if deep_decl != glob_decl {
// Some import layers have been removed, need to overwrite.
assert_ne!(old_deep_decl, old_glob_decl);
// FIXME: reenable the asserts when `warn_ambiguity` is removed (#149195).
// assert_ne!(old_deep_decl, deep_decl);
// assert!(old_deep_decl.is_glob_import());
assert!(!deep_decl.is_glob_import());
if glob_decl.is_ambiguity_recursive() {
glob_decl.warn_ambiguity.set_unchecked(true);
}
glob_decl
} else if glob_decl.res() != old_glob_decl.res() {
old_glob_decl.ambiguity.set_unchecked(Some(glob_decl));

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

Program output


thread 'rustc' (4091524) panicked at /rustc-dev/1b9ae9eddcbd3b0105a0828e323c6db5f1e6ad0c/compiler/rustc_resolve/src/imports.rs:378:13:
assertion failed: !deep_decl.is_glob_import()
stack backtrace:
   0:     0x7fb01623a273 - <<std[6938aa076b36c5ac]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bccd4b2d6cdb7e20]::fmt::Display>::fmt
   1:     0x7fb01680fa08 - core[bccd4b2d6cdb7e20]::fmt::write
   2:     0x7fb0162504f6 - <std[6938aa076b36c5ac]::sys::stdio::unix::Stderr as std[6938aa076b36c5ac]::io::Write>::write_fmt
   3:     0x7fb01620fe68 - std[6938aa076b36c5ac]::panicking::default_hook::{closure#0}
   4:     0x7fb01622db03 - std[6938aa076b36c5ac]::panicking::default_hook
   5:     0x7fb01521089a - std[6938aa076b36c5ac]::panicking::update_hook::<alloc[86015bdb52244da1]::boxed::Box<rustc_driver_impl[350e86f741145418]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fb01622dde2 - std[6938aa076b36c5ac]::panicking::panic_with_hook
   7:     0x7fb01620ff5a - std[6938aa076b36c5ac]::panicking::panic_handler::{closure#0}
   8:     0x7fb016206be9 - std[6938aa076b36c5ac]::sys::backtrace::__rust_end_short_backtrace::<std[6938aa076b36c5ac]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fb0162119fd - __rustc[3c543be16ed5e038]::rust_begin_unwind
  10:     0x7fb013627eec - core[bccd4b2d6cdb7e20]::panicking::panic_fmt
  11:     0x7fb012aa7672 - core[bccd4b2d6cdb7e20]::panicking::panic
  12:     0x7fb01683a7e1 - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  13:     0x7fb0168398cc - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  14:     0x7fb0168398cc - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  15:     0x7fb0168398cc - <rustc_resolve[51f9131d78059eb1]::Resolver>::try_plant_decl_into_local_module
  16:     0x7fb016f045fa - <rustc_resolve[51f9131d78059eb1]::build_reduced_graph::BuildReducedGraphVisitor as rustc_ast[85e5d7c876d0cc7f]::visit::Visitor>::visit_item
  17:     0x7fb016f105b5 - <rustc_resolve[51f9131d78059eb1]::Resolver as rustc_expand[c61a0465d3b74d74]::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  18:     0x7fb017e30e0e - <rustc_expand[c61a0465d3b74d74]::expand::MacroExpander>::fully_expand_fragment
  19:     0x7fb017e1c052 - <rustc_expand[c61a0465d3b74d74]::expand::MacroExpander>::expand_crate
  20:     0x7fb016e78474 - rustc_interface[9706804fe87156b4]::passes::configure_and_expand
  21:     0x7fb0179f2718 - rustc_interface[9706804fe87156b4]::passes::resolver_for_lowering_raw
  22:     0x7fb0179f248d - 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]>>
  23:     0x7fb0179f246b - <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
  24:     0x7fb0179ca81f - 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>
  25:     0x7fb0179ca37c - rustc_query_impl[283934abf3e4e915]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7fb017b8917b - <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}
  27:     0x7fb017a7f698 - rustc_interface[9706804fe87156b4]::interface::run_compiler::<(), rustc_driver_impl[350e86f741145418]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7fb0179966fa - 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}, ()>
  29:     0x7fb0179964be - <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}
  30:     0x7fb017998282 - <std[6938aa076b36c5ac]::sys::thread::unix::Thread>::new::thread_start
  31:     0x7fb01129698b - <unknown>
  32:     0x7fb01131a9cc - <unknown>
  33:                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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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