diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2025-04-06 14:38:16 +0200 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2025-04-08 23:26:48 +0200 |
| commit | 9f57903e9cdafda3e32ce0e3472ad7fe2a9c1e3a (patch) | |
| tree | b29285fb758ae6df9125d5a4e8a6ac2ad0fe1c61 | |
| parent | a0d9c8726678fdc6a43d51e388e1a92e388d5fc2 (diff) | |
| download | rust-9f57903e9cdafda3e32ce0e3472ad7fe2a9c1e3a.tar.gz rust-9f57903e9cdafda3e32ce0e3472ad7fe2a9c1e3a.zip | |
Insert adjustments incrementally
| -rw-r--r-- | compiler/rustc_hir_typeck/src/pat.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index e6e262279cd..70eb21ca356 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -354,13 +354,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // type into the adjustments vector. // // See the examples in `ui/match-defbm*.rs`. - let mut pat_adjustments = vec![]; while let ty::Ref(_, inner_ty, inner_mutability) = *expected.kind() { debug!("inspecting {:?}", expected); debug!("current discriminant is Ref, inserting implicit deref"); // Preserve the reference type. We'll need it later during THIR lowering. - pat_adjustments.push(expected); + self.typeck_results + .borrow_mut() + .pat_adjustments_mut() + .entry(pat.hir_id) + .or_default() + .push(expected); expected = self.try_structurally_resolve_type(pat.span, inner_ty); binding_mode = ByRef::Yes(match binding_mode { @@ -382,13 +386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { max_ref_mutbl = MutblCap::Not; } - if !pat_adjustments.is_empty() { - debug!("default binding mode is now {:?}", binding_mode); - self.typeck_results - .borrow_mut() - .pat_adjustments_mut() - .insert(pat.hir_id, pat_adjustments); - } + debug!("default binding mode is now {:?}", binding_mode); (expected, binding_mode, max_ref_mutbl) } |
