Rename Stmt.node to Stmt.kind
This commit is contained in:
parent
c3d8791373
commit
21bf983acb
32 changed files with 76 additions and 76 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) |
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(¶m.attrs[..]),
|
||||
// Unit/tuple structs/variants take the attributes straight from
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ impl_stable_hash_for_spanned!(hir::BinOpKind);
|
|||
|
||||
impl_stable_hash_for!(struct hir::Stmt {
|
||||
hir_id,
|
||||
node,
|
||||
kind,
|
||||
span,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
|
||||
let exit = match stmt.node {
|
||||
let exit = match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
let init_exit = self.opt_expr(&local.init, pred);
|
||||
self.pat(&local.pat, init_exit)
|
||||
|
|
|
|||
|
|
@ -841,7 +841,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
|
||||
ast::Stmt {
|
||||
id: sess.next_node_id(),
|
||||
node: ast::StmtKind::Expr(expr),
|
||||
kind: ast::StmtKind::Expr(expr),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
}
|
||||
}
|
||||
|
|
@ -857,7 +857,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
let loop_stmt = ast::Stmt {
|
||||
id: self.sess.next_node_id(),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
node: ast::StmtKind::Expr(loop_expr),
|
||||
kind: ast::StmtKind::Expr(loop_expr),
|
||||
};
|
||||
|
||||
if self.within_static_or_const {
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ impl EarlyLintPass for UnusedDocComment {
|
|||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
|
||||
let (kind, is_macro_expansion) = match stmt.node {
|
||||
let (kind, is_macro_expansion) = match stmt.kind {
|
||||
ast::StmtKind::Local(..) => ("statements", false),
|
||||
ast::StmtKind::Item(..) => ("inner items", false),
|
||||
ast::StmtKind::Mac(..) => ("macro expansions", true),
|
||||
|
|
@ -781,7 +781,7 @@ impl EarlyLintPass for UnusedDocComment {
|
|||
ast::StmtKind::Expr(..) => return,
|
||||
};
|
||||
|
||||
self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.node.attrs());
|
||||
self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.kind.attrs());
|
||||
}
|
||||
|
||||
fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ declare_lint_pass!(RedundantSemicolon => [REDUNDANT_SEMICOLON]);
|
|||
|
||||
impl EarlyLintPass for RedundantSemicolon {
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) {
|
||||
if let StmtKind::Semi(expr) = &stmt.node {
|
||||
if let StmtKind::Semi(expr) = &stmt.kind {
|
||||
if let ExprKind::Tup(ref v) = &expr.kind {
|
||||
if v.is_empty() {
|
||||
// Strings of excess semicolons are encoded as empty tuple expressions
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ declare_lint_pass!(UnusedResults => [UNUSED_MUST_USE, UNUSED_RESULTS]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
|
||||
let expr = match s.node {
|
||||
let expr = match s.kind {
|
||||
hir::StmtKind::Semi(ref expr) => &**expr,
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -269,7 +269,7 @@ declare_lint_pass!(PathStatements => [PATH_STATEMENTS]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
|
||||
if let hir::StmtKind::Semi(ref expr) = s.node {
|
||||
if let hir::StmtKind::Semi(ref expr) = s.kind {
|
||||
if let hir::ExprKind::Path(_) = expr.kind {
|
||||
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ impl EarlyLintPass for UnusedParens {
|
|||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
|
||||
if let ast::StmtKind::Local(ref local) = s.node {
|
||||
if let ast::StmtKind::Local(ref local) = s.kind {
|
||||
self.check_unused_parens_pat(cx, &local.pat, false, false);
|
||||
|
||||
if let Some(ref value) = local.init {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn mirror_stmts<'a, 'tcx>(
|
|||
for (index, stmt) in stmts.iter().enumerate() {
|
||||
let hir_id = stmt.hir_id;
|
||||
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Expr(ref expr) |
|
||||
hir::StmtKind::Semi(ref expr) => {
|
||||
result.push(StmtRef::Mirror(Box::new(Stmt {
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
if self.remove_mut_rvalue_borrow(&local.pat) {
|
||||
if let Some(init) = &local.init {
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
|
||||
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
|
||||
// If any statements are items, we need to create an anonymous module
|
||||
block.stmts.iter().any(|statement| match statement.node {
|
||||
block.stmts.iter().any(|statement| match statement.kind {
|
||||
StmtKind::Item(_) | StmtKind::Mac(_) => true,
|
||||
_ => false,
|
||||
})
|
||||
|
|
@ -1161,7 +1161,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'b ast::Stmt) {
|
||||
if let ast::StmtKind::Mac(..) = stmt.node {
|
||||
if let ast::StmtKind::Mac(..) = stmt.kind {
|
||||
self.parent_scope.legacy = self.visit_invoc(stmt.id);
|
||||
} else {
|
||||
visit::walk_stmt(self, stmt);
|
||||
|
|
|
|||
|
|
@ -1804,7 +1804,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
|
||||
// Descend into the block.
|
||||
for stmt in &block.stmts {
|
||||
if let StmtKind::Item(ref item) = stmt.node {
|
||||
if let StmtKind::Item(ref item) = stmt.kind {
|
||||
if let ItemKind::MacroDef(..) = item.node {
|
||||
num_macro_definition_ribs += 1;
|
||||
let res = self.r.definitions.local_def_id(item.id);
|
||||
|
|
|
|||
|
|
@ -3860,7 +3860,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) {
|
||||
// Don't do all the complex logic below for `DeclItem`.
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Item(..) => return,
|
||||
hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
|
||||
}
|
||||
|
|
@ -3873,7 +3873,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.diverges.set(Diverges::Maybe);
|
||||
self.has_errors.set(false);
|
||||
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Local(ref l) => {
|
||||
self.check_decl_local(&l);
|
||||
}
|
||||
|
|
@ -4560,7 +4560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// Be helpful when the user wrote `{... expr;}` and
|
||||
// taking the `;` off is enough to fix the error.
|
||||
let last_stmt = blk.stmts.last()?;
|
||||
let last_expr = match last_stmt.node {
|
||||
let last_expr = match last_stmt.kind {
|
||||
hir::StmtKind::Semi(ref e) => e,
|
||||
_ => return None,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -835,31 +835,31 @@ impl UnOp {
|
|||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Stmt {
|
||||
pub id: NodeId,
|
||||
pub node: StmtKind,
|
||||
pub kind: StmtKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Stmt {
|
||||
pub fn add_trailing_semicolon(mut self) -> Self {
|
||||
self.node = match self.node {
|
||||
self.kind = match self.kind {
|
||||
StmtKind::Expr(expr) => StmtKind::Semi(expr),
|
||||
StmtKind::Mac(mac) => {
|
||||
StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)))
|
||||
}
|
||||
node => node,
|
||||
kind => kind,
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_item(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
StmtKind::Item(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_expr(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
StmtKind::Expr(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -991,7 +991,7 @@ impl Expr {
|
|||
/// for example, an `if` condition.
|
||||
pub fn returns(&self) -> bool {
|
||||
if let ExprKind::Block(ref block, _) = self.kind {
|
||||
match block.stmts.last().map(|last_stmt| &last_stmt.node) {
|
||||
match block.stmts.last().map(|last_stmt| &last_stmt.kind) {
|
||||
// Implicit return
|
||||
Some(&StmtKind::Expr(_)) => true,
|
||||
Some(&StmtKind::Semi(ref expr)) => {
|
||||
|
|
|
|||
|
|
@ -702,11 +702,11 @@ impl HasAttrs for StmtKind {
|
|||
|
||||
impl HasAttrs for Stmt {
|
||||
fn attrs(&self) -> &[ast::Attribute] {
|
||||
self.node.attrs()
|
||||
self.kind.attrs()
|
||||
}
|
||||
|
||||
fn visit_attrs<F: FnOnce(&mut Vec<ast::Attribute>)>(&mut self, f: F) {
|
||||
self.node.visit_attrs(f);
|
||||
self.kind.visit_attrs(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ macro_rules! make_stmts_default {
|
|||
$me.make_expr().map(|e| smallvec![ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: e.span,
|
||||
node: ast::StmtKind::Expr(e),
|
||||
kind: ast::StmtKind::Expr(e),
|
||||
}])
|
||||
}
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ impl MacResult for DummyResult {
|
|||
fn make_stmts(self: Box<DummyResult>) -> Option<SmallVec<[ast::Stmt; 1]>> {
|
||||
Some(smallvec![ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)),
|
||||
kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)),
|
||||
span: self.span,
|
||||
}])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: expr.span,
|
||||
node: ast::StmtKind::Expr(expr),
|
||||
kind: ast::StmtKind::Expr(expr),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
});
|
||||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::StmtKind::Local(local),
|
||||
kind: ast::StmtKind::Local(local),
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
});
|
||||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::StmtKind::Local(local),
|
||||
kind: ast::StmtKind::Local(local),
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
pub fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt {
|
||||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::StmtKind::Item(item),
|
||||
kind: ast::StmtKind::Item(item),
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
self.block(expr.span, vec![ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: expr.span,
|
||||
node: ast::StmtKind::Expr(expr),
|
||||
kind: ast::StmtKind::Expr(expr),
|
||||
}])
|
||||
}
|
||||
pub fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block> {
|
||||
|
|
|
|||
|
|
@ -1206,7 +1206,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
if let StmtKind::Mac(mac) = stmt.node {
|
||||
if let StmtKind::Mac(mac) = stmt.kind {
|
||||
let (mac, style, attrs) = mac.into_inner();
|
||||
self.check_attributes(&attrs);
|
||||
let mut placeholder = self.collect_bang(mac, stmt.span, AstFragmentKind::Stmts)
|
||||
|
|
@ -1224,9 +1224,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||
}
|
||||
|
||||
// The placeholder expander gives ids to statements, so we avoid folding the id here.
|
||||
let ast::Stmt { id, node, span } = stmt;
|
||||
noop_flat_map_stmt_kind(node, self).into_iter().map(|node| {
|
||||
ast::Stmt { id, node, span }
|
||||
let ast::Stmt { id, kind, span } = stmt;
|
||||
noop_flat_map_stmt_kind(kind, self).into_iter().map(|kind| {
|
||||
ast::Stmt { id, kind, span }
|
||||
}).collect()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
|
|||
})),
|
||||
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
|
||||
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new()));
|
||||
ast::Stmt { id, span, node: ast::StmtKind::Mac(mac) }
|
||||
ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) }
|
||||
}]),
|
||||
AstFragmentKind::Arms => AstFragment::Arms(smallvec![
|
||||
ast::Arm {
|
||||
|
|
@ -296,7 +296,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
|||
}
|
||||
|
||||
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
|
||||
let (style, mut stmts) = match stmt.node {
|
||||
let (style, mut stmts) = match stmt.kind {
|
||||
ast::StmtKind::Mac(mac) => (mac.1, self.remove(stmt.id).make_stmts()),
|
||||
_ => return noop_flat_map_stmt(stmt, self),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1247,19 +1247,19 @@ pub fn noop_filter_map_expr<T: MutVisitor>(mut e: P<Expr>, vis: &mut T) -> Optio
|
|||
Some({ vis.visit_expr(&mut e); e })
|
||||
}
|
||||
|
||||
pub fn noop_flat_map_stmt<T: MutVisitor>(Stmt { node, mut span, mut id }: Stmt, vis: &mut T)
|
||||
pub fn noop_flat_map_stmt<T: MutVisitor>(Stmt { kind, mut span, mut id }: Stmt, vis: &mut T)
|
||||
-> SmallVec<[Stmt; 1]>
|
||||
{
|
||||
vis.visit_id(&mut id);
|
||||
vis.visit_span(&mut span);
|
||||
noop_flat_map_stmt_kind(node, vis).into_iter().map(|node| {
|
||||
Stmt { id, node, span }
|
||||
noop_flat_map_stmt_kind(kind, vis).into_iter().map(|kind| {
|
||||
Stmt { id, kind, span }
|
||||
}).collect()
|
||||
}
|
||||
|
||||
pub fn noop_flat_map_stmt_kind<T: MutVisitor>(node: StmtKind, vis: &mut T)
|
||||
pub fn noop_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T)
|
||||
-> SmallVec<[StmtKind; 1]> {
|
||||
match node {
|
||||
match kind {
|
||||
StmtKind::Local(mut local) =>
|
||||
smallvec![StmtKind::Local({ vis.visit_local(&mut local); local })],
|
||||
StmtKind::Item(item) => vis.flat_map_item(item).into_iter().map(StmtKind::Item).collect(),
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Some(if self.eat_keyword(kw::Let) {
|
||||
Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: StmtKind::Local(self.parse_local(attrs.into())?),
|
||||
kind: StmtKind::Local(self.parse_local(attrs.into())?),
|
||||
span: lo.to(self.prev_span),
|
||||
}
|
||||
} else if let Some(macro_def) = self.eat_macro_def(
|
||||
|
|
@ -54,7 +54,7 @@ impl<'a> Parser<'a> {
|
|||
)? {
|
||||
Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: StmtKind::Item(macro_def),
|
||||
kind: StmtKind::Item(macro_def),
|
||||
span: lo.to(self.prev_span),
|
||||
}
|
||||
// Starts like a simple path, being careful to avoid contextual keywords
|
||||
|
|
@ -86,7 +86,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
return Ok(Some(Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: StmtKind::Expr(expr),
|
||||
kind: StmtKind::Expr(expr),
|
||||
span: lo.to(self.prev_span),
|
||||
}));
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ impl<'a> Parser<'a> {
|
|||
span: lo.to(hi),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
};
|
||||
let node = if delim == MacDelimiter::Brace ||
|
||||
let kind = if delim == MacDelimiter::Brace ||
|
||||
self.token == token::Semi || self.token == token::Eof {
|
||||
StmtKind::Mac(P((mac, style, attrs.into())))
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ impl<'a> Parser<'a> {
|
|||
Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
span: lo.to(hi),
|
||||
node,
|
||||
kind,
|
||||
}
|
||||
} else {
|
||||
// FIXME: Bad copy of attrs
|
||||
|
|
@ -150,7 +150,7 @@ impl<'a> Parser<'a> {
|
|||
Some(i) => Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
span: lo.to(i.span),
|
||||
node: StmtKind::Item(i),
|
||||
kind: StmtKind::Item(i),
|
||||
},
|
||||
None => {
|
||||
let unused_attrs = |attrs: &[Attribute], s: &mut Self| {
|
||||
|
|
@ -180,7 +180,7 @@ impl<'a> Parser<'a> {
|
|||
return Ok(Some(Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
span: lo.to(last_semi),
|
||||
node: StmtKind::Semi(self.mk_expr(lo.to(last_semi),
|
||||
kind: StmtKind::Semi(self.mk_expr(lo.to(last_semi),
|
||||
ExprKind::Tup(Vec::new()),
|
||||
ThinVec::new()
|
||||
)),
|
||||
|
|
@ -198,7 +198,7 @@ impl<'a> Parser<'a> {
|
|||
Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
span: lo.to(e.span),
|
||||
node: StmtKind::Expr(e),
|
||||
kind: StmtKind::Expr(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -400,7 +400,7 @@ impl<'a> Parser<'a> {
|
|||
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
|
||||
Some(Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)),
|
||||
kind: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)),
|
||||
span: self.token.span,
|
||||
})
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ impl<'a> Parser<'a> {
|
|||
None => return Ok(None),
|
||||
};
|
||||
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
StmtKind::Expr(ref expr) if self.token != token::Eof => {
|
||||
// expression without semicolon
|
||||
if classify::expr_requires_semi_to_be_stmt(expr) {
|
||||
|
|
@ -443,7 +443,7 @@ impl<'a> Parser<'a> {
|
|||
self.recover_stmt();
|
||||
// Don't complain about type errors in body tail after parse error (#57383).
|
||||
let sp = expr.span.to(self.prev_span);
|
||||
stmt.node = StmtKind::Expr(DummyResult::raw_expr(sp, true));
|
||||
stmt.kind = StmtKind::Expr(DummyResult::raw_expr(sp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1630,7 +1630,7 @@ impl<'a> State<'a> {
|
|||
|
||||
crate fn print_stmt(&mut self, st: &ast::Stmt) {
|
||||
self.maybe_print_comment(st.span.lo());
|
||||
match st.node {
|
||||
match st.kind {
|
||||
ast::StmtKind::Local(ref loc) => {
|
||||
self.print_outer_attributes(&loc.attrs);
|
||||
self.space_if_not_bol();
|
||||
|
|
@ -1703,7 +1703,7 @@ impl<'a> State<'a> {
|
|||
self.print_inner_attributes(attrs);
|
||||
|
||||
for (i, st) in blk.stmts.iter().enumerate() {
|
||||
match st.node {
|
||||
match st.kind {
|
||||
ast::StmtKind::Expr(ref expr) if i == blk.stmts.len() - 1 => {
|
||||
self.maybe_print_comment(st.span.lo());
|
||||
self.space_if_not_bol();
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) {
|
|||
}
|
||||
|
||||
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
|
||||
match statement.node {
|
||||
match statement.kind {
|
||||
StmtKind::Local(ref local) => visitor.visit_local(local),
|
||||
StmtKind::Item(ref item) => visitor.visit_item(item),
|
||||
StmtKind::Expr(ref expression) | StmtKind::Semi(ref expression) => {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P<ast::Expr>) -> ast
|
|||
});
|
||||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::StmtKind::Local(local),
|
||||
kind: ast::StmtKind::Local(local),
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue