Skip to content

Commit 3c043af

Browse files
committed
fix lifetime error for cmp ops
1 parent ce4f8e0 commit 3c043af

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

source/rust_verify/src/lifetime_generate.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use air::ast_util::str_ident;
99
use rustc_ast::{BindingMode, BorrowKind, IsAuto, Mutability};
1010
use rustc_hir::def::{CtorKind, DefKind, Res};
1111
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,
1414
OpaqueTyOrigin, OwnerNode, Pat, PatKind, Safety, Stmt, StmtKind, TraitFn, TraitItem,
1515
TraitItemKind, TraitItemRef, UnOp,
1616
};
@@ -1479,9 +1479,26 @@ fn erase_expr<'tcx>(
14791479
_ => erase_spec_exps(ctxt, state, expr, vec![exp1]),
14801480
}
14811481
}
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+
}
14851502
erase_spec_exps(ctxt, state, expr, vec![exp1, exp2])
14861503
}
14871504
ExprKind::Index(e1, e2, _span) => {

0 commit comments

Comments
 (0)