let assign_expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
let op_kind = assign_expr.op_kind()?;
- if op_kind != ast::BinOp::Assignment {
+ if op_kind != (ast::BinaryOp::Assignment { op: None }) {
cov_mark::hit!(test_cant_pull_non_assignments);
return None;
}
let assignments: Vec<_> = collector
.assignments
.into_iter()
- .map(|(stmt, rhs)| (edit.make_ast_mut(stmt), rhs.clone_for_update()))
+ .map(|(stmt, rhs)| (edit.make_mut(stmt), rhs.clone_for_update()))
.collect();
- let tgt = edit.make_ast_mut(tgt);
+ let tgt = edit.make_mut(tgt);
for (stmt, rhs) in assignments {
let mut stmt = stmt.syntax().clone();
}
}
fn collect_block(&mut self, block: &ast::BlockExpr) -> Option<()> {
- let last_expr = block.tail_expr().or_else(|| {
- if let ast::Stmt::ExprStmt(stmt) = block.statements().last()? {
- stmt.expr()
- } else {
- None
- }
+ let last_expr = block.tail_expr().or_else(|| match block.statements().last()? {
+ ast::Stmt::ExprStmt(stmt) => stmt.expr(),
+ ast::Stmt::Item(_) | ast::Stmt::LetStmt(_) => None,
})?;
if let ast::Expr::BinExpr(expr) = last_expr {
}
fn collect_expr(&mut self, expr: &ast::BinExpr) -> Option<()> {
- if expr.op_kind()? == ast::BinOp::Assignment
+ if expr.op_kind()? == (ast::BinaryOp::Assignment { op: None })
&& is_equivalent(self.sema, &expr.lhs()?, &self.common_lhs)
{
self.assignments.push((expr.clone(), expr.rhs()?));
}
}
(ast::Expr::PrefixExpr(prefix0), ast::Expr::PrefixExpr(prefix1))
- if prefix0.op_kind() == Some(ast::PrefixOp::Deref)
- && prefix1.op_kind() == Some(ast::PrefixOp::Deref) =>
+ if prefix0.op_kind() == Some(ast::UnaryOp::Deref)
+ && prefix1.op_kind() == Some(ast::UnaryOp::Deref) =>
{
cov_mark::hit!(test_pull_assignment_up_deref);
if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) {