about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-27 22:23:26 +0100
committerGitHub <noreply@github.com>2024-11-27 22:23:26 +0100
commit5fc4f85f60f9b1169bddf62d4f23340d81f14a0a (patch)
tree02afdff8e02e17028859a3dea79ec0302a935762 /compiler
parent5d0ee56e883249bee1ead06d3476cd054c388c4b (diff)
parent48b2bbd0dedae98abf7a124dfa409efb5554e7a3 (diff)
downloadrust-5fc4f85f60f9b1169bddf62d4f23340d81f14a0a.tar.gz
rust-5fc4f85f60f9b1169bddf62d4f23340d81f14a0a.zip
Rollup merge of #133521 - compiler-errors:structurally-resolve-cat-proj, r=lcnr
Structurally resolve before matching on type of projection

Another missing structural resolve in closure upvar analysis. I think it's better to place the normalization here rather than trying to guarantee that all types returned by the expr use visitor are structurally normalized, which I don't think we do now. Thoughts?

r? lcnr
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/upvar.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs
index d50eff0deb0..b0c020dd7cb 100644
--- a/compiler/rustc_hir_typeck/src/upvar.rs
+++ b/compiler/rustc_hir_typeck/src/upvar.rs
@@ -1802,7 +1802,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         let mut is_mutbl = bm.1;
 
         for pointer_ty in place.deref_tys() {
-            match pointer_ty.kind() {
+            match self.structurally_resolve_type(self.tcx.hir().span(var_hir_id), pointer_ty).kind()
+            {
                 // We don't capture derefs of raw ptrs
                 ty::RawPtr(_, _) => unreachable!(),
 
@@ -1816,7 +1817,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 // Dereferencing a box doesn't change mutability
                 ty::Adt(def, ..) if def.is_box() => {}
 
-                unexpected_ty => bug!("deref of unexpected pointer type {:?}", unexpected_ty),
+                unexpected_ty => span_bug!(
+                    self.tcx.hir().span(var_hir_id),
+                    "deref of unexpected pointer type {:?}",
+                    unexpected_ty
+                ),
             }
         }