Skip to content

ICE: eii: fn / macro rules None in find_attr() #149981

@matthiaskrgr

Description

@matthiaskrgr

snippet:

macro_rules! foo_impl {}
#[eii]
fn foo_impl() {}

Version information

rustc 1.94.0-nightly (3f4dc1e02 2025-12-14)
binary: rustc
commit-hash: 3f4dc1e02d759aa3c3807d4efc1f7f6e293536a5
commit-date: 2025-12-14
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5

Possibly related line of code:

for i in
find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiImpls(e) => e).into_iter().flatten()
{
eiis.entry(i.eii_macro)
.or_insert_with(|| {
// find the decl for this one if it wasn't in yet (maybe it's from the local crate? not very useful but not illegal)
(find_attr!(tcx.get_all_attrs(i.eii_macro), AttributeKind::EiiExternTarget(d) => *d).unwrap(), Default::default())
}).1.insert(id.into(), *i);
}
// if we find a new declaration, add it to the list without a known implementation
if let Some(decl) =
find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiExternTarget(d) => *d)

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

Program output

error: macros must contain at least one rule
 --> /tmp/icemaker_global_tempdir.H7kAaxdihhDG/rustc_testrunner_tmpdir_reporting.S9gL24J8ZiLI/mvce.rs:1:1
  |
1 | macro_rules! foo_impl {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature `extern_item_impls`
 --> /tmp/icemaker_global_tempdir.H7kAaxdihhDG/rustc_testrunner_tmpdir_reporting.S9gL24J8ZiLI/mvce.rs:2:3
  |
2 | #[eii]
  |   ^^^
  |
  = note: see issue #125418 <https://github.com/rust-lang/rust/issues/125418> for more information
  = help: add `#![feature(extern_item_impls)]` to the crate attributes to enable
  = note: this compiler was built on 2025-12-14; consider upgrading it if it is out of date

warning: unused macro definition: `foo_impl`
 --> /tmp/icemaker_global_tempdir.H7kAaxdihhDG/rustc_testrunner_tmpdir_reporting.S9gL24J8ZiLI/mvce.rs:1:14
  |
1 | macro_rules! foo_impl {}
  |              ^^^^^^^^
  |
  = note: `#[warn(unused_macros)]` (part of `#[warn(unused)]`) on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.H7kAaxdihhDG/rustc_testrunner_tmpdir_reporting.S9gL24J8ZiLI/mvce.rs:3:17
  |
3 | fn foo_impl() {}
  |                 ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.H7kAaxdihhDG/rustc_testrunner_tmpdir_reporting.S9gL24J8ZiLI/mvce.rs`


thread 'rustc' (3711046) panicked at compiler/rustc_metadata/src/eii.rs:34:106:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f791af90173 - <<std[e49fa185a119b89b]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[17865207963548b5]::fmt::Display>::fmt
   1:     0x7f791b610648 - core[17865207963548b5]::fmt::write
   2:     0x7f791afa67c6 - <std[e49fa185a119b89b]::sys::stdio::unix::Stderr as std[e49fa185a119b89b]::io::Write>::write_fmt
   3:     0x7f791af66938 - std[e49fa185a119b89b]::panicking::default_hook::{closure#0}
   4:     0x7f791af84043 - std[e49fa185a119b89b]::panicking::default_hook
   5:     0x7f7919f741d7 - std[e49fa185a119b89b]::panicking::update_hook::<alloc[756b9f94e2773738]::boxed::Box<rustc_driver_impl[e1c4671be5271ce8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f791af84322 - std[e49fa185a119b89b]::panicking::panic_with_hook
   7:     0x7f791af66a2a - std[e49fa185a119b89b]::panicking::panic_handler::{closure#0}
   8:     0x7f791af5dab9 - std[e49fa185a119b89b]::sys::backtrace::__rust_end_short_backtrace::<std[e49fa185a119b89b]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f791af685ad - __rustc[df3bb69314ad135f]::rust_begin_unwind
  10:     0x7f791826df0c - core[17865207963548b5]::panicking::panic_fmt
  11:     0x7f7917775122 - core[17865207963548b5]::panicking::panic
  12:     0x7f7918767e39 - core[17865207963548b5]::option::unwrap_failed
  13:     0x7f791c77747e - rustc_metadata[2002d9e21ce78884]::eii::collect
  14:     0x7f791c77759e - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::externally_implementable_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>>
  15:     0x7f791bad7a77 - rustc_query_system[5be0c069f6d5c539]::query::plumbing::try_execute_query::<rustc_query_impl[462c6a5584cea8d4]::DynamicConfig<rustc_data_structures[30161969bbcb553f]::vec_cache::VecCache<rustc_span[ce53af16555a42ff]::def_id::CrateNum, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5be0c069f6d5c539]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  16:     0x7f791bad0f49 - rustc_query_impl[462c6a5584cea8d4]::query_impl::externally_implementable_items::get_query_non_incr::__rust_end_short_backtrace
  17:     0x7f791bad02ba - rustc_passes[9766a5655bde9e6]::eii::check_externally_implementable_items
  18:     0x7f791bad022f - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::check_externally_implementable_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 0usize]>>
  19:     0x7f791c7725a6 - rustc_query_system[5be0c069f6d5c539]::query::plumbing::try_execute_query::<rustc_query_impl[462c6a5584cea8d4]::DynamicConfig<rustc_query_system[5be0c069f6d5c539]::query::caches::SingleCache<rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  20:     0x7f791c77238e - rustc_query_impl[462c6a5584cea8d4]::query_impl::check_externally_implementable_items::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7f791b6ec481 - rustc_interface[50af632e35c6bce3]::passes::analysis
  22:     0x7f791b6ec2e5 - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 0usize]>>
  23:     0x7f791c7725a6 - rustc_query_system[5be0c069f6d5c539]::query::plumbing::try_execute_query::<rustc_query_impl[462c6a5584cea8d4]::DynamicConfig<rustc_query_system[5be0c069f6d5c539]::query::caches::SingleCache<rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  24:     0x7f791c772176 - rustc_query_impl[462c6a5584cea8d4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f791c92cdd4 - <rustc_interface[50af632e35c6bce3]::passes::create_and_enter_global_ctxt<core[17865207963548b5]::option::Option<rustc_interface[50af632e35c6bce3]::queries::Linker>, rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[17865207963548b5]::ops::function::FnOnce<(&rustc_session[307f8e7a4263bd4]::session::Session, rustc_middle[7055997c00c0bb98]::ty::context::CurrentGcx, alloc[756b9f94e2773738]::sync::Arc<rustc_data_structures[30161969bbcb553f]::jobserver::Proxy>, &std[e49fa185a119b89b]::sync::once_lock::OnceLock<rustc_middle[7055997c00c0bb98]::ty::context::GlobalCtxt>, &rustc_data_structures[30161969bbcb553f]::sync::worker_local::WorkerLocal<rustc_middle[7055997c00c0bb98]::arena::Arena>, &rustc_data_structures[30161969bbcb553f]::sync::worker_local::WorkerLocal<rustc_hir[5d00f225b65c0257]::Arena>, rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  26:     0x7f791c7c19da - rustc_interface[50af632e35c6bce3]::interface::run_compiler::<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7f791c731d8e - std[e49fa185a119b89b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[50af632e35c6bce3]::util::run_in_thread_with_globals<rustc_interface[50af632e35c6bce3]::util::run_in_thread_pool_with_globals<rustc_interface[50af632e35c6bce3]::interface::run_compiler<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7f791c731b60 - <std[e49fa185a119b89b]::thread::lifecycle::spawn_unchecked<rustc_interface[50af632e35c6bce3]::util::run_in_thread_with_globals<rustc_interface[50af632e35c6bce3]::util::run_in_thread_pool_with_globals<rustc_interface[50af632e35c6bce3]::interface::run_compiler<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[17865207963548b5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7f791c7374f8 - <std[e49fa185a119b89b]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7f79160969cb - <unknown>
  31:     0x7f791611aa0c - <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 (3f4dc1e02 2025-12-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [externally_implementable_items] looking up the externally implementable items of a crate
#1 [check_externally_implementable_items] check externally implementable items
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-extern_item_impls`#![feature(extern_item_impls)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions