Don't use an allocation for ItemId in StmtKind

This commit is contained in:
John Kåre Alsaker 2019-02-17 07:23:13 +01:00
parent eac09088e1
commit cdd1c0efbb
4 changed files with 7 additions and 6 deletions

View file

@ -951,7 +951,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
visitor.visit_id(statement.id); visitor.visit_id(statement.id);
match statement.node { match statement.node {
StmtKind::Local(ref local) => visitor.visit_local(local), StmtKind::Local(ref local) => visitor.visit_local(local),
StmtKind::Item(ref item) => visitor.visit_nested_item(**item), StmtKind::Item(item) => visitor.visit_nested_item(item),
StmtKind::Expr(ref expression) | StmtKind::Expr(ref expression) |
StmtKind::Semi(ref expression) => { StmtKind::Semi(ref expression) => {
visitor.visit_expr(expression) visitor.visit_expr(expression)

View file

@ -4663,7 +4663,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt { hir::Stmt {
id: node_id, id: node_id,
hir_id, hir_id,
node: hir::StmtKind::Item(P(item_id)), node: hir::StmtKind::Item(item_id),
span: s.span, span: s.span,
} }
}) })
@ -4693,7 +4693,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt { hir::Stmt {
id: node_id, id: node_id,
hir_id, hir_id,
node: hir::StmtKind::Item(P(item_id)), node: hir::StmtKind::Item(item_id),
span: s.span, span: s.span,
} }
}) })

View file

@ -1159,8 +1159,9 @@ impl fmt::Debug for Stmt {
pub enum StmtKind { pub enum StmtKind {
/// A local (`let`) binding. /// A local (`let`) binding.
Local(P<Local>), Local(P<Local>),
/// An item binding. /// An item binding.
Item(P<ItemId>), Item(ItemId),
/// An expression without a trailing semi-colon (must have unit type). /// An expression without a trailing semi-colon (must have unit type).
Expr(P<Expr>), Expr(P<Expr>),

View file

@ -1007,8 +1007,8 @@ impl<'a> State<'a> {
} }
self.end()? self.end()?
} }
hir::StmtKind::Item(ref item) => { hir::StmtKind::Item(item) => {
self.ann.nested(self, Nested::Item(**item))? self.ann.nested(self, Nested::Item(item))?
} }
hir::StmtKind::Expr(ref expr) => { hir::StmtKind::Expr(ref expr) => {
self.space_if_not_bol()?; self.space_if_not_bol()?;