diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-23 15:55:35 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-24 19:14:59 +0200 |
| commit | 3ec5d07b1d30124e85cd804a74f1b03198cce1f5 (patch) | |
| tree | cb8b94decc2dc0c68d3c766ffc7d76daad7a2775 | |
| parent | 8b4114b0d4975bde6df41dd9c8a41e44033da221 (diff) | |
| download | rust-3ec5d07b1d30124e85cd804a74f1b03198cce1f5.tar.gz rust-3ec5d07b1d30124e85cd804a74f1b03198cce1f5.zip | |
typeck/pat.rs: simplify `peel_off_references`.
| -rw-r--r-- | src/librustc_typeck/check/pat.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 625c57356af..ce033b85fce 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -553,22 +553,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat_adjustments.push(expected); expected = inner_ty; - def_bm = match def_bm { + def_bm = ty::BindByReference(match def_bm { // If default binding mode is by value, make it `ref` or `ref mut` // (depending on whether we observe `&` or `&mut`). - ty::BindByValue(_) => - ty::BindByReference(inner_mutability), - - // Once a `ref`, always a `ref`. This is because a `& &mut` can't mutate - // the underlying value. - ty::BindByReference(hir::Mutability::MutImmutable) => - ty::BindByReference(hir::Mutability::MutImmutable), - - // When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref` - // (on `&`). - ty::BindByReference(hir::Mutability::MutMutable) => - ty::BindByReference(inner_mutability), - }; + ty::BindByValue(_) | + // When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref` (on `&`). + ty::BindByReference(hir::Mutability::MutMutable) => inner_mutability, + // Once a `ref`, always a `ref`. + // This is because a `& &mut` cannot mutate the underlying value. + ty::BindByReference(m @ hir::Mutability::MutImmutable) => m, + }); } if pat_adjustments.len() > 0 { |
