Skip to content

Commit 114314c

Browse files
csmoeoli-obk
authored andcommitted
StmtKind
1 parent fe8955b commit 114314c

File tree

14 files changed

+62
-63
lines changed

14 files changed

+62
-63
lines changed

src/librustc/cfg/construct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
111111
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
112112
let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id());
113113
match stmt.node {
114-
hir::StmtDecl(ref decl, _) => {
114+
hir::StmtKind::Decl(ref decl, _) => {
115115
let exit = self.decl(&decl, pred);
116116
self.add_ast_node(hir_id.local_id, &[exit])
117117
}
118118

119-
hir::StmtExpr(ref expr, _) |
120-
hir::StmtSemi(ref expr, _) => {
119+
hir::StmtKind::Expr(ref expr, _) |
120+
hir::StmtKind::Semi(ref expr, _) => {
121121
let exit = self.expr(&expr, pred);
122122
self.add_ast_node(hir_id.local_id, &[exit])
123123
}

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
264264

265265
fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
266266
// When checking statements ignore expressions, they will be checked later
267-
if let hir::Stmt_::StmtDecl(_, _) = stmt.node {
267+
if let hir::StmtKind::Decl(_, _) = stmt.node {
268268
for attr in stmt.node.attrs() {
269269
if attr.check_name("inline") {
270270
self.check_inline(attr, &stmt.span, Target::Statement);

src/librustc/hir/intravisit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,12 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
935935

936936
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
937937
match statement.node {
938-
StmtDecl(ref declaration, id) => {
938+
StmtKind::Decl(ref declaration, id) => {
939939
visitor.visit_id(id);
940940
visitor.visit_decl(declaration)
941941
}
942-
StmtExpr(ref expression, id) |
943-
StmtSemi(ref expression, id) => {
942+
StmtKind::Expr(ref expression, id) |
943+
StmtKind::Semi(ref expression, id) => {
944944
visitor.visit_id(id);
945945
visitor.visit_expr(expression)
946946
}

src/librustc/hir/lowering.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,7 +3995,7 @@ impl<'a> LoweringContext<'a> {
39953995
// ::std::option::Option::None => break
39963996
// };
39973997
// let <pat> = __next;
3998-
// StmtExpr(<body>);
3998+
// StmtKind::Expr(<body>);
39993999
// }
40004000
// }
40014001
// };
@@ -4057,7 +4057,7 @@ impl<'a> LoweringContext<'a> {
40574057
ThinVec::new(),
40584058
))
40594059
};
4060-
let match_stmt = respan(head_sp, hir::StmtExpr(match_expr, self.next_id().node_id));
4060+
let match_stmt = respan(head_sp, hir::StmtKind::Expr(match_expr, self.next_id().node_id));
40614061

40624062
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id));
40634063

@@ -4076,7 +4076,7 @@ impl<'a> LoweringContext<'a> {
40764076

40774077
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
40784078
let body_expr = P(self.expr_block(body_block, ThinVec::new()));
4079-
let body_stmt = respan(body.span, hir::StmtExpr(body_expr, self.next_id().node_id));
4079+
let body_stmt = respan(body.span, hir::StmtKind::Expr(body_expr, self.next_id().node_id));
40804080

40814081
let loop_block = P(self.block_all(
40824082
e.span,
@@ -4246,7 +4246,7 @@ impl<'a> LoweringContext<'a> {
42464246
fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
42474247
SmallVector::one(match s.node {
42484248
StmtKind::Local(ref l) => Spanned {
4249-
node: hir::StmtDecl(
4249+
node: hir::StmtKind::Decl(
42504250
P(Spanned {
42514251
node: hir::DeclLocal(self.lower_local(l)),
42524252
span: s.span,
@@ -4261,7 +4261,7 @@ impl<'a> LoweringContext<'a> {
42614261
return self.lower_item_id(it)
42624262
.into_iter()
42634263
.map(|item_id| Spanned {
4264-
node: hir::StmtDecl(
4264+
node: hir::StmtKind::Decl(
42654265
P(Spanned {
42664266
node: hir::DeclItem(item_id),
42674267
span: s.span,
@@ -4275,11 +4275,11 @@ impl<'a> LoweringContext<'a> {
42754275
.collect();
42764276
}
42774277
StmtKind::Expr(ref e) => Spanned {
4278-
node: hir::StmtExpr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id),
4278+
node: hir::StmtKind::Expr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id),
42794279
span: s.span,
42804280
},
42814281
StmtKind::Semi(ref e) => Spanned {
4282-
node: hir::StmtSemi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id),
4282+
node: hir::StmtKind::Semi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id),
42834283
span: s.span,
42844284
},
42854285
StmtKind::Mac(..) => panic!("Shouldn't exist here"),
@@ -4494,7 +4494,7 @@ impl<'a> LoweringContext<'a> {
44944494
source,
44954495
});
44964496
let decl = respan(sp, hir::DeclLocal(local));
4497-
respan(sp, hir::StmtDecl(P(decl), self.next_id().node_id))
4497+
respan(sp, hir::StmtKind::Decl(P(decl), self.next_id().node_id))
44984498
}
44994499

45004500
fn stmt_let(

src/librustc/hir/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub use self::ForeignItem_::*;
1919
pub use self::Item_::*;
2020
pub use self::Mutability::*;
2121
pub use self::PrimTy::*;
22-
pub use self::Stmt_::*;
2322
pub use self::Ty_::*;
2423
pub use self::UnOp::*;
2524
pub use self::UnsafeSource::*;
@@ -1102,9 +1101,9 @@ impl UnOp {
11021101
}
11031102

11041103
/// A statement
1105-
pub type Stmt = Spanned<Stmt_>;
1104+
pub type Stmt = Spanned<StmtKind>;
11061105

1107-
impl fmt::Debug for Stmt_ {
1106+
impl fmt::Debug for StmtKind {
11081107
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11091108
// Sadness.
11101109
let spanned = codemap::dummy_spanned(self.clone());
@@ -1116,31 +1115,31 @@ impl fmt::Debug for Stmt_ {
11161115
}
11171116

11181117
#[derive(Clone, RustcEncodable, RustcDecodable)]
1119-
pub enum Stmt_ {
1118+
pub enum StmtKind {
11201119
/// Could be an item or a local (let) binding:
1121-
StmtDecl(P<Decl>, NodeId),
1120+
Decl(P<Decl>, NodeId),
11221121

11231122
/// Expr without trailing semi-colon (must have unit type):
1124-
StmtExpr(P<Expr>, NodeId),
1123+
Expr(P<Expr>, NodeId),
11251124

11261125
/// Expr with trailing semi-colon (may have any type):
1127-
StmtSemi(P<Expr>, NodeId),
1126+
Semi(P<Expr>, NodeId),
11281127
}
11291128

1130-
impl Stmt_ {
1129+
impl StmtKind {
11311130
pub fn attrs(&self) -> &[Attribute] {
11321131
match *self {
1133-
StmtDecl(ref d, _) => d.node.attrs(),
1134-
StmtExpr(ref e, _) |
1135-
StmtSemi(ref e, _) => &e.attrs,
1132+
StmtKind::Decl(ref d, _) => d.node.attrs(),
1133+
StmtKind::Expr(ref e, _) |
1134+
StmtKind::Semi(ref e, _) => &e.attrs,
11361135
}
11371136
}
11381137

11391138
pub fn id(&self) -> NodeId {
11401139
match *self {
1141-
StmtDecl(_, id) => id,
1142-
StmtExpr(_, id) => id,
1143-
StmtSemi(_, id) => id,
1140+
StmtKind::Decl(_, id) => id,
1141+
StmtKind::Expr(_, id) => id,
1142+
StmtKind::Semi(_, id) => id,
11441143
}
11451144
}
11461145
}

src/librustc/hir/print.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,14 +1001,14 @@ impl<'a> State<'a> {
10011001
pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
10021002
self.maybe_print_comment(st.span.lo())?;
10031003
match st.node {
1004-
hir::StmtDecl(ref decl, _) => {
1004+
hir::StmtKind::Decl(ref decl, _) => {
10051005
self.print_decl(&decl)?;
10061006
}
1007-
hir::StmtExpr(ref expr, _) => {
1007+
hir::StmtKind::Expr(ref expr, _) => {
10081008
self.space_if_not_bol()?;
10091009
self.print_expr(&expr)?;
10101010
}
1011-
hir::StmtSemi(ref expr, _) => {
1011+
hir::StmtKind::Semi(ref expr, _) => {
10121012
self.space_if_not_bol()?;
10131013
self.print_expr(&expr)?;
10141014
self.s.word(";")?;
@@ -2396,18 +2396,18 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
23962396
/// this statement requires a semicolon after it.
23972397
/// note that in one case (stmt_semi), we've already
23982398
/// seen the semicolon, and thus don't need another.
2399-
fn stmt_ends_with_semi(stmt: &hir::Stmt_) -> bool {
2399+
fn stmt_ends_with_semi(stmt: &hir::StmtKind) -> bool {
24002400
match *stmt {
2401-
hir::StmtDecl(ref d, _) => {
2401+
hir::StmtKind::Decl(ref d, _) => {
24022402
match d.node {
24032403
hir::DeclLocal(_) => true,
24042404
hir::DeclItem(_) => false,
24052405
}
24062406
}
2407-
hir::StmtExpr(ref e, _) => {
2407+
hir::StmtKind::Expr(ref e, _) => {
24082408
expr_requires_semi_to_be_stmt(&e)
24092409
}
2410-
hir::StmtSemi(..) => {
2410+
hir::StmtKind::Semi(..) => {
24112411
false
24122412
}
24132413
}

src/librustc/ich/impls_hir.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl_stable_hash_for!(enum hir::UnOp {
466466
UnNeg
467467
});
468468

469-
impl_stable_hash_for_spanned!(hir::Stmt_);
469+
impl_stable_hash_for_spanned!(hir::StmtKind);
470470

471471
impl_stable_hash_for!(struct hir::Local {
472472
pat,
@@ -915,10 +915,10 @@ impl_stable_hash_for!(enum hir::ForeignItem_ {
915915
ForeignItemType
916916
});
917917

918-
impl_stable_hash_for!(enum hir::Stmt_ {
919-
StmtDecl(decl, id),
920-
StmtExpr(expr, id),
921-
StmtSemi(expr, id)
918+
impl_stable_hash_for!(enum hir::StmtKind {
919+
Decl(decl, id),
920+
Expr(expr, id),
921+
Semi(expr, id)
922922
});
923923

924924
impl_stable_hash_for!(struct hir::Arg {

src/librustc/middle/expr_use_visitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
586586

587587
fn walk_stmt(&mut self, stmt: &hir::Stmt) {
588588
match stmt.node {
589-
hir::StmtDecl(ref decl, _) => {
589+
hir::StmtKind::Decl(ref decl, _) => {
590590
match decl.node {
591591
hir::DeclLocal(ref local) => {
592592
self.walk_local(&local);
@@ -599,8 +599,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
599599
}
600600
}
601601

602-
hir::StmtExpr(ref expr, _) |
603-
hir::StmtSemi(ref expr, _) => {
602+
hir::StmtKind::Expr(ref expr, _) |
603+
hir::StmtKind::Semi(ref expr, _) => {
604604
self.consume_expr(&expr);
605605
}
606606
}

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
860860
fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode)
861861
-> LiveNode {
862862
match stmt.node {
863-
hir::StmtDecl(ref decl, _) => {
863+
hir::StmtKind::Decl(ref decl, _) => {
864864
self.propagate_through_decl(&decl, succ)
865865
}
866866

867-
hir::StmtExpr(ref expr, _) | hir::StmtSemi(ref expr, _) => {
867+
hir::StmtKind::Expr(ref expr, _) | hir::StmtKind::Semi(ref expr, _) => {
868868
self.propagate_through_expr(&expr, succ)
869869
}
870870
}

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
858858
// index information.)
859859

860860
for (i, statement) in blk.stmts.iter().enumerate() {
861-
if let hir::StmtDecl(..) = statement.node {
862-
// Each StmtDecl introduces a subscope for bindings
861+
if let hir::StmtKind::Decl(..) = statement.node {
862+
// Each StmtKind::Decl introduces a subscope for bindings
863863
// introduced by the declaration; this subscope covers
864864
// a suffix of the block . Each subscope in a block
865865
// has the previous subscope in the block as a parent,

src/librustc_lint/unused.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl LintPass for UnusedResults {
4949
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
5050
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
5151
let expr = match s.node {
52-
hir::StmtSemi(ref expr, _) => &**expr,
52+
hir::StmtKind::Semi(ref expr, _) => &**expr,
5353
_ => return,
5454
};
5555

@@ -166,8 +166,8 @@ impl LintPass for PathStatements {
166166

167167
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
168168
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
169-
if let hir::StmtSemi(ref expr, _) = s.node {
170-
if let hir::ExprPath(_) = expr.node {
169+
if let hir::StmtKind::Semi(ref expr, _) = s.node {
170+
if let hir::ExprKind::Path(_) = expr.node {
171171
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
172172
}
173173
}

src/librustc_mir/hair/cx/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
5555
let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id());
5656
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
5757
match stmt.node {
58-
hir::StmtExpr(ref expr, _) |
59-
hir::StmtSemi(ref expr, _) => {
58+
hir::StmtKind::Expr(ref expr, _) |
59+
hir::StmtKind::Semi(ref expr, _) => {
6060
result.push(StmtRef::Mirror(Box::new(Stmt {
6161
kind: StmtKind::Expr {
6262
scope: region::Scope::Node(hir_id.local_id),
@@ -65,7 +65,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
6565
opt_destruction_scope: opt_dxn_ext,
6666
})))
6767
}
68-
hir::StmtDecl(ref decl, _) => {
68+
hir::StmtKind::Decl(ref decl, _) => {
6969
match decl.node {
7070
hir::DeclItem(..) => {
7171
// ignore for purposes of the MIR

src/librustc_passes/rvalue_promotion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
261261

262262
fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
263263
match stmt.node {
264-
hir::StmtDecl(ref decl, _node_id) => {
264+
hir::StmtKind::Decl(ref decl, _node_id) => {
265265
match &decl.node {
266266
hir::DeclLocal(local) => {
267267
if self.remove_mut_rvalue_borrow(&local.pat) {
@@ -280,8 +280,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
280280
hir::DeclItem(_) => Promotable
281281
}
282282
}
283-
hir::StmtExpr(ref box_expr, _node_id) |
284-
hir::StmtSemi(ref box_expr, _node_id) => {
283+
hir::StmtKind::Expr(ref box_expr, _node_id) |
284+
hir::StmtKind::Semi(ref box_expr, _node_id) => {
285285
let _ = self.check_expr(box_expr);
286286
NotPromotable
287287
}

src/librustc_typeck/check/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4377,15 +4377,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
43774377
pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
43784378
// Don't do all the complex logic below for DeclItem.
43794379
match stmt.node {
4380-
hir::StmtDecl(ref decl, _) => {
4380+
hir::StmtKind::Decl(ref decl, _) => {
43814381
match decl.node {
43824382
hir::DeclLocal(_) => {}
43834383
hir::DeclItem(_) => {
43844384
return;
43854385
}
43864386
}
43874387
}
4388-
hir::StmtExpr(..) | hir::StmtSemi(..) => {}
4388+
hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
43894389
}
43904390

43914391
self.warn_if_unreachable(stmt.node.id(), stmt.span, "statement");
@@ -4397,19 +4397,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
43974397
self.has_errors.set(false);
43984398

43994399
match stmt.node {
4400-
hir::StmtDecl(ref decl, _) => {
4400+
hir::StmtKind::Decl(ref decl, _) => {
44014401
match decl.node {
44024402
hir::DeclLocal(ref l) => {
44034403
self.check_decl_local(&l);
44044404
}
44054405
hir::DeclItem(_) => {/* ignore for now */}
44064406
}
44074407
}
4408-
hir::StmtExpr(ref expr, _) => {
4408+
hir::StmtKind::Expr(ref expr, _) => {
44094409
// Check with expected type of ()
44104410
self.check_expr_has_type_or_error(&expr, self.tcx.mk_nil());
44114411
}
4412-
hir::StmtSemi(ref expr, _) => {
4412+
hir::StmtKind::Semi(ref expr, _) => {
44134413
self.check_expr(&expr);
44144414
}
44154415
}
@@ -4733,7 +4733,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47334733
None => return,
47344734
};
47354735
let last_expr = match last_stmt.node {
4736-
hir::StmtSemi(ref e, _) => e,
4736+
hir::StmtKind::Semi(ref e, _) => e,
47374737
_ => return,
47384738
};
47394739
let last_expr_ty = self.node_ty(last_expr.hir_id);

0 commit comments

Comments
 (0)