@@ -380,21 +380,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
380
380
expected : Ty < ' tcx > ,
381
381
pat_info : PatInfo < ' tcx > ,
382
382
) -> Ty < ' tcx > {
383
- let PatInfo { mut binding_mode, mut max_ref_mutbl, current_depth, .. } = pat_info;
384
383
#[ 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
387
386
&& self . downgrade_mut_inside_shared ( )
388
387
{
389
388
span_bug ! ( pat. span, "Pattern mutability cap violated!" ) ;
390
389
}
391
390
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
- } ;
398
391
// Resolve type if needed.
399
392
let expected = if let AdjustMode :: Peel = adjust_mode
400
393
&& pat. default_binding_modes
@@ -404,13 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
404
397
expected
405
398
} ;
406
399
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 } ;
414
401
415
402
match pat. kind {
416
403
// Peel off a `&` or `&mut` from the scrutinee type. See the examples in
@@ -430,7 +417,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
430
417
. or_default ( )
431
418
. push ( expected) ;
432
419
433
- binding_mode = ByRef :: Yes ( match binding_mode {
420
+ let mut binding_mode = ByRef :: Yes ( match pat_info . binding_mode {
434
421
// If default binding mode is by value, make it `ref` or `ref mut`
435
422
// (depending on whether we observe `&` or `&mut`).
436
423
ByRef :: No |
@@ -441,6 +428,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
441
428
ByRef :: Yes ( Mutability :: Not ) => Mutability :: Not ,
442
429
} ) ;
443
430
431
+ let mut max_ref_mutbl = pat_info. max_ref_mutbl ;
444
432
if self . downgrade_mut_inside_shared ( ) {
445
433
binding_mode = binding_mode. cap_ref_mutability ( max_ref_mutbl. as_mutbl ( ) ) ;
446
434
}
0 commit comments