Repository: rust
Issue: ICE: 'Ok([Binder {..}, ...) is not fully resolved'
Labels: I-ICE,A-trait-system,P-medium,A-associated-items,T-compiler,regression-from-stable-to-stable,C-bug,S-bug-has-test,T-types,fixed-by-next-solver,A-higher-ranked

<!--
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
trait Www {
    type W;
}

trait Xxx: Www<W = Self::X> {
    type X;
}

trait Yyy: Xxx {}

trait Zzz<'a>: Yyy + Xxx<X = Self::Z> {
    type Z;
}

trait Aaa {
    type Y: Yyy;
}

trait Bbb: Aaa<Y = Self::B> {
    type B: for<'a> Zzz<'a>;
}

impl<T> Bbb for T
where
    T: Aaa,
    T::Y: for<'a> Zzz<'a>,
{
    type B = T::Y;
}
```

The example will compile if the lifetime `'a` of `Zzz` and all the associated HRTBs for `Zzz` are removed.

### 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.
-->

Error occurs for both stable, beta, and nightly. Code was tested in the [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0dfbf8784b4e1d1806a87eb0d3124137).

Tested Versions:
stable: rustc 1.71.0 (8ede3aae2 2023-07-12) running on x86_64-unknown-linux-gnu
nightly: rustc 1.73.0-nightly (0e8e857b1 2023-07-16) running on x86_64-unknown-linux-gnu 

### Error output

```
'`Ok([Binder(TraitPredicate(<<T as Aaa>::Y as Zzz<'a>>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(ProjectionPredicate(AliasTy { substs: [<T as Aaa>::Y], def_id: DefId(0:6 ~ playground[90b5]::Xxx::X) }, Term::Ty(<<T as Aaa>::Y as Zzz<'a>>::Z)), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Xxx>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(ProjectionPredicate(AliasTy { substs: [<T as Aaa>::Y], def_id: DefId(0:4 ~ playground[90b5]::Www::W) }, Term::Ty(<<T as Aaa>::Y as Zzz<'_>>::Z)), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Www>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Yyy>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<T as Aaa>, polarity:Positive), []), Binder(TraitPredicate(<T as std::marker::Sized>, polarity:Positive), [])])` is not fully resolved', /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/compiler/rustc_infer/src/infer/mod.rs:1350:9
```

<!--
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>

```
   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at '`Ok([Binder { value: TraitPredicate(<<T as Aaa>::Y as Zzz<'a>>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: ProjectionPredicate(AliasTy { args: [<T as Aaa>::Y], def_id: DefId(0:6 ~ playground[4866]::Xxx::X) }, Term::Ty(<<T as Aaa>::Y as Zzz<'a>>::Z)), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<<T as Aaa>::Y as Xxx>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: ProjectionPredicate(AliasTy { args: [<T as Aaa>::Y], def_id: DefId(0:4 ~ playground[4866]::Www::W) }, Term::Ty(<<T as Aaa>::Y as Zzz<'_>>::Z)), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<<T as Aaa>::Y as Www>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<<T as Aaa>::Y as Yyy>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<T as Aaa>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }])` is not fully resolved', /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/compiler/rustc_infer/src/infer/mod.rs:1379:9
stack backtrace:
   0:     0x7f6a8800b1e1 - std::backtrace_rs::backtrace::libunwind::trace::h5f856d2c12cc6674
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f6a8800b1e1 - std::backtrace_rs::backtrace::trace_unsynchronized::h8449257397d4b934
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6a8800b1e1 - std::sys_common::backtrace::_print_fmt::hc0c3bab7873ac244
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f6a8800b1e1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3787c35683fa4233
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f6a8807119c - core::fmt::rt::Argument::fmt::hae0c3aa49888479e
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/fmt/rt.rs:138:9
   5:     0x7f6a8807119c - core::fmt::write::h0f833d45d904ecbb
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f6a87ffdb8e - std::io::Write::write_fmt::h6fd13360259fea22
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/io/mod.rs:1714:15
   7:     0x7f6a8800aff5 - std::sys_common::backtrace::_print::h715af68f97f33bd8
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f6a8800aff5 - std::sys_common::backtrace::print::h292b9e4a1d37eead
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f6a8800dda3 - std::panicking::default_hook::{{closure}}::hab7084ecbd5f7152
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:269:22
  10:     0x7f6a8800db34 - std::panicking::default_hook::hfbb8ba894af6577e
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:288:9
  11:     0x7f6a8b2d143b - rustc_driver_impl[5bf76b44b01c010b]::install_ice_hook::{closure#0}
  12:     0x7f6a8800e5ce - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc6428110305b5cbe
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2021:9
  13:     0x7f6a8800e5ce - std::panicking::rust_panic_with_hook::h8a8f983a7c12e89b
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:709:13
  14:     0x7f6a8800e357 - std::panicking::begin_panic_handler::{{closure}}::hcbc604b49027ff32
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:597:13
  15:     0x7f6a8800b646 - std::sys_common::backtrace::__rust_end_short_backtrace::hb85256103978a5ea
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f6a8800e0a2 - rust_begin_unwind
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:593:5
  17:     0x7f6a8806d543 - core::panicking::panic_fmt::h3cc36a41bb894309
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/panicking.rs:67:14
  18:     0x7f6a89be7ee2 - rustc_trait_selection[4828e09977927b86]::traits::normalize_param_env_or_error
  19:     0x7f6a89be2e0c - rustc_ty_utils[ff0a06d2a6228635]::ty::param_env
  20:     0x7f6a892f2474 - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::param_env::dynamic_query::{closure#2}::{closure#0}, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 8usize]>>
  21:     0x7f6a892f2440 - <rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::param_env::dynamic_query::{closure#2} as core[ef917bd033b821fa]::ops::function::FnOnce<(rustc_middle[835d091ebc4d05d9]::ty::context::TyCtxt, rustc_span[a69db53e102135]::def_id::DefId)>>::call_once
  22:     0x7f6a893197f5 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::<rustc_query_impl[2a0ca4be8ec05b8b]::DynamicConfig<rustc_query_system[95ed59712a59403e]::query::caches::DefaultCache<rustc_span[a69db53e102135]::def_id::DefId, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false>
  23:     0x7f6a8ac3e601 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::param_env::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f6a89ece0d0 - rustc_middle[835d091ebc4d05d9]::query::plumbing::query_get_at::<rustc_query_system[95ed59712a59403e]::query::caches::DefaultCache<rustc_span[a69db53e102135]::def_id::DefId, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 8usize]>>>
  25:     0x7f6a89ecc312 - rustc_hir_analysis[dc7bd52400bbf8cf]::check::wfcheck::check_well_formed
  26:     0x7f6a892e065c - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7f6a89d0a7f6 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::<rustc_query_impl[2a0ca4be8ec05b8b]::DynamicConfig<rustc_query_system[95ed59712a59403e]::query::caches::VecCache<rustc_hir[9bd7153587c508c5]::hir_id::OwnerId, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false>
  28:     0x7f6a89d0a562 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f6a8a6a0cdc - rustc_data_structures[d2b76f525e315882]::sync::par_for_each_in::<&[rustc_hir[9bd7153587c508c5]::hir::ImplItemId], <rustc_middle[835d091ebc4d05d9]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[dc7bd52400bbf8cf]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  30:     0x7f6a8a6a0b7a - rustc_hir_analysis[dc7bd52400bbf8cf]::check::wfcheck::check_mod_type_wf
  31:     0x7f6a89ff6bbc - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f6a89ff6b9e - <rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[ef917bd033b821fa]::ops::function::FnOnce<(rustc_middle[835d091ebc4d05d9]::ty::context::TyCtxt, rustc_span[a69db53e102135]::def_id::LocalDefId)>>::call_once
  33:     0x7f6a89c2b2ff - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::<rustc_query_impl[2a0ca4be8ec05b8b]::DynamicConfig<rustc_query_system[95ed59712a59403e]::query::caches::VecCache<rustc_span[a69db53e102135]::def_id::LocalDefId, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false>
  34:     0x7f6a8ac1a662 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f6a8a6f1f27 - rustc_data_structures[d2b76f525e315882]::sync::par_for_each_in::<&[rustc_hir[9bd7153587c508c5]::hir_id::OwnerId], <rustc_middle[835d091ebc4d05d9]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[dc7bd52400bbf8cf]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  36:     0x7f6a8a6f1cf7 - <rustc_session[2927e3ab783c954a]::session::Session>::track_errors::<rustc_hir_analysis[dc7bd52400bbf8cf]::check_crate::{closure#5}, ()>
  37:     0x7f6a8a6f0aa8 - rustc_hir_analysis[dc7bd52400bbf8cf]::check_crate
  38:     0x7f6a8a6f026a - rustc_interface[950bb6185283f172]::passes::analysis
  39:     0x7f6a8a752f2a - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 1usize]>>
  40:     0x7f6a8a752f19 - <rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::analysis::dynamic_query::{closure#2} as core[ef917bd033b821fa]::ops::function::FnOnce<(rustc_middle[835d091ebc4d05d9]::ty::context::TyCtxt, ())>>::call_once
  41:     0x7f6a8a91df48 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::<rustc_query_impl[2a0ca4be8ec05b8b]::DynamicConfig<rustc_query_system[95ed59712a59403e]::query::caches::SingleCache<rustc_middle[835d091ebc4d05d9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false>
  42:     0x7f6a8a91dd27 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7f6a8a5a2e85 - <rustc_middle[835d091ebc4d05d9]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>
  44:     0x7f6a8a5a24b2 - <rustc_interface[950bb6185283f172]::interface::Compiler>::enter::<rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}::{closure#2}, core[ef917bd033b821fa]::result::Result<core[ef917bd033b821fa]::option::Option<rustc_interface[950bb6185283f172]::queries::Linker>, rustc_span[a69db53e102135]::ErrorGuaranteed>>
  45:     0x7f6a8a59b825 - rustc_span[a69db53e102135]::set_source_map::<core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>, rustc_interface[950bb6185283f172]::interface::run_compiler<core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  46:     0x7f6a8a59b296 - <scoped_tls[af683b2dcd27050]::ScopedKey<rustc_span[a69db53e102135]::SessionGlobals>>::set::<rustc_interface[950bb6185283f172]::interface::run_compiler<core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>
  47:     0x7f6a8a59a85c - std[c0adc0b90f4efda2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[950bb6185283f172]::util::run_in_thread_pool_with_globals<rustc_interface[950bb6185283f172]::interface::run_compiler<core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>
  48:     0x7f6a8a59a61e - <<std[c0adc0b90f4efda2]::thread::Builder>::spawn_unchecked_<rustc_interface[950bb6185283f172]::util::run_in_thread_pool_with_globals<rustc_interface[950bb6185283f172]::interface::run_compiler<core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#1} as core[ef917bd033b821fa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f6a88018c55 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hee3992ac1361b768
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2007:9
  50:     0x7f6a88018c55 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h98eb33f4039b4e2e
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2007:9
  51:     0x7f6a88018c55 - std::sys::unix::thread::Thread::new::thread_start::h4a5bbbf722280c2f
                               at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7f6a87edf609 - start_thread
  53:     0x7f6a87e02133 - clone
  54:                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: rustc 1.73.0-nightly (0e8e857b1 2023-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [param_env] computing normalized predicates of `<impl at src/lib.rs:23:1: 23:18>`
#1 [check_well_formed] checking that `<impl at src/lib.rs:23:1: 23:18>` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
```

</p>
</details>