Rename Stmt.node to Stmt.kind

This commit is contained in:
varkor 2019-09-26 17:34:50 +01:00
parent c3d8791373
commit 21bf983acb
32 changed files with 76 additions and 76 deletions

View file

@ -262,7 +262,7 @@ impl CheckAttrVisitor<'tcx> {
fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
// When checking statements ignore expressions, they will be checked later
if let hir::StmtKind::Local(ref l) = stmt.node {
if let hir::StmtKind::Local(ref l) = stmt.kind {
for attr in l.attrs.iter() {
if attr.check_name(sym::inline) {
self.check_inline(attr, &stmt.span, Target::Statement);

View file

@ -974,7 +974,7 @@ 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) {
visitor.visit_id(statement.hir_id);
match statement.node {
match statement.kind {
StmtKind::Local(ref local) => visitor.visit_local(local),
StmtKind::Item(item) => visitor.visit_nested_item(item),
StmtKind::Expr(ref expression) |

View file

@ -2660,7 +2660,7 @@ impl<'a> LoweringContext<'a> {
for (index, stmt) in b.stmts.iter().enumerate() {
if index == b.stmts.len() - 1 {
if let StmtKind::Expr(ref e) = stmt.node {
if let StmtKind::Expr(ref e) = stmt.kind {
expr = Some(P(self.lower_expr(e)));
} else {
stmts.extend(self.lower_stmt(stmt));
@ -2931,7 +2931,7 @@ impl<'a> LoweringContext<'a> {
}
fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> {
let node = match s.node {
let kind = match s.kind {
StmtKind::Local(ref l) => {
let (l, item_ids) = self.lower_local(l);
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
@ -2944,7 +2944,7 @@ impl<'a> LoweringContext<'a> {
ids.push({
hir::Stmt {
hir_id: self.lower_node_id(s.id),
node: hir::StmtKind::Local(P(l)),
kind: hir::StmtKind::Local(P(l)),
span: s.span,
}
});
@ -2962,7 +2962,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt {
hir_id,
node: hir::StmtKind::Item(item_id),
kind: hir::StmtKind::Item(item_id),
span: s.span,
}
})
@ -2974,7 +2974,7 @@ impl<'a> LoweringContext<'a> {
};
smallvec![hir::Stmt {
hir_id: self.lower_node_id(s.id),
node,
kind,
span: s.span,
}]
}
@ -3011,8 +3011,8 @@ impl<'a> LoweringContext<'a> {
// Helper methods for building HIR.
fn stmt(&mut self, span: Span, node: hir::StmtKind) -> hir::Stmt {
hir::Stmt { span, node, hir_id: self.next_id() }
fn stmt(&mut self, span: Span, kind: hir::StmtKind) -> hir::Stmt {
hir::Stmt { span, kind, hir_id: self.next_id() }
}
fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt {

View file

@ -303,7 +303,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}
fn visit_stmt(&mut self, stmt: &'a Stmt) {
match stmt.node {
match stmt.kind {
StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id),
_ => visit::walk_stmt(self, stmt),
}

View file

@ -968,7 +968,7 @@ impl<'hir> Map<'hir> {
Some(Node::Variant(ref v)) => Some(&v.attrs[..]),
Some(Node::Field(ref f)) => Some(&f.attrs[..]),
Some(Node::Expr(ref e)) => Some(&*e.attrs),
Some(Node::Stmt(ref s)) => Some(s.node.attrs()),
Some(Node::Stmt(ref s)) => Some(s.kind.attrs()),
Some(Node::Arm(ref a)) => Some(&*a.attrs),
Some(Node::GenericParam(param)) => Some(&param.attrs[..]),
// Unit/tuple structs/variants take the attributes straight from

View file

@ -1221,7 +1221,7 @@ impl UnOp {
#[derive(RustcEncodable, RustcDecodable)]
pub struct Stmt {
pub hir_id: HirId,
pub node: StmtKind,
pub kind: StmtKind,
pub span: Span,
}

View file

@ -944,7 +944,7 @@ impl<'a> State<'a> {
pub fn print_stmt(&mut self, st: &hir::Stmt) {
self.maybe_print_comment(st.span.lo());
match st.node {
match st.kind {
hir::StmtKind::Local(ref loc) => {
self.print_local(loc.init.as_deref(), |this| this.print_local_decl(&loc));
}
@ -961,7 +961,7 @@ impl<'a> State<'a> {
self.s.word(";");
}
}
if stmt_ends_with_semi(&st.node) {
if stmt_ends_with_semi(&st.kind) {
self.s.word(";");
}
self.maybe_print_trailing_comment(st.span, None)

View file

@ -158,7 +158,7 @@ impl_stable_hash_for_spanned!(hir::BinOpKind);
impl_stable_hash_for!(struct hir::Stmt {
hir_id,
node,
kind,
span,
});

View file

@ -590,7 +590,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
}
fn walk_stmt(&mut self, stmt: &hir::Stmt) {
match stmt.node {
match stmt.kind {
hir::StmtKind::Local(ref local) => {
self.walk_local(&local);
}

View file

@ -947,7 +947,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode)
-> LiveNode {
match stmt.node {
match stmt.kind {
hir::StmtKind::Local(ref local) => {
// Note: we mark the variable as defined regardless of whether
// there is an initializer. Initially I had thought to only mark

View file

@ -796,7 +796,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
// index information.)
for (i, statement) in blk.stmts.iter().enumerate() {
match statement.node {
match statement.kind {
hir::StmtKind::Local(..) |
hir::StmtKind::Item(..) => {
// Each declaration introduces a subscope for bindings