Skip to content

Commit

Permalink
analyze: rewrite::unlower: remove self arg from fn is_var
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed May 30, 2023
1 parent cda2242 commit b3c59ae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions c2rust-analyze/src/rewrite/expr/unlower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ impl<'a, 'tcx> UnlowerVisitor<'a, 'tcx> {
false
}

fn is_var(&self, pl: mir::Place<'tcx>) -> bool {
pl.projection.len() == 0
}

fn visit_expr_inner(&mut self, ex: &'tcx hir::Expr<'tcx>) {
let _g = panic_detail::set_current_span(ex.span);

Expand Down Expand Up @@ -188,7 +184,7 @@ impl<'a, 'tcx> UnlowerVisitor<'a, 'tcx> {

hir::ExprKind::Call(_, args) | hir::ExprKind::MethodCall(_, args, _) => {
let (loc, _mir_pl, _mir_func, mir_args) = match self.get_last_call(&locs) {
Some(x @ (_, pl, _, _)) if self.is_var(pl) => x,
Some(x @ (_, pl, _, _)) if is_var(pl) => x,
_ => {
warn("expected final Call to store into var");
return;
Expand All @@ -210,7 +206,7 @@ impl<'a, 'tcx> UnlowerVisitor<'a, 'tcx> {
// For all other `ExprKind`s, we expect the last `loc` to be an assignment storing
// the final result into a temporary.
let (loc, _mir_pl, mir_rv) = match self.get_last_assign(&locs) {
Some(x @ (_, pl, _)) if self.is_var(pl) => x,
Some(x @ (_, pl, _)) if is_var(pl) => x,
_ => {
warn("expected final Assign to store into var");
return;
Expand Down Expand Up @@ -257,6 +253,10 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnlowerVisitor<'a, 'tcx> {
}
}

fn is_var(pl: mir::Place) -> bool {
pl.projection.len() == 0
}

/// Builds the *unlowering map*, which maps each piece of the MIR to the HIR `Expr` that was
/// lowered to produce it.
///
Expand Down

0 comments on commit b3c59ae

Please sign in to comment.