@@ -130,13 +130,14 @@ enum AdjustMode {
130
130
/// Peel off all immediate reference types.
131
131
Peel ,
132
132
/// Reset binding mode to the initial mode.
133
+ /// Used for destructuring assignment, where we don't want any match ergonomics.
133
134
Reset ,
134
135
/// Produced by ref patterns.
135
136
/// Reset the binding mode to the initial mode,
136
137
/// and if the old biding mode was by-reference
137
138
/// with mutability matching the pattern,
138
139
/// mark the pattern as having consumed this reference.
139
- RefReset ( Mutability ) ,
140
+ ResetAndConsumeRef ( Mutability ) ,
140
141
/// Pass on the input binding mode and expected type.
141
142
Pass ,
142
143
}
@@ -292,7 +293,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
292
293
match adjust_mode {
293
294
AdjustMode :: Pass => ( expected, def_bm, false ) ,
294
295
AdjustMode :: Reset => ( expected, INITIAL_BM , false ) ,
295
- AdjustMode :: RefReset ( mutbl) => ( expected, INITIAL_BM , def_bm. 0 == ByRef :: Yes ( mutbl) ) ,
296
+ AdjustMode :: ResetAndConsumeRef ( mutbl) => {
297
+ ( expected, INITIAL_BM , def_bm. 0 == ByRef :: Yes ( mutbl) )
298
+ }
296
299
AdjustMode :: Peel => {
297
300
let peeled = self . peel_off_references ( pat, expected, def_bm) ;
298
301
( peeled. 0 , peeled. 1 , false )
@@ -351,7 +354,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
351
354
// ```
352
355
//
353
356
// See issue #46688.
354
- PatKind :: Ref ( _, mutbl) => AdjustMode :: RefReset ( * mutbl) ,
357
+ PatKind :: Ref ( _, mutbl) => AdjustMode :: ResetAndConsumeRef ( * mutbl) ,
355
358
// A `_` pattern works with any expected type, so there's no need to do anything.
356
359
PatKind :: Wild
357
360
// A malformed pattern doesn't have an expected type, so let's just accept any type.
0 commit comments