Skip to content

[ICE]: expected type for impl Trait .. but found Lifetime .. #155834

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}

original:

#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
fn main() {}

Version information

rustc 1.97.0-nightly (68ffae46b 2026-04-25)
binary: rustc
commit-hash: 68ffae46b581747074413e4242ab0c6ecc4db4a9
commit-date: 2026-04-25
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

self.shift_vars_through_binders(ty)
}
#[cold]
#[inline(never)]
fn type_param_expected(&self, p: I::ParamTy, ty: I::Ty, kind: ty::GenericArgKind<I>) -> ! {
panic!(
"expected type for `{:?}` ({:?}/{}) but found {:?} when instantiating, args={:?}",
p,
ty,
p.index(),
kind,
self.args,

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

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.s5sQCS09ZQrR/rustc_testrunner_tmpdir_reporting.dZLzMRMj9m4W/mvce.rs:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.s5sQCS09ZQrR/rustc_testrunner_tmpdir_reporting.dZLzMRMj9m4W/mvce.rs:5:25
  |
5 | fn N(arg: impl Trait) {}
  |                         ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.s5sQCS09ZQrR/rustc_testrunner_tmpdir_reporting.dZLzMRMj9m4W/mvce.rs`


thread 'rustc' (638682) panicked at /rustc-dev/68ffae46b581747074413e4242ab0c6ecc4db4a9/compiler/rustc_type_ir/src/binder.rs:780:9:
expected type for `impl Trait/#0` (impl Trait/#0/0) but found Lifetime('?0) when instantiating, args=['?0]
stack backtrace:
   0:     0x7f3f20d62edb - <<std[74a5d452ef4468e2]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[af918ca625322054]::fmt::Display>::fmt
   1:     0x7f3f2142d948 - core[af918ca625322054]::fmt::write
   2:     0x7f3f20d79b16 - <std[74a5d452ef4468e2]::sys::stdio::unix::Stderr as std[74a5d452ef4468e2]::io::Write>::write_fmt
   3:     0x7f3f20d39158 - std[74a5d452ef4468e2]::panicking::default_hook::{closure#0}
   4:     0x7f3f20d56543 - std[74a5d452ef4468e2]::panicking::default_hook
   5:     0x7f3f1fd2cb9c - std[74a5d452ef4468e2]::panicking::update_hook::<alloc[3c1e8b5c2310114c]::boxed::Box<rustc_driver_impl[65db170643483585]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f3f20d56822 - std[74a5d452ef4468e2]::panicking::panic_with_hook
   7:     0x7f3f20d39218 - std[74a5d452ef4468e2]::panicking::panic_handler::{closure#0}
   8:     0x7f3f20d2d779 - std[74a5d452ef4468e2]::sys::backtrace::__rust_end_short_backtrace::<std[74a5d452ef4468e2]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f3f20d3ac7d - __rustc[4d529550cd7027cf]::rust_begin_unwind
  10:     0x7f3f1d9439fc - core[af918ca625322054]::panicking::panic_fmt
  11:     0x7f3f1d988341 - <rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::type_param_expected
  12:     0x7f3f2144f0e3 - <rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt> as rustc_type_ir[1096221e047aa687]::fold::TypeFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::fold_ty
  13:     0x7f3f221491ea - <&rustc_middle[11ba238a743b416b]::ty::list::RawList<(), rustc_middle[11ba238a743b416b]::ty::generic_args::GenericArg> as rustc_type_ir[1096221e047aa687]::fold::TypeFoldable<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>
  14:     0x7f3f2144ea16 - <rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt> as rustc_type_ir[1096221e047aa687]::fold::TypeFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::fold_ty
  15:     0x7f3f2144c091 - <rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt> as rustc_type_ir[1096221e047aa687]::fold::TypeFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::fold_const
  16:     0x7f3f2144e932 - <rustc_type_ir[1096221e047aa687]::binder::ArgFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt> as rustc_type_ir[1096221e047aa687]::fold::TypeFolder<rustc_middle[11ba238a743b416b]::ty::context::TyCtxt>>::fold_ty
  17:     0x7f3f1d5af67b - <rustc_trait_selection[74a69c4642fdac27]::traits::select::SelectionContext>::match_impl::{closure#0}
  18:     0x7f3f214839cf - <rustc_trait_selection[74a69c4642fdac27]::traits::select::SelectionContext>::assemble_candidates_from_impls
  19:     0x7f3f2149f4cb - <rustc_trait_selection[74a69c4642fdac27]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  20:     0x7f3f219b44be - <rustc_trait_selection[74a69c4642fdac27]::traits::select::SelectionContext>::poly_select::{closure#0}
  21:     0x7f3f21b4393a - <rustc_trait_selection[74a69c4642fdac27]::traits::fulfill::FulfillProcessor as rustc_data_structures[c7559108f0771746]::obligation_forest::ObligationProcessor>::process_obligation
  22:     0x7f3f21405d50 - <rustc_data_structures[c7559108f0771746]::obligation_forest::ObligationForest<rustc_trait_selection[74a69c4642fdac27]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[74a69c4642fdac27]::traits::fulfill::FulfillProcessor>
  23:     0x7f3f21d508eb - <rustc_trait_selection[74a69c4642fdac27]::traits::fulfill::FulfillmentContext<rustc_trait_selection[74a69c4642fdac27]::traits::FulfillmentError> as rustc_infer[2a2824931b260976]::traits::engine::TraitEngine<rustc_trait_selection[74a69c4642fdac27]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  24:     0x7f3f21d4efd0 - rustc_hir_analysis[d855bfa14cfa04e0]::check::wfcheck::check_impl
  25:     0x7f3f22045019 - rustc_hir_analysis[d855bfa14cfa04e0]::check::check::check_item_type
  26:     0x7f3f220413e6 - rustc_hir_analysis[d855bfa14cfa04e0]::check::wfcheck::check_well_formed
  27:     0x7f3f220413c7 - rustc_query_impl[2514449be8add55a]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  28:     0x7f3f220409b2 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_data_structures[c7559108f0771746]::vec_cache::VecCache<rustc_span[1d3df3d0ad1babfb]::def_id::LocalDefId, rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[11ba238a743b416b]::dep_graph::graph::DepNodeIndex>, false>
  29:     0x7f3f22040747 - rustc_query_impl[2514449be8add55a]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7f3f2203c949 - rustc_hir_analysis[d855bfa14cfa04e0]::check::wfcheck::check_type_wf
  31:     0x7f3f2203c853 - rustc_query_impl[2514449be8add55a]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  32:     0x7f3f22565f50 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_middle[11ba238a743b416b]::query::caches::SingleCache<rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 1usize]>>, false>
  33:     0x7f3f22565d29 - rustc_query_impl[2514449be8add55a]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  34:     0x7f3f216f27e9 - rustc_hir_analysis[d855bfa14cfa04e0]::check_crate
  35:     0x7f3f22308127 - rustc_interface[78b66ebcbd67330e]::passes::analysis
  36:     0x7f3f225637c9 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_middle[11ba238a743b416b]::query::caches::SingleCache<rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  37:     0x7f3f22563429 - rustc_query_impl[2514449be8add55a]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  38:     0x7f3f2252e779 - rustc_interface[78b66ebcbd67330e]::interface::run_compiler::<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}
  39:     0x7f3f22554584 - std[74a5d452ef4468e2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_with_globals<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_pool_with_globals<rustc_interface[78b66ebcbd67330e]::interface::run_compiler<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7f3f22554c6d - <std[74a5d452ef4468e2]::thread::lifecycle::spawn_unchecked<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_with_globals<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_pool_with_globals<rustc_interface[78b66ebcbd67330e]::interface::run_compiler<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[af918ca625322054]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f3f22555aec - <std[74a5d452ef4468e2]::sys::thread::unix::Thread>::new::thread_start
  42:     0x7f3f1c0a597a - <unknown>
  43:     0x7f3f1c1292bc - <unknown>
  44:                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.97.0-nightly (68ffae46b 2026-04-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.s5sQCS09ZQrR/rustc_testrunner_tmpdir_reporting.dZLzMRMj9m4W/mvce.rs:4:1: 4:27>` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-min_generic_const_args

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`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

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions