Skip to content

ICE: eii on generic Instance::mono: DefId(..) has type parameters #149983

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#[eii]
fn foo<T>() {}

original:

#![feature(extern_item_impls)]
#[eii]
fn foo<T>() {}

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:

}
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
let args = GenericArgs::for_item(tcx, def_id, |param, _| match param.kind {
ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(),
ty::GenericParamDefKind::Type { .. } => {
bug!("Instance::mono: {:?} has type parameters", def_id)
}
ty::GenericParamDefKind::Const { .. } => {
bug!("Instance::mono: {:?} has const parameters", def_id)
}
});

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

Program output

error[E0658]: use of unstable library feature `extern_item_impls`
 --> /tmp/icemaker_global_tempdir.U3tHnWSBpLWx/rustc_testrunner_tmpdir_reporting.H4TpM3NoZJ6J/mvce.rs:1:3
  |
1 | #[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

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.U3tHnWSBpLWx/rustc_testrunner_tmpdir_reporting.H4TpM3NoZJ6J/mvce.rs:2:15
  |
2 | fn foo<T>() {}
  |               ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.U3tHnWSBpLWx/rustc_testrunner_tmpdir_reporting.H4TpM3NoZJ6J/mvce.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:469:17: Instance::mono: DefId(0:7 ~ mvce[6920]::{extern#0}::foo) has type parameters


thread 'rustc' (889356) panicked at compiler/rustc_middle/src/ty/instance.rs:469:17:
Box<dyn Any>
stack backtrace:
   0:     0x7fe188f90173 - <<std[e49fa185a119b89b]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[17865207963548b5]::fmt::Display>::fmt
   1:     0x7fe189610648 - core[17865207963548b5]::fmt::write
   2:     0x7fe188fa67c6 - <std[e49fa185a119b89b]::sys::stdio::unix::Stderr as std[e49fa185a119b89b]::io::Write>::write_fmt
   3:     0x7fe188f66938 - std[e49fa185a119b89b]::panicking::default_hook::{closure#0}
   4:     0x7fe188f84043 - std[e49fa185a119b89b]::panicking::default_hook
   5:     0x7fe187f741d7 - std[e49fa185a119b89b]::panicking::update_hook::<alloc[756b9f94e2773738]::boxed::Box<rustc_driver_impl[e1c4671be5271ce8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe188f84322 - std[e49fa185a119b89b]::panicking::panic_with_hook
   7:     0x7fe187fb0c61 - std[e49fa185a119b89b]::panicking::begin_panic::<rustc_errors[c34899de065ee3bb]::ExplicitBug>::{closure#0}
   8:     0x7fe187fa12b6 - std[e49fa185a119b89b]::sys::backtrace::__rust_end_short_backtrace::<std[e49fa185a119b89b]::panicking::begin_panic<rustc_errors[c34899de065ee3bb]::ExplicitBug>::{closure#0}, !>
   9:     0x7fe187fa0efa - std[e49fa185a119b89b]::panicking::begin_panic::<rustc_errors[c34899de065ee3bb]::ExplicitBug>
  10:     0x7fe187fce351 - <rustc_errors[c34899de065ee3bb]::diagnostic::BugAbort as rustc_errors[c34899de065ee3bb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fe188571e09 - rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt::<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}
  12:     0x7fe188571f92 - rustc_middle[7055997c00c0bb98]::ty::context::tls::with_opt::<rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fe18856376b - rustc_middle[7055997c00c0bb98]::ty::context::tls::with_context_opt::<rustc_middle[7055997c00c0bb98]::ty::context::tls::with_opt<rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fe186a6b994 - rustc_middle[7055997c00c0bb98]::util::bug::bug_fmt
  15:     0x7fe18afc4bc8 - <rustc_middle[7055997c00c0bb98]::ty::list::RawList<(), rustc_middle[7055997c00c0bb98]::ty::generic_args::GenericArg>>::fill_item::<<rustc_middle[7055997c00c0bb98]::ty::instance::Instance>::mono::{closure#0}>.llvm.5956545360636944833.cold
  16:     0x7fe18986537f - <rustc_middle[7055997c00c0bb98]::ty::instance::Instance>::mono
  17:     0x7fe18a0f6002 - rustc_codegen_ssa[8ebb5883527637a7]::codegen_attrs::codegen_fn_attrs
  18:     0x7fe18a0f3329 - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::codegen_fn_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>>
  19:     0x7fe189619ac6 - rustc_query_system[5be0c069f6d5c539]::query::plumbing::try_execute_query::<rustc_query_impl[462c6a5584cea8d4]::DynamicConfig<rustc_query_system[5be0c069f6d5c539]::query::caches::DefIdCache<rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  20:     0x7fe18961939d - rustc_query_impl[462c6a5584cea8d4]::query_impl::codegen_fn_attrs::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7fe189dcec9c - rustc_hir_analysis[d4ef36df6ca7828f]::check::check::check_item_type
  22:     0x7fe189dca276 - rustc_hir_analysis[d4ef36df6ca7828f]::check::wfcheck::check_well_formed
  23:     0x7fe189dca257 - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7fe189dc9acd - 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::LocalDefId, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[5be0c069f6d5c539]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  25:     0x7fe189dc95d6 - rustc_query_impl[462c6a5584cea8d4]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7fe189dc6d70 - rustc_hir_analysis[d4ef36df6ca7828f]::check::wfcheck::check_type_wf
  27:     0x7fe189dc6c61 - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7fe18a770dd4 - 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; 1usize]>>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  29:     0x7fe18a770bb6 - rustc_query_impl[462c6a5584cea8d4]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7fe18a0f8316 - rustc_hir_analysis[d4ef36df6ca7828f]::check_crate
  31:     0x7fe1896ec69b - rustc_interface[50af632e35c6bce3]::passes::analysis
  32:     0x7fe1896ec2e5 - 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]>>
  33:     0x7fe18a7725a6 - 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>
  34:     0x7fe18a772176 - rustc_query_impl[462c6a5584cea8d4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fe18a92cdd4 - <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}
  36:     0x7fe18a7c19da - rustc_interface[50af632e35c6bce3]::interface::run_compiler::<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7fe18a731d8e - 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}, ()>
  38:     0x7fe18a731b60 - <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}
  39:     0x7fe18a7374f8 - <std[e49fa185a119b89b]::sys::thread::unix::Thread>::new::thread_start
  40:     0x7fe1840969cb - <unknown>
  41:     0x7fe18411aa0c - <unknown>
  42:                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: 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 [codegen_fn_attrs] computing codegen attributes of `_::foo`
#1 [check_well_formed] checking that `_::foo` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error[E0044]: foreign items may not have type parameters
 --> /tmp/icemaker_global_tempdir.U3tHnWSBpLWx/rustc_testrunner_tmpdir_reporting.H4TpM3NoZJ6J/mvce.rs:2:1
  |
2 | fn foo<T>() {}
  | ^^^^^^^^^^^ can't have type parameters
  |
  = help: replace the type parameters with concrete types like `u32`

error: aborting due to 4 previous errors

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

@rustbot label +F-extern_item_impls

Metadata

Metadata

Assignees

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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions