]> git.lizzy.rs Git - rust.git/commitdiff
StmtKind
authorcsmoe <35686186+csmoe@users.noreply.github.com>
Wed, 11 Jul 2018 10:54:37 +0000 (18:54 +0800)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Mon, 16 Jul 2018 13:09:16 +0000 (15:09 +0200)
14 files changed:
src/librustc/cfg/construct.rs
src/librustc/hir/check_attr.rs
src/librustc/hir/intravisit.rs
src/librustc/hir/lowering.rs
src/librustc/hir/mod.rs
src/librustc/hir/print.rs
src/librustc/ich/impls_hir.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/liveness.rs
src/librustc/middle/region.rs
src/librustc_lint/unused.rs
src/librustc_mir/hair/cx/block.rs
src/librustc_passes/rvalue_promotion.rs
src/librustc_typeck/check/mod.rs

index aab70456dc18dbcef2e484c231cbe2916feadaca..bbea4ad6a4c9bb9cbb720b259f94e5ce804385fd 100644 (file)
@@ -111,13 +111,13 @@ fn block(&mut self, blk: &hir::Block, pred: CFGIndex) -> CFGIndex {
     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])
             }
index 2d83c158fe08f1bb8c65a1f2b695437ad6d7eed0..a4e9279b23f7d0d644ad8e9b24c4f84942fe4fce 100644 (file)
@@ -264,7 +264,7 @@ fn emit_repr_error(
 
     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);
index e2c0020db2ff346ee50de183a6809d1b5728ed47..de0f3a405d891bd0c05089668bedcc055ac4ac11 100644 (file)
@@ -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)
         }
index 86f6e08215e5219fcd520e29862ba121ca5bb3b4..07d1281ada69e6e7e1822e3422be62cc0536d043 100644 (file)
@@ -3995,7 +3995,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                 //             ::std::option::Option::None => break
                 //           };
                 //           let <pat> = __next;
-                //           StmtExpr(<body>);
+                //           StmtKind::Expr(<body>);
                 //         }
                 //       }
                 //     };
@@ -4057,7 +4057,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                         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 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
 
                 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 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
     fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
         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 @@ fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
                 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 @@ fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
                     .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 @@ fn stmt_let_pat(
             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(
index 594fae972b17375f6e83d759a7230c001a0c2cbe..bb1536d9630286561d7f95618a08d816121a4d56 100644 (file)
@@ -19,7 +19,6 @@
 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 @@ pub fn is_by_value(self) -> bool {
 }
 
 /// A statement
-pub type Stmt = Spanned<Stmt_>;
+pub type Stmt = Spanned<StmtKind>;
 
-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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable)]
-pub enum Stmt_ {
+pub enum StmtKind {
     /// Could be an item or a local (let) binding:
-    StmtDecl(P<Decl>, NodeId),
+    Decl(P<Decl>, NodeId),
 
     /// Expr without trailing semi-colon (must have unit type):
-    StmtExpr(P<Expr>, NodeId),
+    Expr(P<Expr>, NodeId),
 
     /// Expr with trailing semi-colon (may have any type):
-    StmtSemi(P<Expr>, NodeId),
+    Semi(P<Expr>, 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,
         }
     }
 }
index 3004c0d0224c0965cd67e9d61ae5ff235742a08c..5a3a36c6458506d51d7d099a299a96a61d1bdf67 100644 (file)
@@ -1001,14 +1001,14 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
     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
         }
     }
index 71a8d3ccdaf65a4fe4fba5e3182d3f83557b2ced..8df6539ecfeb6973e326bf7a3920bd6d263b2775 100644 (file)
@@ -466,7 +466,7 @@ fn hash_stable<W: StableHasherResult>(&self,
     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 @@ fn hash_stable<W: StableHasherResult>(&self,
     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 {
index a83aa47fd4f13ff2826715f7a0e46f19ee38488c..af7dc3afdbb5e501e4549690d080fe5858976328 100644 (file)
@@ -586,7 +586,7 @@ fn walk_callee(&mut self, call: &hir::Expr, callee: &hir::Expr) {
 
     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 @@ fn walk_stmt(&mut self, stmt: &hir::Stmt) {
                 }
             }
 
-            hir::StmtExpr(ref expr, _) |
-            hir::StmtSemi(ref expr, _) => {
+            hir::StmtKind::Expr(ref expr, _) |
+            hir::StmtKind::Semi(ref expr, _) => {
                 self.consume_expr(&expr);
             }
         }
index 07a9dd75d4ca4ae1229449666c4a1cc72a37887f..cad74a0fb9e955781f3bbd62d69d74cd497e4239 100644 (file)
@@ -860,11 +860,11 @@ fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode)
     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)
             }
         }
index a196820fcf17d8a4f578cdc1432815bf22480cb6..f822c4c08f279884fba6f66ea3faf0a2385234d2 100644 (file)
@@ -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,
index 1ae6289e9399b221dafcf8d790a089b7843a91e5..c71799a172c96dfa0406d74bf6c9685efb0c24ac 100644 (file)
@@ -49,7 +49,7 @@ fn get_lints(&self) -> LintArray {
 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 @@ fn get_lints(&self) -> LintArray {
 
 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");
             }
         }
index 5ef1eef133d9d45413a1448e2c7743c4de904bb5..48558ba6db24dc672b80c4a6bd1b318296724570 100644 (file)
@@ -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
index 66633a0de70911f7471a09dbba802824b6728768..138731edfff78f34c3c4c43e7aa5420cd16a6aff 100644 (file)
@@ -261,7 +261,7 @@ fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability {
 
     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 @@ fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
                     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
             }
index c7ad3398873eabc00e12491b7ad70d74bd629a54..0d93c52a24898c77d473db691de4159177837eac 100644 (file)
@@ -4377,7 +4377,7 @@ pub fn check_decl_local(&self, local: &'gcx hir::Local)  {
     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 @@ pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
                     }
                 }
             }
-            hir::StmtExpr(..) | hir::StmtSemi(..) => {}
+            hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
         }
 
         self.warn_if_unreachable(stmt.node.id(), stmt.span, "statement");
@@ -4397,7 +4397,7 @@ pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
         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 @@ pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
                     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 @@ fn consider_hint_about_removing_semicolon(&self,
             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);