@@ -9,8 +9,8 @@ use air::ast_util::str_ident;
9
9
use rustc_ast:: { BindingMode , BorrowKind , IsAuto , Mutability } ;
10
10
use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
11
11
use rustc_hir:: {
12
- AssocItemKind , Block , BlockCheckMode , BodyId , Closure , Crate , Expr , ExprKind , FnSig , HirId ,
13
- Impl , ImplItem , ImplItemKind , ItemKind , LetExpr , LetStmt , MaybeOwner , Node , OpaqueTy ,
12
+ AssocItemKind , BinOpKind , Block , BlockCheckMode , BodyId , Closure , Crate , Expr , ExprKind , FnSig ,
13
+ HirId , Impl , ImplItem , ImplItemKind , ItemKind , LetExpr , LetStmt , MaybeOwner , Node , OpaqueTy ,
14
14
OpaqueTyOrigin , OwnerNode , Pat , PatKind , Safety , Stmt , StmtKind , TraitFn , TraitItem ,
15
15
TraitItemKind , TraitItemRef , UnOp ,
16
16
} ;
@@ -1479,9 +1479,26 @@ fn erase_expr<'tcx>(
1479
1479
_ => erase_spec_exps ( ctxt, state, expr, vec ! [ exp1] ) ,
1480
1480
}
1481
1481
}
1482
- ExprKind :: Binary ( _op, e1, e2) => {
1483
- let exp1 = erase_expr ( ctxt, state, expect_spec, e1) ;
1484
- let exp2 = erase_expr ( ctxt, state, expect_spec, e2) ;
1482
+ ExprKind :: Binary ( op, e1, e2) => {
1483
+ let mut exp1 = erase_expr ( ctxt, state, expect_spec, e1) ;
1484
+ let mut exp2 = erase_expr ( ctxt, state, expect_spec, e2) ;
1485
+ let use_ref = matches ! (
1486
+ op. node,
1487
+ BinOpKind :: Eq
1488
+ | BinOpKind :: Ne
1489
+ | BinOpKind :: Gt
1490
+ | BinOpKind :: Ge
1491
+ | BinOpKind :: Lt
1492
+ | BinOpKind :: Le
1493
+ ) ;
1494
+ if use_ref {
1495
+ if let Some ( e) = exp1 {
1496
+ exp1 = Some ( Box :: new ( ( e. 0 , ExpX :: AddrOf ( Mutability :: Not , e) ) ) )
1497
+ }
1498
+ if let Some ( e) = exp2 {
1499
+ exp2 = Some ( Box :: new ( ( e. 0 , ExpX :: AddrOf ( Mutability :: Not , e) ) ) )
1500
+ }
1501
+ }
1485
1502
erase_spec_exps ( ctxt, state, expr, vec ! [ exp1, exp2] )
1486
1503
}
1487
1504
ExprKind :: Index ( e1, e2, _span) => {
0 commit comments