Repository: rust
Issue: ICE with `feature(non_lifetime_binders)` for trait generic that is constrained equal to supertrait associated type.
Labels: I-ICE,T-compiler,C-bug,S-bug-has-test,T-types,F-non_lifetime_binders,requires-incomplete-features

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
#![feature(non_lifetime_binders)]
#![allow(unused)]

trait A<T>: Iterator<Item = T> {}

fn demo(x: &mut impl for<U> A<U>) {
    let _: Option<u32> = x.next(); // Removing this line stops the ICE
}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.83.0-nightly (0609062a9 2024-09-13)
binary: rustc
commit-hash: 0609062a91c8f445c3e9a0de57e402f9b1b8b0a7
commit-date: 2024-09-13
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
```

### Error output

```
thread 'rustc' panicked at compiler/rustc_borrowck/src/type_check/relate_tys.rs:343:9:
unexpected inference var std::option::Option<?0t>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```rs
$ RUST_BACKTRACE=full cargo build 
   Compiling non-lifetime-binders-ice v0.1.0 (/home/zachary/Programming/rusttesting/non-lifetime-binders-ice)
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/lib.rs:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

thread 'rustc' panicked at compiler/rustc_borrowck/src/type_check/relate_tys.rs:343:9:
unexpected inference var std::option::Option<?0t>
stack backtrace:
   0:     0x7df233a7701a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h85a9257eb6c41e04
   1:     0x7df234203257 - core::fmt::write::hcc8bee8d21353e39
   2:     0x7df23515c4b3 - std::io::Write::write_fmt::h70ac935b0c89b059
   3:     0x7df233a76e72 - std::sys::backtrace::BacktraceLock::print::hd262bc6f83870824
   4:     0x7df233a795f1 - std::panicking::default_hook::{{closure}}::h1ac01a4d50ceb64f
   5:     0x7df233a79424 - std::panicking::default_hook::h7c4ba54603c1d0b3
   6:     0x7df232b7ccff - std[b495ad0c4617e146]::panicking::update_hook::<alloc[a0425571c9a9acf]::boxed::Box<rustc_driver_impl[f22662736fcaf763]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7df233a79d18 - std::panicking::rust_panic_with_hook::h0dd05eda4407feb9
   8:     0x7df233a79ae7 - std::panicking::begin_panic_handler::{{closure}}::hff4951198a9049be
   9:     0x7df233a774c9 - std::sys::backtrace::__rust_end_short_backtrace::hae232f20e82e2c44
  10:     0x7df233a797b4 - rust_begin_unwind
  11:     0x7df230894523 - core::panicking::panic_fmt::h6dddd3310fdcb8b7
  12:     0x7df23443ca7f - <rustc_borrowck[a2299cf35e33e6d2]::type_check::relate_tys::NllTypeRelating as rustc_type_ir[a35413f6f42f08]::relate::TypeRelation<rustc_middle[7cca7f2870ea52e7]::ty::context::TyCtxt>>::tys
  13:     0x7df234447572 - <rustc_borrowck[a2299cf35e33e6d2]::type_check::TypeChecker>::typeck_mir
  14:     0x7df235302842 - rustc_borrowck[a2299cf35e33e6d2]::type_check::type_check
  15:     0x7df2342c4549 - rustc_borrowck[a2299cf35e33e6d2]::nll::compute_regions
  16:     0x7df2352b18c8 - rustc_borrowck[a2299cf35e33e6d2]::do_mir_borrowck
  17:     0x7df2352a3f87 - rustc_query_impl[484dcaccf014b2f3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[484dcaccf014b2f3]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 8usize]>>
  18:     0x7df2344925d4 - rustc_query_system[a8532041af820499]::query::plumbing::try_execute_query::<rustc_query_impl[484dcaccf014b2f3]::DynamicConfig<rustc_query_system[a8532041af820499]::query::caches::VecCache<rustc_span[45f656ad9ccc3ab8]::def_id::LocalDefId, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[484dcaccf014b2f3]::plumbing::QueryCtxt, true>
  19:     0x7df234497434 - rustc_query_impl[484dcaccf014b2f3]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  20:     0x7df234a7e278 - rustc_interface[1ce9087adc29d20e]::passes::run_required_analyses
  21:     0x7df2350b4b9e - rustc_interface[1ce9087adc29d20e]::passes::analysis
  22:     0x7df2350b4b71 - rustc_query_impl[484dcaccf014b2f3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[484dcaccf014b2f3]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 1usize]>>
  23:     0x7df2350bdc4d - rustc_query_system[a8532041af820499]::query::plumbing::try_execute_query::<rustc_query_impl[484dcaccf014b2f3]::DynamicConfig<rustc_query_system[a8532041af820499]::query::caches::SingleCache<rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[484dcaccf014b2f3]::plumbing::QueryCtxt, true>
  24:     0x7df2350bd8fa - rustc_query_impl[484dcaccf014b2f3]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  25:     0x7df234f3aafc - rustc_interface[1ce9087adc29d20e]::interface::run_compiler::<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7df23503fc50 - std[b495ad0c4617e146]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_with_globals<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_pool_with_globals<rustc_interface[1ce9087adc29d20e]::interface::run_compiler<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>
  27:     0x7df2350402ba - <<std[b495ad0c4617e146]::thread::Builder>::spawn_unchecked_<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_with_globals<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_pool_with_globals<rustc_interface[1ce9087adc29d20e]::interface::run_compiler<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#1} as core[7f44e8b513577cf8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7df2350406ab - std::sys::pal::unix::thread::Thread::new::thread_start::hdd18e2f9323a466b
  29:     0x7df22f29ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  30:     0x7df22f329c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  31:                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: please attach the file at `/home/zachary/Programming/rusttesting/non-lifetime-binders-ice/rustc-ice-2024-09-14T08_33_54-96527.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `demo`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: `non-lifetime-binders-ice` (lib) generated 1 warning
error: could not compile `non-lifetime-binders-ice` (lib); 1 warning emitted

Caused by:
  process didn't exit successfully: `/home/zachary/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name non_lifetime_binders_ice --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=180 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=f19fe47f3fdd4a9f -C extra-filename=-f19fe47f3fdd4a9f --out-dir /home/zachary/opt_mount/zachary/cargo-target/debug/deps -C incremental=/home/zachary/opt_mount/zachary/cargo-target/debug/incremental -L dependency=/home/zachary/opt_mount/zachary/cargo-target/debug/deps` (exit status: 101)
```

`/.../non-lifetime-binders-ice/rustc-ice-2024-09-14T08_33_54-96527.txt`: 

```rs
thread 'rustc' panicked at compiler/rustc_borrowck/src/type_check/relate_tys.rs:343:9:
unexpected inference var std::option::Option<?0t>
stack backtrace:
   0:     0x7df23543dbe5 - std::backtrace::Backtrace::create::h47c5ac21bc5295ff
   1:     0x7df233a62695 - std::backtrace::Backtrace::force_capture::h22d7360fb10c606e
   2:     0x7df232b7d337 - std[b495ad0c4617e146]::panicking::update_hook::<alloc[a0425571c9a9acf]::boxed::Box<rustc_driver_impl[f22662736fcaf763]::install_ice_hook::{closure#0}>>::{closure#0}
   3:     0x7df233a79d18 - std::panicking::rust_panic_with_hook::h0dd05eda4407feb9
   4:     0x7df233a79ae7 - std::panicking::begin_panic_handler::{{closure}}::hff4951198a9049be
   5:     0x7df233a774c9 - std::sys::backtrace::__rust_end_short_backtrace::hae232f20e82e2c44
   6:     0x7df233a797b4 - rust_begin_unwind
   7:     0x7df230894523 - core::panicking::panic_fmt::h6dddd3310fdcb8b7
   8:     0x7df23443ca7f - <rustc_borrowck[a2299cf35e33e6d2]::type_check::relate_tys::NllTypeRelating as rustc_type_ir[a35413f6f42f08]::relate::TypeRelation<rustc_middle[7cca7f2870ea52e7]::ty::context::TyCtxt>>::tys
   9:     0x7df234447572 - <rustc_borrowck[a2299cf35e33e6d2]::type_check::TypeChecker>::typeck_mir
  10:     0x7df235302842 - rustc_borrowck[a2299cf35e33e6d2]::type_check::type_check
  11:     0x7df2342c4549 - rustc_borrowck[a2299cf35e33e6d2]::nll::compute_regions
  12:     0x7df2352b18c8 - rustc_borrowck[a2299cf35e33e6d2]::do_mir_borrowck
  13:     0x7df2352a3f87 - rustc_query_impl[484dcaccf014b2f3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[484dcaccf014b2f3]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 8usize]>>
  14:     0x7df2344925d4 - rustc_query_system[a8532041af820499]::query::plumbing::try_execute_query::<rustc_query_impl[484dcaccf014b2f3]::DynamicConfig<rustc_query_system[a8532041af820499]::query::caches::VecCache<rustc_span[45f656ad9ccc3ab8]::def_id::LocalDefId, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[484dcaccf014b2f3]::plumbing::QueryCtxt, true>
  15:     0x7df234497434 - rustc_query_impl[484dcaccf014b2f3]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  16:     0x7df234a7e278 - rustc_interface[1ce9087adc29d20e]::passes::run_required_analyses
  17:     0x7df2350b4b9e - rustc_interface[1ce9087adc29d20e]::passes::analysis
  18:     0x7df2350b4b71 - rustc_query_impl[484dcaccf014b2f3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[484dcaccf014b2f3]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 1usize]>>
  19:     0x7df2350bdc4d - rustc_query_system[a8532041af820499]::query::plumbing::try_execute_query::<rustc_query_impl[484dcaccf014b2f3]::DynamicConfig<rustc_query_system[a8532041af820499]::query::caches::SingleCache<rustc_middle[7cca7f2870ea52e7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[484dcaccf014b2f3]::plumbing::QueryCtxt, true>
  20:     0x7df2350bd8fa - rustc_query_impl[484dcaccf014b2f3]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  21:     0x7df234f3aafc - rustc_interface[1ce9087adc29d20e]::interface::run_compiler::<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}
  22:     0x7df23503fc50 - std[b495ad0c4617e146]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_with_globals<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_pool_with_globals<rustc_interface[1ce9087adc29d20e]::interface::run_compiler<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>
  23:     0x7df2350402ba - <<std[b495ad0c4617e146]::thread::Builder>::spawn_unchecked_<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_with_globals<rustc_interface[1ce9087adc29d20e]::util::run_in_thread_pool_with_globals<rustc_interface[1ce9087adc29d20e]::interface::run_compiler<core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>, rustc_driver_impl[f22662736fcaf763]::run_compiler::{closure#0}>::{closure#1}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7f44e8b513577cf8]::result::Result<(), rustc_span[45f656ad9ccc3ab8]::ErrorGuaranteed>>::{closure#1} as core[7f44e8b513577cf8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7df2350406ab - std::sys::pal::unix::thread::Thread::new::thread_start::hdd18e2f9323a466b
  25:     0x7df22f29ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  26:     0x7df22f329c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  27:                0x0 - <unknown>


rustc version: 1.83.0-nightly (0609062a9 2024-09-13)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `demo`
#1 [analysis] running analysis passes on this crate
end of query stack
```

</p>
</details>


@rustbot label +F-non-lifetime-binders +requires-nightly