Skip to content

Commit ceda39e

Browse files
committed
refactor: bypass invalidation of CallExpr and take CallExpr via Stmt
this is more straightforward way
1 parent 05a90f9 commit ceda39e

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/lib.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct TransformVisitor {
3131
}
3232

3333
impl TransformVisitor {
34-
fn is_removal_target(&mut self, call_expr: &mut CallExpr) -> bool {
34+
fn is_removal_target(&mut self, call_expr: &CallExpr) -> bool {
3535
match call_expr.callee {
3636
Callee::Expr(ref expr) => {
3737
match expr.as_ref() {
@@ -97,30 +97,14 @@ impl VisitMut for TransformVisitor {
9797
});
9898
}
9999

100-
fn visit_mut_expr_stmt(&mut self, n: &mut ExprStmt) {
100+
fn visit_mut_stmt(&mut self, n: &mut Stmt) {
101101
if self.target_variables.is_empty() {
102102
n.visit_mut_children_with(self);
103103
return;
104104
}
105-
match n.expr.as_mut() {
106-
Expr::Call(call_expr) => {
107-
if self.is_removal_target(call_expr) {
108-
call_expr.take();
109-
} else {
110-
n.visit_mut_children_with(self);
111-
}
112-
},
113-
_ => {
114-
n.visit_mut_children_with(self);
115-
}
116-
}
117-
}
118-
119-
fn visit_mut_stmt(&mut self, n: &mut Stmt) {
120-
n.visit_mut_children_with(self);
121105
if let Stmt::Expr(ExprStmt{ expr, ..}) = n {
122106
if let Expr::Call(call_expr) = expr.as_ref() {
123-
if *call_expr == CallExpr::dummy() {
107+
if self.is_removal_target(call_expr) {
124108
n.take();
125109
}
126110
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy