Skip to content

Commit f458151

Browse files
committed
Remove redundant assignment
1 parent 6588018 commit f458151

File tree

1 file changed

+5
-17
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+5
-17
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
380380
expected: Ty<'tcx>,
381381
pat_info: PatInfo<'tcx>,
382382
) -> Ty<'tcx> {
383-
let PatInfo { mut binding_mode, mut max_ref_mutbl, current_depth, .. } = pat_info;
384383
#[cfg(debug_assertions)]
385-
if binding_mode == ByRef::Yes(Mutability::Mut)
386-
&& max_ref_mutbl != MutblCap::Mut
384+
if pat_info.binding_mode == ByRef::Yes(Mutability::Mut)
385+
&& pat_info.max_ref_mutbl != MutblCap::Mut
387386
&& self.downgrade_mut_inside_shared()
388387
{
389388
span_bug!(pat.span, "Pattern mutability cap violated!");
390389
}
391390

392-
if !pat.default_binding_modes {
393-
// When we perform destructuring assignment, we disable default match bindings, which
394-
// are unintuitive in this context.
395-
binding_mode = ByRef::No;
396-
max_ref_mutbl = MutblCap::Mut;
397-
};
398391
// Resolve type if needed.
399392
let expected = if let AdjustMode::Peel = adjust_mode
400393
&& pat.default_binding_modes
@@ -404,13 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
404397
expected
405398
};
406399
let old_pat_info = pat_info;
407-
let pat_info = PatInfo {
408-
binding_mode,
409-
max_ref_mutbl,
410-
current_depth: current_depth + 1,
411-
top_info: old_pat_info.top_info,
412-
decl_origin: old_pat_info.decl_origin,
413-
};
400+
let pat_info = PatInfo { current_depth: old_pat_info.current_depth + 1, ..old_pat_info };
414401

415402
match pat.kind {
416403
// Peel off a `&` or `&mut` from the scrutinee type. See the examples in
@@ -430,7 +417,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
430417
.or_default()
431418
.push(expected);
432419

433-
binding_mode = ByRef::Yes(match binding_mode {
420+
let mut binding_mode = ByRef::Yes(match pat_info.binding_mode {
434421
// If default binding mode is by value, make it `ref` or `ref mut`
435422
// (depending on whether we observe `&` or `&mut`).
436423
ByRef::No |
@@ -441,6 +428,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
441428
ByRef::Yes(Mutability::Not) => Mutability::Not,
442429
});
443430

431+
let mut max_ref_mutbl = pat_info.max_ref_mutbl;
444432
if self.downgrade_mut_inside_shared() {
445433
binding_mode = binding_mode.cap_ref_mutability(max_ref_mutbl.as_mutbl());
446434
}

0 commit comments

Comments
 (0)