Repository: rust
Issue: ICE "... is not fully resolved'" with min_specialization and lifetime param
Labels: I-ICE,T-compiler,C-bug,F-specialization,glacier,S-bug-has-test

This ICEs with `#![feature(min_specialization)]`. Oddly enough, it does not ICE with `#![feature(specialization)]`, which is supposedly more unstable.

Found by fuzzing.

### edited: New example, still failing after #116663 (thanks @matthiaskrgr)

```rs
#![feature(min_specialization)]

trait MySpecTrait {
    fn f();
}

impl<'a, T: ?Sized> MySpecTrait for T {
    default fn f() {}
}

impl<'a, T: ?Sized> MySpecTrait for &'a T {
    fn f() {}
}

fn main() {}
```

### Code

```Rust
#![feature(min_specialization)]

trait Dance {}

impl<'a, T> Dance for T {}

impl Dance for bool {}

fn main() {}
```

### Error output

```
thread 'rustc' panicked at '`Ok(['_#0r, bool])` is not fully resolved', compiler/rustc_infer/src/infer/mod.rs:1473:9
```

<details><summary><strong>Full output with backtrace</strong></summary>
<p>

```
thread 'rustc' panicked at '`Ok(['_#0r, bool])` is not fully resolved', /rustc/0da281b6068a7d889ae89a9bd8991284cc9b7535/compiler/rustc_infer/src/infer/mod.rs:1473:9
stack backtrace:
   0:        0x1070c68a2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h98e7719cdb057d8f
   1:        0x10711e74a - core::fmt::write::he324e6f3a7ef7ed0
   2:        0x1070b897c - std::io::Write::write_fmt::h295c914c323e508a
   3:        0x1070c666a - std::sys_common::backtrace::print::hb2f2bd76d0a1d9b2
   4:        0x1070c9a76 - std::panicking::default_hook::{{closure}}::h7f2a23a911934152
   5:        0x1070c97c7 - std::panicking::default_hook::h576cf5867894044c
   6:        0x114b9f62d - rustc_driver[ba5c792b9438c2b]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x1070ca271 - std::panicking::rust_panic_with_hook::hf0781b554a936fbf
   8:        0x1070ca003 - std::panicking::begin_panic_handler::{{closure}}::h8d2525e276d552d8
   9:        0x1070c6d38 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3badbbd5492e2d6
  10:        0x1070c9ccd - _rust_begin_unwind
  11:        0x10714b1b3 - core::panicking::panic_fmt::h15d4409e62dc090a
  12:        0x11757859f - <rustc_infer[b40902abbc4e8850]::infer::InferCtxt>::fully_resolve::<&rustc_middle[298407787cc28eff]::ty::list::List<rustc_middle[298407787cc28eff]::ty::subst::GenericArg>>
  13:        0x1175fee24 - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::min_specialization::check_always_applicable
  14:        0x1175fe8da - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::min_specialization::check_min_specialization
  15:        0x1175aaf07 - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::check_mod_impl_wf
  16:        0x11838d855 - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<rustc_span[73e074df7cba0abf]::def_id::LocalDefId, ()>>
  17:        0x11847c845 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::check_mod_impl_wf, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  18:        0x117611608 - <rustc_middle[298407787cc28eff]::hir::map::Map>::for_each_module::<rustc_hir_analysis[3f5a3f8b91adb05]::check_crate::{closure#2}::{closure#0}::{closure#0}>
  19:        0x1176027d1 - <rustc_session[43d2d941ace548e5]::session::Session>::track_errors::<rustc_hir_analysis[3f5a3f8b91adb05]::check_crate::{closure#2}, ()>
  20:        0x1175b22fb - rustc_hir_analysis[3f5a3f8b91adb05]::check_crate
  21:        0x114c77fda - rustc_interface[a666f6d755ed9279]::passes::analysis
  22:        0x11841026c - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<(), core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>>
  23:        0x11848a3f9 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::analysis, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  24:        0x114b2e296 - <rustc_interface[a666f6d755ed9279]::passes::QueryContext>::enter::<rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  25:        0x114b72a4d - rustc_span[73e074df7cba0abf]::with_source_map::<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  26:        0x114b6234c - <scoped_tls[c17fceff1b2b43d8]::ScopedKey<rustc_span[73e074df7cba0abf]::SessionGlobals>>::set::<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  27:        0x114b31e5a - std[8878bd7dd366d71b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  28:        0x114b17f7b - <<std[8878bd7dd366d71b]::thread::Builder>::spawn_unchecked_<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#1} as core[13371b8ce97f01bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:        0x1070d3387 - std::sys::unix::thread::Thread::new::thread_start::hfd54df40dd14130e
  30:     0x7ff814d514e1 - __pthread_start

error: internal compiler error: unexpected panic

note: 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.66.0-nightly (0da281b60 2022-10-27) running on x86_64-apple-darwin

query stack during panic:
#0 [check_mod_impl_wf] checking that impls are well-formed in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
```

</p>
</details>

### Regression

Bisected to 6365e5ad9fa9e2ec867a67aeeae414e7c62d8354 (#102903, @compiler-errors).

But that's just when the assertion was added.

<details><summary>Bisection details</summary>

searched nightlies: from nightly-2022-10-26 to nightly-2022-10-28
regressed nightly: nightly-2022-10-27
searched commit range: https://github.com/rust-lang/rust/compare/bed4ad65bf7a1cef39e3d66b3670189581b3b073...1898c34e923bad763e723c68dd9f23a09f9eb0fc
regressed commit: https://github.com/rust-lang/rust/commit/6365e5ad9fa9e2ec867a67aeeae414e7c62d8354

bisected with <a href='https://github.com/rust-lang/cargo-bisect-rustc'>cargo-bisect-rustc</a> v0.6.4

Host triple: x86_64-apple-darwin

</details>

### Version

`rustc --version --verbose`:
```
rustc 1.66.0-nightly (0da281b60 2022-10-27)
binary: rustc
commit-hash: 0da281b6068a7d889ae89a9bd8991284cc9b7535
commit-date: 2022-10-27
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
```