1
Fork 0

Address review comments

This commit is contained in:
Jules Bertholet 2024-04-02 10:54:29 -05:00
parent f37a4d55ee
commit 9d200f2d88
No known key found for this signature in database
GPG key ID: 32034DAFC38C1BFC
11 changed files with 55 additions and 33 deletions

View file

@ -65,16 +65,16 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
// we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the
// adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted
// gets the least-dereferenced type).
let unadjusted = if self.typeck_results.ref_pats_that_dont_deref().contains(pat.hir_id) {
match pat.kind {
hir::PatKind::Ref(inner, _) => self.lower_pattern_unadjusted(inner),
_ => span_bug!(pat.span, "non ref pattern marked as non-deref ref pattern"),
let unadjusted_pat = match pat.kind {
hir::PatKind::Ref(inner, _)
if self.typeck_results.skipped_ref_pats().contains(pat.hir_id) =>
{
self.lower_pattern_unadjusted(inner)
}
} else {
self.lower_pattern_unadjusted(pat)
_ => self.lower_pattern_unadjusted(pat),
};
self.typeck_results.pat_adjustments().get(pat.hir_id).unwrap_or(&vec![]).iter().rev().fold(
unadjusted,
unadjusted_pat,
|pat: Box<_>, ref_ty| {
debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty);
Box::new(Pat {