Box in stmt is no longer required
diff --git a/examples/trace-var/trace-var/src/lib.rs b/examples/trace-var/trace-var/src/lib.rs
index ec06cde..01db7f4 100644
--- a/examples/trace-var/trace-var/src/lib.rs
+++ b/examples/trace-var/trace-var/src/lib.rs
@@ -148,9 +148,9 @@
match s {
Stmt::Local(s) => {
if s.init.is_some() && self.should_print_pat(&s.pat) {
- self.let_and_print(*s)
+ self.let_and_print(s)
} else {
- Stmt::Local(Box::new(fold::fold_local(self, *s)))
+ Stmt::Local(fold::fold_local(self, s))
}
}
_ => fold::fold_stmt(self, s),
diff --git a/src/expr.rs b/src/expr.rs
index 8cab97d..b019231 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -572,16 +572,16 @@
/// A statement, usually ending in a semicolon.
pub enum Stmt {
/// A local (let) binding.
- Local(Box<Local>),
+ Local(Local),
/// An item definition.
- Item(Box<Item>),
+ Item(Item),
/// Expr without trailing semicolon.
- Expr(Box<Expr>),
+ Expr(Expr),
/// Expression with trailing semicolon;
- Semi(Box<Expr>, Token![;]),
+ Semi(Expr, Token![;]),
}
}
@@ -2080,7 +2080,7 @@
mut e: syn!(Expr) >>
({
e.replace_attrs(attrs);
- Stmt::Expr(Box::new(e))
+ Stmt::Expr(e)
})
)) >>
(match last {
@@ -2121,7 +2121,7 @@
// expression statements
data: braces!(syn!(TokenStream)) >>
semi: option!(punct!(;)) >>
- (Stmt::Item(Box::new(Item::Macro(ItemMacro {
+ (Stmt::Item(Item::Macro(ItemMacro {
attrs: attrs,
ident: None,
mac: Macro {
@@ -2131,7 +2131,7 @@
tts: data.1,
},
semi_token: semi,
- }))))
+ })))
));
#[cfg(feature = "full")]
@@ -2142,18 +2142,18 @@
ty: option!(tuple!(punct!(:), syn!(Type))) >>
init: option!(tuple!(punct!(=), syn!(Expr))) >>
semi: punct!(;) >>
- (Stmt::Local(Box::new(Local {
+ (Stmt::Local(Local {
attrs: attrs,
let_token: let_,
pat: Box::new(pat),
ty: ty.map(|(colon, ty)| (colon, Box::new(ty))),
init: init.map(|(eq, expr)| (eq, Box::new(expr))),
semi_token: semi,
- })))
+ }))
));
#[cfg(feature = "full")]
- named!(stmt_item -> Stmt, map!(syn!(Item), |i| Stmt::Item(Box::new(i))));
+ named!(stmt_item -> Stmt, map!(syn!(Item), |i| Stmt::Item(i)));
#[cfg(feature = "full")]
named!(stmt_blockexpr -> Stmt, do_parse!(
@@ -2167,9 +2167,9 @@
({
e.replace_attrs(attrs);
if let Some(semi) = semi {
- Stmt::Semi(Box::new(e), semi)
+ Stmt::Semi(e, semi)
} else {
- Stmt::Expr(Box::new(e))
+ Stmt::Expr(e)
}
})
));
@@ -2181,7 +2181,7 @@
semi: punct!(;) >>
({
e.replace_attrs(attrs);
- Stmt::Semi(Box::new(e), semi)
+ Stmt::Semi(e, semi)
})
));
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index d8e0ec5..0794f69 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -2462,22 +2462,22 @@
match _i {
Stmt::Local(_binding_0, ) => {
Stmt::Local (
- Box::new(_visitor.fold_local(* _binding_0)),
+ _visitor.fold_local(_binding_0),
)
}
Stmt::Item(_binding_0, ) => {
Stmt::Item (
- Box::new(_visitor.fold_item(* _binding_0)),
+ _visitor.fold_item(_binding_0),
)
}
Stmt::Expr(_binding_0, ) => {
Stmt::Expr (
- Box::new(_visitor.fold_expr(* _binding_0)),
+ _visitor.fold_expr(_binding_0),
)
}
Stmt::Semi(_binding_0, _binding_1, ) => {
Stmt::Semi (
- Box::new(_visitor.fold_expr(* _binding_0)),
+ _visitor.fold_expr(_binding_0),
Token ! [ ; ](tokens_helper(_visitor, &(_binding_1).0)),
)
}
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index a3dc7f3..8b6c004 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -1930,16 +1930,16 @@
pub fn visit_stmt<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Stmt) {
match *_i {
Stmt::Local(ref _binding_0, ) => {
- _visitor.visit_local(& * * _binding_0);
+ _visitor.visit_local(_binding_0);
}
Stmt::Item(ref _binding_0, ) => {
- _visitor.visit_item(& * * _binding_0);
+ _visitor.visit_item(_binding_0);
}
Stmt::Expr(ref _binding_0, ) => {
- _visitor.visit_expr(& * * _binding_0);
+ _visitor.visit_expr(_binding_0);
}
Stmt::Semi(ref _binding_0, ref _binding_1, ) => {
- _visitor.visit_expr(& * * _binding_0);
+ _visitor.visit_expr(_binding_0);
tokens_helper(_visitor, &(_binding_1).0);
}
}
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index 029db60..2408af0 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -1930,16 +1930,16 @@
pub fn visit_stmt_mut<V: VisitMut + ?Sized>(_visitor: &mut V, _i: &mut Stmt) {
match *_i {
Stmt::Local(ref mut _binding_0, ) => {
- _visitor.visit_local_mut(& mut * * _binding_0);
+ _visitor.visit_local_mut(_binding_0);
}
Stmt::Item(ref mut _binding_0, ) => {
- _visitor.visit_item_mut(& mut * * _binding_0);
+ _visitor.visit_item_mut(_binding_0);
}
Stmt::Expr(ref mut _binding_0, ) => {
- _visitor.visit_expr_mut(& mut * * _binding_0);
+ _visitor.visit_expr_mut(_binding_0);
}
Stmt::Semi(ref mut _binding_0, ref mut _binding_1, ) => {
- _visitor.visit_expr_mut(& mut * * _binding_0);
+ _visitor.visit_expr_mut(_binding_0);
tokens_helper(_visitor, &mut (_binding_1).0);
}
}
diff --git a/tests/test_expr.rs b/tests/test_expr.rs
index 2028af5..5c60d4b 100644
--- a/tests/test_expr.rs
+++ b/tests/test_expr.rs
@@ -102,7 +102,7 @@
assert_let!(Item::Fn(ItemFn { ref block, .. }) = actual.items[1]; {
assert_let!(Stmt::Local(ref local) = block.stmts[0]; {
- assert_let!(Local { init: Some((_, ref init_expr)), .. } = **local; {
+ assert_let!(Local { init: Some((_, ref init_expr)), .. } = *local; {
assert_let!(Expr::Catch(..) = **init_expr);
});
});
@@ -114,7 +114,7 @@
});
assert_let!(Stmt::Expr(ref expr) = block.stmts[3]; {
- assert_let!(Expr::While(ExprWhile { ref cond, .. }) = **expr; {
+ assert_let!(Expr::While(ExprWhile { ref cond, .. }) = *expr; {
assert_let!(Expr::Path(ExprPath { qself: None, ref path, .. }) = **cond; {
assert_eq!(*path, "catch".into());
});
@@ -122,7 +122,7 @@
});
assert_let!(Stmt::Semi(ref expr, _) = block.stmts[5]; {
- assert_let!(Expr::Assign(ExprAssign { ref left, ref right, .. }) = **expr; {
+ assert_let!(Expr::Assign(ExprAssign { ref left, ref right, .. }) = *expr; {
assert_let!(Expr::Path(ExprPath { qself: None, ref path, .. }) = **left; {
assert_eq!(*path, "catch".into());
});
@@ -136,7 +136,7 @@
});
assert_let!(Stmt::Semi(ref expr, _) = block.stmts[7]; {
- assert_let!(Expr::Match(ExprMatch { ref expr, .. }) = **expr; {
+ assert_let!(Expr::Match(ExprMatch { ref expr, .. }) = *expr; {
assert_let!(Expr::Path(ExprPath { qself: None, ref path, .. }) = **expr; {
assert_eq!(*path, "catch".into());
});
diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs
index d9cd744..0a2ee15 100644
--- a/tests/test_precedence.rs
+++ b/tests/test_precedence.rs
@@ -328,8 +328,8 @@
fn fold_stmt(&mut self, stmt: Stmt) -> Stmt {
match stmt {
// Don't wrap toplevel expressions in statements.
- Stmt::Expr(e) => Stmt::Expr(Box::new(fold_expr(self, *e))),
- Stmt::Semi(e, semi) => Stmt::Semi(Box::new(fold_expr(self, *e)), semi),
+ Stmt::Expr(e) => Stmt::Expr(fold_expr(self, e)),
+ Stmt::Semi(e, semi) => Stmt::Semi(fold_expr(self, e), semi),
s => s,
}
}