diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-03 17:27:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-03 17:27:07 +0100 |
| commit | 49df325cb42c409db13f689a5ff3cc5d7e6627f2 (patch) | |
| tree | a3c3a8c8f44ca6110f499b3b6937f8bc3c39feac | |
| parent | 453a1a8b7ff049e697bbd15aad2d4674b2825768 (diff) | |
| parent | 0609b999681f9c807554bffe838288bda7efa3f1 (diff) | |
| download | rust-49df325cb42c409db13f689a5ff3cc5d7e6627f2.tar.gz rust-49df325cb42c409db13f689a5ff3cc5d7e6627f2.zip | |
Rollup merge of #133558 - compiler-errors:structurally-resolve-probe-adt, r=lcnr
Structurally resolve in `probe_adt` fixes #132320 r? lcnr
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 6 | ||||
| -rw-r--r-- | tests/crashes/132320.rs | 15 | ||||
| -rw-r--r-- | tests/ui/traits/next-solver/typeck/structurally-resolve-in-probe_adt.rs | 15 |
3 files changed, 20 insertions, 16 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 3940d138deb..aacdcf027b6 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -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, } diff --git a/tests/crashes/132320.rs b/tests/crashes/132320.rs deleted file mode 100644 index 79181c3a2c5..00000000000 --- 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 00000000000..23915808279 --- /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<T> Mirror for T { + type Assoc = T; +} + +type Foo<T> = <Option<T> as Mirror>::Assoc; + +fn main() { + let x = Foo::<i32>::None; +} |
