Skip to content

Commit 3ec5d07

Browse files
committed
typeck/pat.rs: simplify peel_off_references.
1 parent 8b4114b commit 3ec5d07

File tree

1 file changed

+8
-14
lines changed
  • src/librustc_typeck/check

1 file changed

+8
-14
lines changed

src/librustc_typeck/check/pat.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -553,22 +553,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
553553
pat_adjustments.push(expected);
554554

555555
expected = inner_ty;
556-
def_bm = match def_bm {
556+
def_bm = ty::BindByReference(match def_bm {
557557
// If default binding mode is by value, make it `ref` or `ref mut`
558558
// (depending on whether we observe `&` or `&mut`).
559-
ty::BindByValue(_) =>
560-
ty::BindByReference(inner_mutability),
561-
562-
// Once a `ref`, always a `ref`. This is because a `& &mut` can't mutate
563-
// the underlying value.
564-
ty::BindByReference(hir::Mutability::MutImmutable) =>
565-
ty::BindByReference(hir::Mutability::MutImmutable),
566-
567-
// When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref`
568-
// (on `&`).
569-
ty::BindByReference(hir::Mutability::MutMutable) =>
570-
ty::BindByReference(inner_mutability),
571-
};
559+
ty::BindByValue(_) |
560+
// When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref` (on `&`).
561+
ty::BindByReference(hir::Mutability::MutMutable) => inner_mutability,
562+
// Once a `ref`, always a `ref`.
563+
// This is because a `& &mut` cannot mutate the underlying value.
564+
ty::BindByReference(m @ hir::Mutability::MutImmutable) => m,
565+
});
572566
}
573567

574568
if pat_adjustments.len() > 0 {

0 commit comments

Comments
 (0)