Skip to content

ICE: wf: ..has escaping bound vars, so it cannot be wrapped in a dummy binder #146903

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]
#![feature(lazy_type_alias)]
type FooArg<'a, 'bb> = [u8; x];
type _TaWhere1 = Box<Fn(FooArg)>;

original:

#![feature(generic_const_exprs)]
#![feature(lazy_type_alias)]
type FooArg<'a, 'bb> = [u8; x];
type _TaWhere1 = Box<Fn(FooArg) >;

pub fn main() {}

Version information

rustc 1.92.0-nightly (ce4beebec 2025-09-22)
binary: rustc
commit-hash: ce4beebecb77821734079cff47d8af08f9f27f11
commit-date: 2025-09-22
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

Possibly related line of code:

let cause = self.cause(ObligationCauseCode::ArrayLen(t));
self.out.push(traits::Obligation::with_depth(
tcx,
cause,
self.recursion_depth,
self.param_env,
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(
len,
tcx.types.usize,
))),
));
}

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

Program output

error[E0425]: cannot find value `x` in this scope
 --> /tmp/icemaker_global_tempdir.a4ZmvyZfIZaM/rustc_testrunner_tmpdir_reporting.eJnlgeCgC6AQ/mvce.rs:3:29
  |
3 | type FooArg<'a, 'bb> = [u8; x];
  |                             ^ not found in this scope

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

warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.a4ZmvyZfIZaM/rustc_testrunner_tmpdir_reporting.eJnlgeCgC6AQ/mvce.rs:2:12
  |
2 | #![feature(lazy_type_alias)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.a4ZmvyZfIZaM/rustc_testrunner_tmpdir_reporting.eJnlgeCgC6AQ/mvce.rs:4:34
  |
4 | type _TaWhere1 = Box<Fn(FooArg)>;
  |                                  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.a4ZmvyZfIZaM/rustc_testrunner_tmpdir_reporting.eJnlgeCgC6AQ/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.a4ZmvyZfIZaM/rustc_testrunner_tmpdir_reporting.eJnlgeCgC6AQ/mvce.rs:4:22
  |
4 | type _TaWhere1 = Box<Fn(FooArg)>;
  |                      ^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
  |
4 | type _TaWhere1 = Box<dyn Fn(FooArg)>;
  |                      +++


thread 'rustc' (286396) panicked at compiler/rustc_trait_selection/src/traits/wf.rs:760:21:
`ConstArgHasType(UnevaluatedConst { def: DefId(0:6 ~ mvce[47ca]::FooArg::{constant#0}), args: ['^0.Named(DefId(0:8 ~ mvce[47ca]::_TaWhere1::'_)), '^1.Named(DefId(0:9 ~ mvce[47ca]::_TaWhere1::'_#1))] }, usize)` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x7fca3ba02753 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3e5bd3a23c0347a9
   1:     0x7fca3c202044 - core::fmt::write::heee6829eb564c27d
   2:     0x7fca3b9b7101 - std::io::Write::write_fmt::ha453775b50cc97a5
   3:     0x7fca3b9c84c2 - std::sys::backtrace::BacktraceLock::print::h71d64778f60f39dd
   4:     0x7fca3b9ce429 - std::panicking::default_hook::{{closure}}::h0c1df9123d837333
   5:     0x7fca3b9cdf53 - std::panicking::default_hook::h1518572259f2e3d5
   6:     0x7fca3a9f1e47 - std[18d792bd9b3d078a]::panicking::update_hook::<alloc[cb65cdfa434cac9f]::boxed::Box<rustc_driver_impl[477d964a0f4cf97e]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fca3b9ce84f - std::panicking::panic_with_hook::hec947c027cbe77e3
   8:     0x7fca3b9ce60a - std::panicking::panic_handler::{{closure}}::h420539349ea435e2
   9:     0x7fca3b9c85f9 - std::sys::backtrace::__rust_end_short_backtrace::h3bc70f6bdfad0d7e
  10:     0x7fca3b9a913d - __rustc[5f47dcb501f887f7]::rust_begin_unwind
  11:     0x7fca389fe0a0 - core::panicking::panic_fmt::hff23e5fdf1301a77
  12:     0x7fca3de97908 - <rustc_type_ir[75560ed23b05734]::binder::Binder<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt, rustc_type_ir[75560ed23b05734]::predicate_kind::PredicateKind<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt>>>::dummy.cold
  13:     0x7fca3cc12ca3 - <rustc_trait_selection[ff1980eedda976e0]::traits::wf::WfPredicates as rustc_type_ir[75560ed23b05734]::visit::TypeVisitor<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt>>::visit_ty
  14:     0x7fca3cc11f59 - <rustc_trait_selection[ff1980eedda976e0]::traits::wf::WfPredicates as rustc_type_ir[75560ed23b05734]::visit::TypeVisitor<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt>>::visit_ty
  15:     0x7fca3cc13103 - <rustc_trait_selection[ff1980eedda976e0]::traits::wf::WfPredicates as rustc_type_ir[75560ed23b05734]::visit::TypeVisitor<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt>>::visit_ty
  16:     0x7fca3cc1165a - <rustc_trait_selection[ff1980eedda976e0]::traits::wf::WfPredicates as rustc_type_ir[75560ed23b05734]::visit::TypeVisitor<rustc_middle[168a57e624ed4250]::ty::context::TyCtxt>>::visit_ty
  17:     0x7fca3ca3a693 - <rustc_trait_selection[ff1980eedda976e0]::traits::fulfill::FulfillProcessor as rustc_data_structures[2cf611a40505b448]::obligation_forest::ObligationProcessor>::process_obligation
  18:     0x7fca3c204f89 - <rustc_data_structures[2cf611a40505b448]::obligation_forest::ObligationForest<rustc_trait_selection[ff1980eedda976e0]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[ff1980eedda976e0]::traits::fulfill::FulfillProcessor>
  19:     0x7fca3cb8992a - <rustc_trait_selection[ff1980eedda976e0]::traits::fulfill::FulfillmentContext<rustc_trait_selection[ff1980eedda976e0]::traits::FulfillmentError> as rustc_infer[64ee6b518028a4d2]::traits::engine::TraitEngine<rustc_trait_selection[ff1980eedda976e0]::traits::FulfillmentError>>::select_all_or_error
  20:     0x7fca3cadc1e9 - rustc_hir_analysis[4edf01fa6f9b9c5f]::check::check::check_item_type
  21:     0x7fca3cad3bf9 - rustc_hir_analysis[4edf01fa6f9b9c5f]::check::wfcheck::check_well_formed
  22:     0x7fca3cad3bdb - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 1usize]>>
  23:     0x7fca3cad3452 - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_data_structures[2cf611a40505b448]::vec_cache::VecCache<rustc_span[150c1f29595c3fc1]::def_id::LocalDefId, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[fc44913d20ec5c31]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
  24:     0x7fca3cad2f56 - rustc_query_impl[e799cb834319d50f]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7fca3cad0575 - rustc_hir_analysis[4edf01fa6f9b9c5f]::check::wfcheck::check_type_wf
  26:     0x7fca3cad0475 - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 1usize]>>
  27:     0x7fca3d2638c8 - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::SingleCache<rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
  28:     0x7fca3d263576 - rustc_query_impl[e799cb834319d50f]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fca3cc8109c - rustc_hir_analysis[4edf01fa6f9b9c5f]::check_crate
  30:     0x7fca3c401870 - rustc_interface[60bc46e8fdb58ac8]::passes::analysis
  31:     0x7fca3c40152d - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7fca3d2699a0 - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::SingleCache<rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
  33:     0x7fca3d26967c - rustc_query_impl[e799cb834319d50f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fca3d474b0f - rustc_interface[60bc46e8fdb58ac8]::passes::create_and_enter_global_ctxt::<core[524b22d1fd644b30]::option::Option<rustc_interface[60bc46e8fdb58ac8]::queries::Linker>, rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  35:     0x7fca3d4121be - rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler::<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7fca3d374778 - std[18d792bd9b3d078a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_with_globals<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_pool_with_globals<rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7fca3d37445c - <<std[18d792bd9b3d078a]::thread::Builder>::spawn_unchecked_<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_with_globals<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_pool_with_globals<rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[524b22d1fd644b30]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fca3d37a34d - std::sys::thread::unix::Thread::new::thread_start::hd35e43a00d992682
  39:     0x7fca36a969cb - <unknown>
  40:     0x7fca36b1aa0c - <unknown>
  41:                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.92.0-nightly (ce4beebec 2025-09-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `_TaWhere1` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 3 warnings emitted

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

@rustbot label +F-generic_const_exprs +F-lazy_type_alias

Metadata

Metadata

Assignees

No one assigned

    Labels

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