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])
}
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);
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)
}
// ::std::option::Option::None => break
// };
// let <pat> = __next;
- // StmtExpr(<body>);
+ // StmtKind::Expr(<body>);
// }
// }
// };
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));
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,
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,
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,
.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"),
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(
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::*;
}
/// 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());
}
#[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,
}
}
}
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(";")?;
/// 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
}
}
UnNeg
});
-impl_stable_hash_for_spanned!(hir::Stmt_);
+impl_stable_hash_for_spanned!(hir::StmtKind);
impl_stable_hash_for!(struct hir::Local {
pat,
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 {
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);
}
}
- hir::StmtExpr(ref expr, _) |
- hir::StmtSemi(ref expr, _) => {
+ hir::StmtKind::Expr(ref expr, _) |
+ hir::StmtKind::Semi(ref expr, _) => {
self.consume_expr(&expr);
}
}
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 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,
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,
};
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");
}
}
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),
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
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) {
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
}
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(_) => {
}
}
}
- hir::StmtExpr(..) | hir::StmtSemi(..) => {}
+ hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
}
self.warn_if_unreachable(stmt.node.id(), stmt.span, "statement");
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);
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);
}
}
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);