Skip to content

ICE in resolve #150711

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
mod foo {

    macro f() {}

    pub macro m() {
        use f;
        f!();
    }
}

fn main() {
    foo::m!();
}

original:

//@ edition:2018

#![feature(decl_macro)]

mod foo {
    fn f() {}
    macro f() {}

    pub macro m() {
        use f as f; //~ ERROR `f` is private, and cannot be re-exported
        f!();
    }
}

fn main() {
    foo::m!();
}

Version information

rustc 1.94.0-nightly (e29fcf45e 2026-01-04)
binary: rustc
commit-hash: e29fcf45e4ae686d77b490bf07320f0d3a2cf35f
commit-date: 2026-01-04
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

}
Err(ControlFlow::Continue(determinacy)) => Err(determinacy),
Err(ControlFlow::Break(Determinacy::Undetermined)) => {
return ControlFlow::Break(Err(Determinacy::determined(force)));
}
// Privacy errors, do not happen during in scope resolution.
Err(ControlFlow::Break(Determinacy::Determined)) => unreachable!(),
}
}
Scope::MacroUsePrelude => match self.macro_use_prelude.get(&ident.name).cloned() {
Some(binding) => Ok(binding),
None => Err(Determinacy::determined(
self.graph_root.unexpanded_invocations.borrow().is_empty(),

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

Program output


thread 'rustc' (4177338) panicked at /rustc-dev/e29fcf45e4ae686d77b490bf07320f0d3a2cf35f/compiler/rustc_resolve/src/ident.rs:597:73:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f6e5e038943 - <<std[eaa43e369792efb9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[4141bff0bf9ca9dd]::fmt::Display>::fmt
   1:     0x7f6e5e60e348 - core[4141bff0bf9ca9dd]::fmt::write
   2:     0x7f6e5e04ebc6 - <std[eaa43e369792efb9]::sys::stdio::unix::Stderr as std[eaa43e369792efb9]::io::Write>::write_fmt
   3:     0x7f6e5e00e778 - std[eaa43e369792efb9]::panicking::default_hook::{closure#0}
   4:     0x7f6e5e02c1d3 - std[eaa43e369792efb9]::panicking::default_hook
   5:     0x7f6e5d010e9a - std[eaa43e369792efb9]::panicking::update_hook::<alloc[83e7320d2ee5a6b1]::boxed::Box<rustc_driver_impl[5af842e777d449e6]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6e5e02c4b2 - std[eaa43e369792efb9]::panicking::panic_with_hook
   7:     0x7f6e5e00e86a - std[eaa43e369792efb9]::panicking::panic_handler::{closure#0}
   8:     0x7f6e5e005589 - std[eaa43e369792efb9]::sys::backtrace::__rust_end_short_backtrace::<std[eaa43e369792efb9]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6e5e01030d - __rustc[6ead4e718bd245fd]::rust_begin_unwind
  10:     0x7f6e5ad7eeec - core[4141bff0bf9ca9dd]::panicking::panic_fmt
  11:     0x7f6e5a8b0b72 - core[4141bff0bf9ca9dd]::panicking::panic
  12:     0x7f6e5f4d2dce - <rustc_resolve[67b6ebad77523df8]::Resolver>::resolve_ident_in_scope_set
  13:     0x7f6e5e94b381 - <rustc_resolve[67b6ebad77523df8]::Resolver as rustc_expand[210b8681d377d6a8]::base::ResolverExpand>::resolve_macro_invocation
  14:     0x7f6e5fbff395 - <rustc_expand[210b8681d377d6a8]::expand::MacroExpander>::fully_expand_fragment
  15:     0x7f6e5fbfe452 - <rustc_expand[210b8681d377d6a8]::expand::MacroExpander>::expand_crate
  16:     0x7f6e5ecf3973 - rustc_interface[eaf9095e0de5b742]::passes::configure_and_expand
  17:     0x7f6e5f814818 - rustc_interface[eaf9095e0de5b742]::passes::resolver_for_lowering_raw
  18:     0x7f6e5f81458d - rustc_query_impl[1b717c0605046cd0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1b717c0605046cd0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 16usize]>>
  19:     0x7f6e5f81456f - <rustc_query_impl[1b717c0605046cd0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[4141bff0bf9ca9dd]::ops::function::FnOnce<(rustc_middle[829e5443847148d]::ty::context::TyCtxt, ())>>::call_once
  20:     0x7f6e5f7e4d1f - rustc_query_system[5c35911b3dd767e9]::query::plumbing::try_execute_query::<rustc_query_impl[1b717c0605046cd0]::DynamicConfig<rustc_query_system[5c35911b3dd767e9]::query::caches::SingleCache<rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[1b717c0605046cd0]::plumbing::QueryCtxt, false>
  21:     0x7f6e5f7e487c - rustc_query_impl[1b717c0605046cd0]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7f6e5f995bf8 - <rustc_interface[eaf9095e0de5b742]::passes::create_and_enter_global_ctxt<core[4141bff0bf9ca9dd]::option::Option<rustc_interface[eaf9095e0de5b742]::queries::Linker>, rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[4141bff0bf9ca9dd]::ops::function::FnOnce<(&rustc_session[ea1eec3ed26e42d5]::session::Session, rustc_middle[829e5443847148d]::ty::context::CurrentGcx, alloc[83e7320d2ee5a6b1]::sync::Arc<rustc_data_structures[4e9b1f6e439fd3ef]::jobserver::Proxy>, &std[eaa43e369792efb9]::sync::once_lock::OnceLock<rustc_middle[829e5443847148d]::ty::context::GlobalCtxt>, &rustc_data_structures[4e9b1f6e439fd3ef]::sync::worker_local::WorkerLocal<rustc_middle[829e5443847148d]::arena::Arena>, &rustc_data_structures[4e9b1f6e439fd3ef]::sync::worker_local::WorkerLocal<rustc_hir[67c6535075053fb5]::Arena>, rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  23:     0x7f6e5f86e398 - rustc_interface[eaf9095e0de5b742]::interface::run_compiler::<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}
  24:     0x7f6e5f6f7e8e - std[eaa43e369792efb9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_with_globals<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_pool_with_globals<rustc_interface[eaf9095e0de5b742]::interface::run_compiler<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x7f6e5f6f7c60 - <std[eaa43e369792efb9]::thread::lifecycle::spawn_unchecked<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_with_globals<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_pool_with_globals<rustc_interface[eaf9095e0de5b742]::interface::run_compiler<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4141bff0bf9ca9dd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f6e5f6f6038 - <std[eaa43e369792efb9]::sys::thread::unix::Thread>::new::thread_start
  27:     0x7f6e5909698b - <unknown>
  28:     0x7f6e5911a9cc - <unknown>
  29:                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 (e29fcf45e 2026-01-04) 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

@rustbot label +F-decl_macro

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-decl_macro`#![feature(decl_macro)]`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