From a8df969c3f9504f77faefc3dafa19de77d31e2dc Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 28 Nov 2024 00:58:05 +0000 Subject: [PATCH] Structurally resolve in probe_adt --- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 2 +- tests/crashes/132320.rs | 15 --------------- .../typeck/structurally-resolve-in-probe_adt.rs | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 tests/crashes/132320.rs create mode 100644 tests/ui/traits/next-solver/typeck/structurally-resolve-in-probe_adt.rs diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 3940d138deb0a..cea1b268a5e7d 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -307,7 +307,7 @@ 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() + self.try_structurally_resolve_type(span, ty).ty_adt_def() } _ => None, } diff --git a/tests/crashes/132320.rs b/tests/crashes/132320.rs deleted file mode 100644 index 79181c3a2c522..0000000000000 --- a/tests/crashes/132320.rs +++ /dev/null @@ -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; - } -} diff --git a/tests/ui/traits/next-solver/typeck/structurally-resolve-in-probe_adt.rs b/tests/ui/traits/next-solver/typeck/structurally-resolve-in-probe_adt.rs new file mode 100644 index 0000000000000..23915808279a5 --- /dev/null +++ b/tests/ui/traits/next-solver/typeck/structurally-resolve-in-probe_adt.rs @@ -0,0 +1,15 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +trait Mirror { + type Assoc; +} +impl Mirror for T { + type Assoc = T; +} + +type Foo = as Mirror>::Assoc; + +fn main() { + let x = Foo::::None; +}