Repository: rust
Issue: ICE: `ConstEvaluatable(UnevaluatedConst .. has escaping bound vars, so it cannot be wrapped in a dummy binder.`
Labels: I-ICE,T-compiler,C-bug,F-generic_const_exprs,S-has-mcve,S-has-bisection

<!--
[31mICE[0m: Rustc ./a.rs '-Zcrate-attr=feature(generic_const_exprs) -ooutputfile -Zdump-mir-dir=dir' 'thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:511:26: '`ConstEvaluatable(UnevaluatedConst { def: DefId(0:8 ~ a[5f0f]::S::{constant#0}), args: ['^0.Named(DefId(0:16 ~ a[5f0f]::{extern#0}::lint_me::'_), "'_"), '^1.Named(DefId(0:17 ~ a[5f0f]::{extern#0}::lint_me::'_#1), "'_")] })` has escaping bound vars, so it cannot be wrapped in a dummy binder.'', 'thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:511:26: '`ConstEvaluatable(UnevaluatedConst { def: DefId(0:8 ~ a[5f0f]::S::{constant#0}), args: ['^0.Named(DefId(0:16 ~ a[5f0f]::{extern#0}::lint_me::'_), "'_"), '^1.Named(DefId(0:17 ~ a[5f0f]::{extern#0}::lint_me::'_#1), "'_")] })` has escaping bound vars, so it cannot be wrapped in a dummy binder.''
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
#![feature(generic_const_exprs)]
type Bar<T> = T;
type S<'l> = [i32; A];

extern "C" {
    pub fn lint_me(x: Bar<S<{}>>);
}

````

original:
````rust
// Regression test for issue #119295.

#![feature(type_alias_impl_trait)]

type Bar<T> = T;
type S<'l, 'same_pattern> = [i32; A];

extern "C" {
    pub fn lint_me(
        x: Bar<
            S<
                { //~ ERROR mismatched types
                    pub type Sum<A, B> = <A as Add<B>>::Output;
                    //~^ ERROR unconstrained opaque type
                },
            >,
        >,
    );
}

fn main() {}

````

Version information
````
rustc 1.86.0-nightly (c62b73272 2025-01-19)
binary: rustc
commit-hash: c62b732724b6beb50a5c73be26d0c5f668504059
commit-date: 2025-01-19
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

````

Possibly related line of code:
https://github.com/rust-lang/rust/blob/c62b732724b6beb50a5c73be26d0c5f668504059/compiler/rustc_middle/src/ty/predicate.rs#L505-L517

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs)`

<details><summary><strong>Program output</strong></summary>
<p>

```
error[E0425]: cannot find value `A` in this scope
 --> /tmp/icemaker_global_tempdir.7oeLQrIl66wL/rustc_testrunner_tmpdir_reporting.YAHMJ2htoVtz/mvce.rs:2:20
  |
2 | type S<'l> = [i32; A];
  |                    ^ 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
 --> <crate attribute>:1:9
  |
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

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.7oeLQrIl66wL/rustc_testrunner_tmpdir_reporting.YAHMJ2htoVtz/mvce.rs:6:2
  |
6 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.7oeLQrIl66wL/rustc_testrunner_tmpdir_reporting.YAHMJ2htoVtz/mvce.rs`

error[E0107]: type alias takes 0 generic arguments but 1 generic argument was supplied
 --> /tmp/icemaker_global_tempdir.7oeLQrIl66wL/rustc_testrunner_tmpdir_reporting.YAHMJ2htoVtz/mvce.rs:5:27
  |
5 |     pub fn lint_me(x: Bar<S<{}>>);
  |                           ^ -- help: remove the unnecessary generic argument
  |                           |
  |                           expected 0 generic arguments
  |
note: type alias defined here, with 0 generic parameters
 --> /tmp/icemaker_global_tempdir.7oeLQrIl66wL/rustc_testrunner_tmpdir_reporting.YAHMJ2htoVtz/mvce.rs:2:6
  |
2 | type S<'l> = [i32; A];
  |      ^


thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:511:26:
`ConstEvaluatable(UnevaluatedConst { def: DefId(0:7 ~ mvce[281a]::S::{constant#0}), args: ['^0.Named(DefId(0:11 ~ mvce[281a]::{extern#0}::lint_me::'_), "'_")] })` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x7526136f57fa - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h913b3ba5a3fabe95
   1:     0x752613e12da6 - core::fmt::write::hccd409e337a87e20
   2:     0x752614d1dd51 - std::io::Write::write_fmt::hb2e39594285880b6
   3:     0x7526136f5652 - std::sys::backtrace::BacktraceLock::print::hf55385c23ca0d98c
   4:     0x7526136f7ad2 - std::panicking::default_hook::{{closure}}::hf1b1117dfff2dddd
   5:     0x7526136f795a - std::panicking::default_hook::h8eb75fbb03af06c8
   6:     0x752612855deb - std[3d5eca3a92bc4dab]::panicking::update_hook::<alloc[a0e257928d44e98b]::boxed::Box<rustc_driver_impl[a4e3be7b68e659d1]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7526136f8653 - std::panicking::rust_panic_with_hook::hd4e13f60768f5c61
   8:     0x7526136f834a - std::panicking::begin_panic_handler::{{closure}}::ha9e43821cab53039
   9:     0x7526136f5cc9 - std::sys::backtrace::__rust_end_short_backtrace::h55a888377cfa5bc9
  10:     0x7526136f800d - rust_begin_unwind
  11:     0x7526103a8ae0 - core::panicking::panic_fmt::hd9c4ffd61cb27733
  12:     0x75261590d289 - <rustc_type_ir[6e983793a20e5c26]::binder::Binder<rustc_middle[7889754f33fd8966]::ty::context::TyCtxt, rustc_type_ir[6e983793a20e5c26]::predicate_kind::PredicateKind<rustc_middle[7889754f33fd8966]::ty::context::TyCtxt>>>::dummy.llvm.3867692987603750651.cold
  13:     0x752615043438 - <rustc_middle[7889754f33fd8966]::ty::predicate::Clause as rustc_type_ir[6e983793a20e5c26]::upcast::UpcastFrom<rustc_middle[7889754f33fd8966]::ty::context::TyCtxt, rustc_type_ir[6e983793a20e5c26]::predicate_kind::ClauseKind<rustc_middle[7889754f33fd8966]::ty::context::TyCtxt>>>::upcast_from
  14:     0x752612a4a1cc - <rustc_hir_analysis[3c8bb58bae5ad588]::collect::predicates_of::const_evaluatable_predicates_of::{closure#0}::ConstCollector as rustc_type_ir[6e983793a20e5c26]::visit::TypeVisitor<rustc_middle[7889754f33fd8966]::ty::context::TyCtxt>>::visit_const
  15:     0x752614bbfb7c - rustc_hir_analysis[3c8bb58bae5ad588]::collect::predicates_of::gather_explicit_predicates_of
  16:     0x752614bb786f - rustc_query_impl[8699b96174aa9f14]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8699b96174aa9f14]::query_impl::explicit_predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 24usize]>>
  17:     0x752614069230 - rustc_query_system[afaedc2be035c28b]::query::plumbing::try_execute_query::<rustc_query_impl[8699b96174aa9f14]::DynamicConfig<rustc_query_system[afaedc2be035c28b]::query::caches::DefIdCache<rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[8699b96174aa9f14]::plumbing::QueryCtxt, false>
  18:     0x752614068a68 - rustc_query_impl[8699b96174aa9f14]::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace
  19:     0x752614067106 - rustc_hir_analysis[3c8bb58bae5ad588]::collect::predicates_of::predicates_of
  20:     0x752614067013 - rustc_query_impl[8699b96174aa9f14]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8699b96174aa9f14]::query_impl::predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 24usize]>>
  21:     0x752614069219 - rustc_query_system[afaedc2be035c28b]::query::plumbing::try_execute_query::<rustc_query_impl[8699b96174aa9f14]::DynamicConfig<rustc_query_system[afaedc2be035c28b]::query::caches::DefIdCache<rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[8699b96174aa9f14]::plumbing::QueryCtxt, false>
  22:     0x752614068968 - rustc_query_impl[8699b96174aa9f14]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace
  23:     0x75261449b2cd - <rustc_hir_analysis[3c8bb58bae5ad588]::collect::CollectItemTypesVisitor as rustc_hir[d75fc7391b460916]::intravisit::Visitor>::visit_item
  24:     0x7526144adde5 - rustc_hir_analysis[3c8bb58bae5ad588]::check::wfcheck::check_well_formed
  25:     0x7526144adbe3 - rustc_query_impl[8699b96174aa9f14]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8699b96174aa9f14]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7526144ad685 - rustc_query_system[afaedc2be035c28b]::query::plumbing::try_execute_query::<rustc_query_impl[8699b96174aa9f14]::DynamicConfig<rustc_data_structures[f5b7eb2b075db7e5]::vec_cache::VecCache<rustc_span[4d8b97697ec1bb1a]::def_id::LocalDefId, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[afaedc2be035c28b]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8699b96174aa9f14]::plumbing::QueryCtxt, false>
  27:     0x7526144ad101 - rustc_query_impl[8699b96174aa9f14]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7526144aa52c - rustc_hir_analysis[3c8bb58bae5ad588]::check::wfcheck::check_mod_type_wf
  29:     0x7526144aa34b - rustc_query_impl[8699b96174aa9f14]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8699b96174aa9f14]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 1usize]>>
  30:     0x752614d5ab88 - rustc_query_system[afaedc2be035c28b]::query::plumbing::try_execute_query::<rustc_query_impl[8699b96174aa9f14]::DynamicConfig<rustc_query_system[afaedc2be035c28b]::query::caches::DefaultCache<rustc_span[4d8b97697ec1bb1a]::def_id::LocalModDefId, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8699b96174aa9f14]::plumbing::QueryCtxt, false>
  31:     0x752614d5a930 - rustc_query_impl[8699b96174aa9f14]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7526142449a6 - rustc_hir_analysis[3c8bb58bae5ad588]::check_crate
  33:     0x7526142413a2 - rustc_interface[9d7efb036b79b9b4]::passes::run_required_analyses
  34:     0x752614d1955e - rustc_interface[9d7efb036b79b9b4]::passes::analysis
  35:     0x752614d1952f - rustc_query_impl[8699b96174aa9f14]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8699b96174aa9f14]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 0usize]>>
  36:     0x752614dd2d95 - rustc_query_system[afaedc2be035c28b]::query::plumbing::try_execute_query::<rustc_query_impl[8699b96174aa9f14]::DynamicConfig<rustc_query_system[afaedc2be035c28b]::query::caches::SingleCache<rustc_middle[7889754f33fd8966]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8699b96174aa9f14]::plumbing::QueryCtxt, false>
  37:     0x752614dd2ace - rustc_query_impl[8699b96174aa9f14]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x752614d97129 - rustc_interface[9d7efb036b79b9b4]::passes::create_and_enter_global_ctxt::<core[79ca29a2cb0a3e36]::option::Option<rustc_interface[9d7efb036b79b9b4]::queries::Linker>, rustc_driver_impl[a4e3be7b68e659d1]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  39:     0x752614d67916 - rustc_interface[9d7efb036b79b9b4]::interface::run_compiler::<(), rustc_driver_impl[a4e3be7b68e659d1]::run_compiler::{closure#0}>::{closure#1}
  40:     0x752614c99387 - std[3d5eca3a92bc4dab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9d7efb036b79b9b4]::util::run_in_thread_with_globals<rustc_interface[9d7efb036b79b9b4]::util::run_in_thread_pool_with_globals<rustc_interface[9d7efb036b79b9b4]::interface::run_compiler<(), rustc_driver_impl[a4e3be7b68e659d1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x752614c99059 - <<std[3d5eca3a92bc4dab]::thread::Builder>::spawn_unchecked_<rustc_interface[9d7efb036b79b9b4]::util::run_in_thread_with_globals<rustc_interface[9d7efb036b79b9b4]::util::run_in_thread_pool_with_globals<rustc_interface[9d7efb036b79b9b4]::interface::run_compiler<(), rustc_driver_impl[a4e3be7b68e659d1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[79ca29a2cb0a3e36]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x752614c987eb - std::sys::pal::unix::thread::Thread::new::thread_start::h634ec41480837481
  43:     0x75260f06439d - <unknown>
  44:     0x75260f0e949c - <unknown>
  45:                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.86.0-nightly (c62b73272 2025-01-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z dump-mir-dir=dir

query stack during panic:
#0 [explicit_predicates_of] computing explicit predicates of `lint_me`
#1 [predicates_of] computing predicates of `lint_me`
#2 [check_well_formed] checking that `` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

```

</p>
</details>

<!--
query stack:
`ConstEvaluatable(UnevaluatedConst { def: DefId(0:7 ~ mvce[281a]::S::{constant#0}), args: ['^0.Named(DefId(0:11 ~ mvce[281a]::{extern#0}::lint_me::'_), "'_")] })` has escaping bound vars, so it cannot be wrapped in a dummy binder.
#0 [explicit_predicates_of] computing explicit predicates of `lint_me`
#1 [predicates_of] computing predicates of `lint_me`
#2 [check_well_formed] checking that `` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate

-->
@rustbot label +F-type_alias_impl_trait +F-generic_const_exprs