From cdd1c0efbb37fd475ebc60e0e58e32e7d2cbff19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 17 Feb 2019 07:23:13 +0100 Subject: [PATCH] Don't use an allocation for ItemId in StmtKind --- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/lowering.rs | 4 ++-- src/librustc/hir/mod.rs | 3 ++- src/librustc/hir/print.rs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 9436c600c9f..a8fa1f31a55 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -951,7 +951,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { visitor.visit_id(statement.id); match statement.node { 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::Semi(ref expression) => { visitor.visit_expr(expression) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 84487c40f87..2341dda6768 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -4663,7 +4663,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr { hir::Stmt { id: node_id, hir_id, - node: hir::StmtKind::Item(P(item_id)), + node: hir::StmtKind::Item(item_id), span: s.span, } }) @@ -4693,7 +4693,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr { hir::Stmt { id: node_id, hir_id, - node: hir::StmtKind::Item(P(item_id)), + node: hir::StmtKind::Item(item_id), span: s.span, } }) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d774359fa79..f4a9903e559 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1159,8 +1159,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { pub enum StmtKind { /// A local (`let`) binding. Local(P), + /// An item binding. - Item(P), + Item(ItemId), /// An expression without a trailing semi-colon (must have unit type). Expr(P), diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 9b6fcf259be..81a67b1a4bc 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1007,8 +1007,8 @@ pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> { } self.end()? } - hir::StmtKind::Item(ref item) => { - self.ann.nested(self, Nested::Item(**item))? + hir::StmtKind::Item(item) => { + self.ann.nested(self, Nested::Item(item))? } hir::StmtKind::Expr(ref expr) => { self.space_if_not_bol()?; -- GitLab