@@ -263,14 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263263 let by_ref_binop = !op. node . is_by_value ( ) ;
264264 if is_assign == IsAssign :: Yes || by_ref_binop {
265265 if let ty:: Ref ( region, _, mutbl) = method. sig . inputs ( ) [ 0 ] . kind ( ) {
266- let mutbl = match mutbl {
267- hir:: Mutability :: Not => AutoBorrowMutability :: Not ,
268- hir:: Mutability :: Mut => AutoBorrowMutability :: Mut {
269- // Allow two-phase borrows for binops in initial deployment
270- // since they desugar to methods
271- allow_two_phase_borrow : AllowTwoPhase :: Yes ,
272- } ,
273- } ;
266+ let mutbl = AutoBorrowMutability :: new ( * mutbl, AllowTwoPhase :: Yes ) ;
274267 let autoref = Adjustment {
275268 kind : Adjust :: Borrow ( AutoBorrow :: Ref ( * region, mutbl) ) ,
276269 target : method. sig . inputs ( ) [ 0 ] ,
@@ -280,14 +273,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
280273 }
281274 if by_ref_binop {
282275 if let ty:: Ref ( region, _, mutbl) = method. sig . inputs ( ) [ 1 ] . kind ( ) {
283- let mutbl = match mutbl {
284- hir:: Mutability :: Not => AutoBorrowMutability :: Not ,
285- hir:: Mutability :: Mut => AutoBorrowMutability :: Mut {
286- // Allow two-phase borrows for binops in initial deployment
287- // since they desugar to methods
288- allow_two_phase_borrow : AllowTwoPhase :: Yes ,
289- } ,
290- } ;
276+ // Allow two-phase borrows for binops in initial deployment
277+ // since they desugar to methods
278+ let mutbl = AutoBorrowMutability :: new ( * mutbl, AllowTwoPhase :: Yes ) ;
279+
291280 let autoref = Adjustment {
292281 kind : Adjust :: Borrow ( AutoBorrow :: Ref ( * region, mutbl) ) ,
293282 target : method. sig . inputs ( ) [ 1 ] ,
0 commit comments