diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index aab70456dc1..bbea4ad6a4c 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -111,13 +111,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id()); match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { let exit = self.decl(&decl, pred); self.add_ast_node(hir_id.local_id, &[exit]) } - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { let exit = self.expr(&expr, pred); self.add_ast_node(hir_id.local_id, &[exit]) } diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 2d83c158fe0..a4e9279b23f 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -264,7 +264,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { fn check_stmt_attributes(&self, stmt: &hir::Stmt) { // When checking statements ignore expressions, they will be checked later - if let hir::Stmt_::StmtDecl(_, _) = stmt.node { + if let hir::StmtKind::Decl(_, _) = stmt.node { for attr in stmt.node.attrs() { if attr.check_name("inline") { self.check_inline(attr, &stmt.span, Target::Statement); diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index e2c0020db2f..de0f3a405d8 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -935,12 +935,12 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { match statement.node { - StmtDecl(ref declaration, id) => { + StmtKind::Decl(ref declaration, id) => { visitor.visit_id(id); visitor.visit_decl(declaration) } - StmtExpr(ref expression, id) | - StmtSemi(ref expression, id) => { + StmtKind::Expr(ref expression, id) | + StmtKind::Semi(ref expression, id) => { visitor.visit_id(id); visitor.visit_expr(expression) } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 86f6e08215e..07d1281ada6 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3995,7 +3995,7 @@ impl<'a> LoweringContext<'a> { // ::std::option::Option::None => break // }; // let = __next; - // StmtExpr(); + // StmtKind::Expr(); // } // } // }; @@ -4057,7 +4057,7 @@ impl<'a> LoweringContext<'a> { ThinVec::new(), )) }; - let match_stmt = respan(head_sp, hir::StmtExpr(match_expr, self.next_id().node_id)); + let match_stmt = respan(head_sp, hir::StmtKind::Expr(match_expr, self.next_id().node_id)); let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id)); @@ -4076,7 +4076,7 @@ impl<'a> LoweringContext<'a> { let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false)); let body_expr = P(self.expr_block(body_block, ThinVec::new())); - let body_stmt = respan(body.span, hir::StmtExpr(body_expr, self.next_id().node_id)); + let body_stmt = respan(body.span, hir::StmtKind::Expr(body_expr, self.next_id().node_id)); let loop_block = P(self.block_all( e.span, @@ -4246,7 +4246,7 @@ impl<'a> LoweringContext<'a> { fn lower_stmt(&mut self, s: &Stmt) -> SmallVector { SmallVector::one(match s.node { StmtKind::Local(ref l) => Spanned { - node: hir::StmtDecl( + node: hir::StmtKind::Decl( P(Spanned { node: hir::DeclLocal(self.lower_local(l)), span: s.span, @@ -4261,7 +4261,7 @@ impl<'a> LoweringContext<'a> { return self.lower_item_id(it) .into_iter() .map(|item_id| Spanned { - node: hir::StmtDecl( + node: hir::StmtKind::Decl( P(Spanned { node: hir::DeclItem(item_id), span: s.span, @@ -4275,11 +4275,11 @@ impl<'a> LoweringContext<'a> { .collect(); } StmtKind::Expr(ref e) => Spanned { - node: hir::StmtExpr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), + node: hir::StmtKind::Expr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), span: s.span, }, StmtKind::Semi(ref e) => Spanned { - node: hir::StmtSemi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), + node: hir::StmtKind::Semi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), span: s.span, }, StmtKind::Mac(..) => panic!("Shouldn't exist here"), @@ -4494,7 +4494,7 @@ impl<'a> LoweringContext<'a> { source, }); let decl = respan(sp, hir::DeclLocal(local)); - respan(sp, hir::StmtDecl(P(decl), self.next_id().node_id)) + respan(sp, hir::StmtKind::Decl(P(decl), self.next_id().node_id)) } fn stmt_let( diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 594fae972b1..bb1536d9630 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -19,7 +19,6 @@ pub use self::ForeignItem_::*; pub use self::Item_::*; pub use self::Mutability::*; pub use self::PrimTy::*; -pub use self::Stmt_::*; pub use self::Ty_::*; pub use self::UnOp::*; pub use self::UnsafeSource::*; @@ -1102,9 +1101,9 @@ impl UnOp { } /// A statement -pub type Stmt = Spanned; +pub type Stmt = Spanned; -impl fmt::Debug for Stmt_ { +impl fmt::Debug for StmtKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Sadness. let spanned = codemap::dummy_spanned(self.clone()); @@ -1116,31 +1115,31 @@ impl fmt::Debug for Stmt_ { } #[derive(Clone, RustcEncodable, RustcDecodable)] -pub enum Stmt_ { +pub enum StmtKind { /// Could be an item or a local (let) binding: - StmtDecl(P, NodeId), + Decl(P, NodeId), /// Expr without trailing semi-colon (must have unit type): - StmtExpr(P, NodeId), + Expr(P, NodeId), /// Expr with trailing semi-colon (may have any type): - StmtSemi(P, NodeId), + Semi(P, NodeId), } -impl Stmt_ { +impl StmtKind { pub fn attrs(&self) -> &[Attribute] { match *self { - StmtDecl(ref d, _) => d.node.attrs(), - StmtExpr(ref e, _) | - StmtSemi(ref e, _) => &e.attrs, + StmtKind::Decl(ref d, _) => d.node.attrs(), + StmtKind::Expr(ref e, _) | + StmtKind::Semi(ref e, _) => &e.attrs, } } pub fn id(&self) -> NodeId { match *self { - StmtDecl(_, id) => id, - StmtExpr(_, id) => id, - StmtSemi(_, id) => id, + StmtKind::Decl(_, id) => id, + StmtKind::Expr(_, id) => id, + StmtKind::Semi(_, id) => id, } } } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 3004c0d0224..5a3a36c6458 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1001,14 +1001,14 @@ impl<'a> State<'a> { pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> { self.maybe_print_comment(st.span.lo())?; match st.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { self.print_decl(&decl)?; } - hir::StmtExpr(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) => { self.space_if_not_bol()?; self.print_expr(&expr)?; } - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Semi(ref expr, _) => { self.space_if_not_bol()?; self.print_expr(&expr)?; self.s.word(";")?; @@ -2396,18 +2396,18 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { /// this statement requires a semicolon after it. /// note that in one case (stmt_semi), we've already /// seen the semicolon, and thus don't need another. -fn stmt_ends_with_semi(stmt: &hir::Stmt_) -> bool { +fn stmt_ends_with_semi(stmt: &hir::StmtKind) -> bool { match *stmt { - hir::StmtDecl(ref d, _) => { + hir::StmtKind::Decl(ref d, _) => { match d.node { hir::DeclLocal(_) => true, hir::DeclItem(_) => false, } } - hir::StmtExpr(ref e, _) => { + hir::StmtKind::Expr(ref e, _) => { expr_requires_semi_to_be_stmt(&e) } - hir::StmtSemi(..) => { + hir::StmtKind::Semi(..) => { false } } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 71a8d3ccdaf..8df6539ecfe 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -466,7 +466,7 @@ impl_stable_hash_for!(enum hir::UnOp { UnNeg }); -impl_stable_hash_for_spanned!(hir::Stmt_); +impl_stable_hash_for_spanned!(hir::StmtKind); impl_stable_hash_for!(struct hir::Local { pat, @@ -915,10 +915,10 @@ impl_stable_hash_for!(enum hir::ForeignItem_ { ForeignItemType }); -impl_stable_hash_for!(enum hir::Stmt_ { - StmtDecl(decl, id), - StmtExpr(expr, id), - StmtSemi(expr, id) +impl_stable_hash_for!(enum hir::StmtKind { + Decl(decl, id), + Expr(expr, id), + Semi(expr, id) }); impl_stable_hash_for!(struct hir::Arg { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index a83aa47fd4f..af7dc3afdbb 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { fn walk_stmt(&mut self, stmt: &hir::Stmt) { match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { hir::DeclLocal(ref local) => { self.walk_local(&local); @@ -599,8 +599,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } } - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { self.consume_expr(&expr); } } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 07a9dd75d4c..cad74a0fb9e 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -860,11 +860,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode) -> LiveNode { match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { self.propagate_through_decl(&decl, succ) } - hir::StmtExpr(ref expr, _) | hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | hir::StmtKind::Semi(ref expr, _) => { self.propagate_through_expr(&expr, succ) } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index a196820fcf1..f822c4c08f2 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -858,8 +858,8 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk: // index information.) for (i, statement) in blk.stmts.iter().enumerate() { - if let hir::StmtDecl(..) = statement.node { - // Each StmtDecl introduces a subscope for bindings + if let hir::StmtKind::Decl(..) = statement.node { + // Each StmtKind::Decl introduces a subscope for bindings // introduced by the declaration; this subscope covers // a suffix of the block . Each subscope in a block // has the previous subscope in the block as a parent, diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 1ae6289e939..c71799a172c 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -49,7 +49,7 @@ impl LintPass for UnusedResults { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { let expr = match s.node { - hir::StmtSemi(ref expr, _) => &**expr, + hir::StmtKind::Semi(ref expr, _) => &**expr, _ => return, }; @@ -166,8 +166,8 @@ impl LintPass for PathStatements { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { - if let hir::StmtSemi(ref expr, _) = s.node { - if let hir::ExprPath(_) = expr.node { + if let hir::StmtKind::Semi(ref expr, _) = s.node { + if let hir::ExprKind::Path(_) = expr.node { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); } } diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 5ef1eef133d..48558ba6db2 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -55,8 +55,8 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id()); let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id); match stmt.node { - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { result.push(StmtRef::Mirror(Box::new(Stmt { kind: StmtKind::Expr { scope: region::Scope::Node(hir_id.local_id), @@ -65,7 +65,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, opt_destruction_scope: opt_dxn_ext, }))) } - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { hir::DeclItem(..) => { // ignore for purposes of the MIR diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 66633a0de70..138731edfff 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -261,7 +261,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability { match stmt.node { - hir::StmtDecl(ref decl, _node_id) => { + hir::StmtKind::Decl(ref decl, _node_id) => { match &decl.node { hir::DeclLocal(local) => { if self.remove_mut_rvalue_borrow(&local.pat) { @@ -280,8 +280,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { hir::DeclItem(_) => Promotable } } - hir::StmtExpr(ref box_expr, _node_id) | - hir::StmtSemi(ref box_expr, _node_id) => { + hir::StmtKind::Expr(ref box_expr, _node_id) | + hir::StmtKind::Semi(ref box_expr, _node_id) => { let _ = self.check_expr(box_expr); NotPromotable } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c7ad3398873..0d93c52a248 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4377,7 +4377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) { // Don't do all the complex logic below for DeclItem. match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { hir::DeclLocal(_) => {} hir::DeclItem(_) => { @@ -4385,7 +4385,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - hir::StmtExpr(..) | hir::StmtSemi(..) => {} + hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {} } self.warn_if_unreachable(stmt.node.id(), stmt.span, "statement"); @@ -4397,7 +4397,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.has_errors.set(false); match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { hir::DeclLocal(ref l) => { self.check_decl_local(&l); @@ -4405,11 +4405,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::DeclItem(_) => {/* ignore for now */} } } - hir::StmtExpr(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) => { // Check with expected type of () self.check_expr_has_type_or_error(&expr, self.tcx.mk_nil()); } - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Semi(ref expr, _) => { self.check_expr(&expr); } } @@ -4733,7 +4733,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None => return, }; let last_expr = match last_stmt.node { - hir::StmtSemi(ref e, _) => e, + hir::StmtKind::Semi(ref e, _) => e, _ => return, }; let last_expr_ty = self.node_ty(last_expr.hir_id);