Skip to content

Commit 5d8f9c8

Browse files
authored
Rollup merge of #155043 - malezjaa:refactor-typecheck-op, r=adwinwhite
Fix if branch in op.rs I removed the if guard without thinking in #154223. Really sorry about this. r? @hkBst
2 parents ddf6fae + d024e57 commit 5d8f9c8

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

  • compiler/rustc_hir_typeck/src

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
294294
self.apply_adjustments(lhs_expr, vec![autoref]);
295295
}
296296

297-
if let ty::Ref(_, _, mutbl) = method.sig.inputs()[1].kind() {
298-
// Allow two-phase borrows for binops in initial deployment
299-
// since they desugar to methods
300-
let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes);
301-
let autoref = Adjustment {
302-
kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)),
303-
target: method.sig.inputs()[1],
304-
};
305-
// HACK(eddyb) Bypass checks due to reborrows being in
306-
// some cases applied on the RHS, on top of which we need
307-
// to autoref, which is not allowed by apply_adjustments.
308-
// self.apply_adjustments(rhs_expr, vec![autoref]);
309-
self.typeck_results
310-
.borrow_mut()
311-
.adjustments_mut()
312-
.entry(rhs_expr.hir_id)
313-
.or_default()
314-
.push(autoref);
297+
if by_ref_binop {
298+
if let ty::Ref(_, _, mutbl) = method.sig.inputs()[1].kind() {
299+
// Allow two-phase borrows for binops in initial deployment
300+
// since they desugar to methods
301+
let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes);
302+
let autoref = Adjustment {
303+
kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)),
304+
target: method.sig.inputs()[1],
305+
};
306+
// HACK(eddyb) Bypass checks due to reborrows being in
307+
// some cases applied on the RHS, on top of which we need
308+
// to autoref, which is not allowed by apply_adjustments.
309+
// self.apply_adjustments(rhs_expr, vec![autoref]);
310+
self.typeck_results
311+
.borrow_mut()
312+
.adjustments_mut()
313+
.entry(rhs_expr.hir_id)
314+
.or_default()
315+
.push(autoref);
316+
}
315317
}
316318
}
317319

0 commit comments

Comments
 (0)