Rollup merge of #133558 - compiler-errors:structurally-resolve-probe-adt, r=lcnr

Structurally resolve in `probe_adt`

fixes #132320

r? lcnr
This commit is contained in:
Matthias Krüger 2024-12-03 17:27:07 +01:00 committed by GitHub
commit 49df325cb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 16 deletions

View File

@ -307,7 +307,11 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _)
if !ty.has_escaping_bound_vars() =>
{
self.normalize(span, ty).ty_adt_def()
if self.next_trait_solver() {
self.try_structurally_resolve_type(span, ty).ty_adt_def()
} else {
self.normalize(span, ty).ty_adt_def()
}
}
_ => None,
}

View File

@ -1,15 +0,0 @@
//@ known-bug: #132320
//@ compile-flags: -Znext-solver=globally
trait Foo {
type Item;
fn foo(&mut self);
}
impl Foo for () {
type Item = Option<()>;
fn foo(&mut self) {
let _ = Self::Item::None;
}
}

View File

@ -0,0 +1,15 @@
//@ check-pass
//@ compile-flags: -Znext-solver
trait Mirror {
type Assoc;
}
impl<T> Mirror for T {
type Assoc = T;
}
type Foo<T> = <Option<T> as Mirror>::Assoc;
fn main() {
let x = Foo::<i32>::None;
}