diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 1df09429e51..987745722d6 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> { } fn check_expr_attributes(&self, expr: &hir::Expr) { - let target = match expr.node { + let target = match expr.kind { hir::ExprKind::Closure(..) => Target::Closure, _ => Target::Expression, }; diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 91fc004b893..083bc00b34b 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -992,7 +992,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_id(expression.hir_id); walk_list!(visitor, visit_attribute, expression.attrs.iter()); - match expression.node { + match expression.kind { ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f861499cfe4..b951614511d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3378,7 +3378,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool { } }; - match expr.node { + match expr.kind { // All built-in range literals but `..=` and `..` desugar to `Struct`s. ExprKind::Struct(ref qpath, _, _) => { if let QPath::Resolved(None, ref path) = **qpath { @@ -3393,7 +3393,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool { // `..=` desugars into `::std::ops::RangeInclusive::new(...)`. ExprKind::Call(ref func, _) => { - if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node { + if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind { if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node { let new_call = segment.ident.as_str() == "new"; return is_range_path(&path) && is_lit(sess, &expr.span) && new_call; diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 90b6c9474ac..ba6164b2a11 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -17,7 +17,7 @@ impl LoweringContext<'_> { } pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr { - let kind = match e.node { + let kind = match e.kind { ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))), ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::Repeat(ref expr, ref count) => { @@ -184,7 +184,7 @@ impl LoweringContext<'_> { hir::Expr { hir_id: self.lower_node_id(e.id), - node: kind, + kind, span: e.span, attrs: e.attrs.clone(), } @@ -282,7 +282,7 @@ impl LoweringContext<'_> { // Handle then + scrutinee: let then_expr = self.lower_block_expr(then); - let (then_pat, scrutinee, desugar) = match cond.node { + let (then_pat, scrutinee, desugar) = match cond.kind { // ` => `: ExprKind::Let(ref pat, ref scrutinee) => { let scrutinee = self.lower_expr(scrutinee); @@ -332,7 +332,7 @@ impl LoweringContext<'_> { // Handle then + scrutinee: let then_expr = self.lower_block_expr(body); - let (then_pat, scrutinee, desugar, source) = match cond.node { + let (then_pat, scrutinee, desugar, source) = match cond.kind { ExprKind::Let(ref pat, ref scrutinee) => { // to: // @@ -459,7 +459,7 @@ impl LoweringContext<'_> { }); // `static || -> { body }`: - let generator_node = hir::ExprKind::Closure( + let generator_kind = hir::ExprKind::Closure( capture_clause, decl, body_id, @@ -468,7 +468,7 @@ impl LoweringContext<'_> { ); let generator = hir::Expr { hir_id: self.lower_node_id(closure_node_id), - node: generator_node, + kind: generator_kind, span, attrs: ThinVec::new(), }; @@ -625,7 +625,7 @@ impl LoweringContext<'_> { // loop { .. } let loop_expr = P(hir::Expr { hir_id: loop_hir_id, - node: hir::ExprKind::Loop( + kind: hir::ExprKind::Loop( loop_block, None, hir::LoopSource::Loop, @@ -1135,14 +1135,14 @@ impl LoweringContext<'_> { )); // `[opt_ident]: loop { ... }` - let loop_expr = hir::ExprKind::Loop( + let kind = hir::ExprKind::Loop( loop_block, self.lower_label(opt_label), hir::LoopSource::ForLoop, ); let loop_expr = P(hir::Expr { hir_id: self.lower_node_id(e.id), - node: loop_expr, + kind, span: e.span, attrs: ThinVec::new(), }); @@ -1443,15 +1443,10 @@ impl LoweringContext<'_> { pub(super) fn expr( &mut self, span: Span, - node: hir::ExprKind, + kind: hir::ExprKind, attrs: ThinVec ) -> hir::Expr { - hir::Expr { - hir_id: self.next_id(), - node, - span, - attrs, - } + hir::Expr { hir_id: self.next_id(), kind, span, attrs } } fn field(&mut self, ident: Ident, expr: P, span: Span) -> hir::Field { diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 351f5818f7e..c7e70d93041 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -58,7 +58,7 @@ impl MaybeFnLike for ast::TraitItem { impl MaybeFnLike for ast::Expr { fn is_fn_like(&self) -> bool { - match self.node { + match self.kind { ast::ExprKind::Closure(..) => true, _ => false, } @@ -241,7 +241,7 @@ impl<'a> FnLikeNode<'a> { _ => bug!("impl method FnLikeNode that is not fn-like") } }, - map::Node::Expr(e) => match e.node { + map::Node::Expr(e) => match e.kind { ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)), _ => bug!("expr FnLikeNode that is not fn-like"), diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index d1cc7a8ce98..42a76a721a3 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -271,7 +271,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_expr(&mut self, expr: &'a Expr) { - let parent_def = match expr.node { + let parent_def = match expr.kind { ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id), ExprKind::Closure(_, asyncness, ..) => { // Async closures desugar to closures inside of closures, so @@ -312,7 +312,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { if let token::NtExpr(ref expr) = *nt { - if let ExprKind::Mac(..) = expr.node { + if let ExprKind::Mac(..) = expr.kind { self.visit_macro_invoc(expr.id); } } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 956cb36c6b1..f4ac3992111 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -71,7 +71,7 @@ impl<'hir> Entry<'hir> { } Node::Expr(ref expr) => { - match expr.node { + match expr.kind { ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl), _ => None, } @@ -111,7 +111,7 @@ impl<'hir> Entry<'hir> { Node::AnonConst(constant) => Some(constant.body), Node::Expr(expr) => { - match expr.node { + match expr.kind { ExprKind::Closure(.., body, _, _) => Some(body), _ => None, } @@ -468,7 +468,7 @@ impl<'hir> Map<'hir> { Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => { BodyOwnerKind::Static(m) } - Node::Expr(&Expr { node: ExprKind::Closure(..), .. }) => { + Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => { BodyOwnerKind::Closure } node => bug!("{:#?} is not a body node", node), @@ -634,7 +634,7 @@ impl<'hir> Map<'hir> { Some(Node::TraitItem(_)) | Some(Node::ImplItem(_)) => true, Some(Node::Expr(e)) => { - match e.node { + match e.kind { ExprKind::Closure(..) => true, _ => false, } @@ -749,7 +749,7 @@ impl<'hir> Map<'hir> { Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | - Node::Expr(Expr { node: ExprKind::Closure(..), ..}) | + Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) | Node::ImplItem(_) => true, _ => false, } @@ -757,7 +757,7 @@ impl<'hir> Map<'hir> { let match_non_returning_block = |node: &Node<'_>| { match *node { Node::Expr(ref expr) => { - match expr.node { + match expr.kind { ExprKind::Loop(..) | ExprKind::Ret(..) => true, _ => false, } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 6fdc126e216..2657dbfd7ad 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1434,7 +1434,7 @@ pub struct AnonConst { #[derive(RustcEncodable, RustcDecodable)] pub struct Expr { pub hir_id: HirId, - pub node: ExprKind, + pub kind: ExprKind, pub attrs: ThinVec, pub span: Span, } @@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72); impl Expr { pub fn precedence(&self) -> ExprPrecedence { - match self.node { + match self.kind { ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Call(..) => ExprPrecedence::Call, @@ -1478,7 +1478,7 @@ impl Expr { } pub fn is_place_expr(&self) -> bool { - match self.node { + match self.kind { ExprKind::Path(QPath::Resolved(_, ref path)) => { match path.res { Res::Local(..) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 3cbc9ebec0a..d5140141d7e 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1035,7 +1035,7 @@ impl<'a> State<'a> { /// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in /// `if cond { ... }`. pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) { - let needs_par = match expr.node { + let needs_par = match expr.kind { // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. hir::ExprKind::Closure(..) | @@ -1119,11 +1119,10 @@ impl<'a> State<'a> { } fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) { - let prec = - match func.node { - hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, - _ => parser::PREC_POSTFIX, - }; + let prec = match func.kind { + hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, + _ => parser::PREC_POSTFIX, + }; self.print_expr_maybe_paren(func, prec); self.print_call_post(args) @@ -1161,7 +1160,7 @@ impl<'a> State<'a> { Fixity::None => (prec + 1, prec + 1), }; - let left_prec = match (&lhs.node, op.node) { + let left_prec = match (&lhs.kind, op.node) { // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead // of `(x as i32) < ...`. We need to convince it _not_ to do that. @@ -1200,7 +1199,7 @@ impl<'a> State<'a> { self.print_outer_attributes(&expr.attrs); self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); - match expr.node { + match expr.kind { hir::ExprKind::Box(ref expr) => { self.word_space("box"); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); @@ -1803,7 +1802,7 @@ impl<'a> State<'a> { } self.word_space("=>"); - match arm.body.node { + match arm.body.kind { hir::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident); @@ -2222,7 +2221,7 @@ impl<'a> State<'a> { // // Duplicated from `parse::classify`, but adapted for the HIR. fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { - match e.node { + match e.kind { hir::ExprKind::Match(..) | hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) => false, @@ -2273,7 +2272,7 @@ fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp { /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not. fn contains_exterior_struct_lit(value: &hir::Expr) -> bool { - match value.node { + match value.kind { hir::ExprKind::Struct(..) => true, hir::ExprKind::Assign(ref lhs, ref rhs) | diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index cc532cb064e..3442881e0f4 100644 --- a/src/librustc/hir/upvars.rs +++ b/src/librustc/hir/upvars.rs @@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(..) = expr.node { + if let hir::ExprKind::Closure(..) = expr.kind { let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id); if let Some(upvars) = self.tcx.upvars(closure_def_id) { // Every capture of a closure expression is a local in scope, diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 6e6492d0426..7f83fe95c13 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -173,12 +173,12 @@ impl<'a> HashStable> for hir::Expr { let hir::Expr { hir_id: _, ref span, - ref node, + ref kind, ref attrs } = *self; span.hash_stable(hcx, hasher); - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); }) } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index f28a52a1d8d..13de626b996 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> { let span = scope.span(self, region_scope_tree); let tag = match self.hir().find(scope.hir_id(region_scope_tree)) { Some(Node::Block(_)) => "block", - Some(Node::Expr(expr)) => match expr.node { + Some(Node::Expr(expr)) => match expr.kind { hir::ExprKind::Call(..) => "call", hir::ExprKind::MethodCall(..) => "method call", hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let", @@ -639,7 +639,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { hir::MatchSource::TryDesugar => { if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found { let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id); - let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node { + let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.kind { let arg_expr = args.first().expect("try desugaring call w/out arg"); self.in_progress_tables.and_then(|tables| { tables.borrow().expr_ty_opt(arg_expr) diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index d56a6cf1f7b..1df60dfc63e 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -92,10 +92,10 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr) { if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = ( - &expr.node, + &expr.kind, self.node_matches_type(expr.hir_id), ) { - self.found_closure = Some(&expr.node); + self.found_closure = Some(&expr.kind); } intravisit::walk_expr(self, expr); } @@ -114,7 +114,7 @@ fn closure_return_type_suggestion( FunctionRetTy::DefaultReturn(_) => ("-> ", " "), _ => ("", ""), }; - let suggestion = match body.value.node { + let suggestion = match body.value.kind { ExprKind::Block(..) => { vec![(output.span(), format!("{}{}{}", arrow, ret, post))] } diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index f5a4dac2c2c..9231e4f779e 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { let hir = &self.tcx().hir(); if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) { if let Node::Expr(Expr { - node: Closure(_, _, _, closure_span, None), + kind: Closure(_, _, _, closure_span, None), .. }) = hir.get(hir_id) { let sup_sp = sup_origin.span(); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 821ede37229..b31b25d6bee 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => { let res = self.tables.qpath_res(qpath, expr.hir_id); self.handle_res(res); diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 1b1491a8feb..a30b1214a22 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_adjustment(expr); - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => { } hir::ExprKind::Type(ref subexpr, _) => { diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 73a2e7dff6b..ecca62349c9 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -150,7 +150,7 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let res = if let hir::ExprKind::Path(ref qpath) = expr.node { + let res = if let hir::ExprKind::Path(ref qpath) = expr.kind { self.tables.qpath_res(qpath, expr.hir_id) } else { Res::Err diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 9f6611712a8..6b539ec544d 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -456,7 +456,7 @@ fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) { } fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) { - match expr.node { + match expr.kind { // live nodes required for uses or definitions of variables: hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res); @@ -991,7 +991,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)); - match expr.node { + match expr.kind { // Interesting cases with control flow or which gen/kill hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) @@ -1259,7 +1259,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // these errors are detected in the later pass borrowck. We // just ignore such cases and treat them as reads. - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => succ, hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), _ => self.propagate_through_expr(expr, succ) @@ -1268,7 +1268,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // see comment on propagate_through_place() fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { - match expr.node { + match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, acc) } @@ -1377,7 +1377,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { } fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Assign(ref l, _) => { this.check_place(&l); } @@ -1420,7 +1420,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { impl<'tcx> Liveness<'_, 'tcx> { fn check_place(&mut self, expr: &'tcx Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { if let Res::Local(var_hid) = path.res { let upvars = self.ir.tcx.upvars(self.ir.body_owner); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index e0149a3b9de..fe28c6d21fc 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; - match expr.node { + match expr.kind { hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { if self.tables.is_method_call(expr) { self.cat_overloaded_place(expr, e_base, NoteNone) diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index c2bcd462163..57119a5e236 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -100,7 +100,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let res = match expr.node { + let res = match expr.kind { hir::ExprKind::Path(ref qpath) => { Some(self.tables.qpath_res(qpath, expr.hir_id)) } @@ -313,7 +313,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::ImplItemKind::TyAlias(_) => {} } } - Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => { + Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(.., body, _, _), .. }) => { self.visit_nested_body(body); } // Nothing to recurse on for these diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 87470140e31..63e925346d7 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -893,7 +893,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h let mut terminating = |id: hir::ItemLocalId| { terminating_scopes.insert(id); }; - match expr.node { + match expr.kind { // Conditional or repeating scopes are always terminating // scopes, meaning that temporaries cannot outlive them. // This ensures fixed size stacks. @@ -996,7 +996,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h // properly, we can't miss any types. - match expr.node { + match expr.kind { // Manually recurse over closures, because they are the only // case of nested bodies that share the parent environment. hir::ExprKind::Closure(.., body, _, _) => { @@ -1053,7 +1053,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h debug!("resolve_expr post-increment {}, expr = {:?}", visitor.expr_and_pat_count, expr); - if let hir::ExprKind::Yield(_, source) = &expr.node { + if let hir::ExprKind::Yield(_, source) = &expr.kind { // Mark this expr's scope and all parent scopes as containing `yield`. let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node }; loop { @@ -1240,7 +1240,7 @@ fn resolve_local<'tcx>( expr: &hir::Expr, blk_id: Option, ) { - match expr.node { + match expr.kind { hir::ExprKind::AddrOf(_, ref subexpr) => { record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); record_rvalue_scope(visitor, &subexpr, blk_id); @@ -1300,7 +1300,7 @@ fn resolve_local<'tcx>( // outer expression. visitor.scope_tree.record_rvalue_scope(expr.hir_id.local_id, blk_scope); - match expr.node { + match expr.kind { hir::ExprKind::AddrOf(_, ref subexpr) | hir::ExprKind::Unary(hir::UnDeref, ref subexpr) | hir::ExprKind::Field(ref subexpr, _) | diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index d833a34385b..1054df767d6 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -1214,7 +1214,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { } fn expression_label(ex: &hir::Expr) -> Option { - if let hir::ExprKind::Loop(_, Some(label), _) = ex.node { + if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind { Some(label.ident) } else { None diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0683940af98..849eed957a8 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -956,7 +956,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let parent_node = self.tcx.hir().get_parent_node(hir_id); if let Some(Node::Local(ref local)) = self.tcx.hir().find(parent_node) { if let Some(ref expr) = local.init { - if let hir::ExprKind::Index(_, _) = expr.node { + if let hir::ExprKind::Index(_, _) = expr.kind { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) { err.span_suggestion( expr.span, @@ -1110,7 +1110,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .. })) = node { let body = hir.body(*body_id); - if let hir::ExprKind::Block(blk, _) = &body.value.node { + if let hir::ExprKind::Block(blk, _) = &body.value.kind { if decl.output.span().overlaps(span) && blk.expr.is_none() && "()" == &trait_ref.self_ty().to_string() { @@ -1134,7 +1134,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec) { match node { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(_, ref _decl, id, span, _), + kind: hir::ExprKind::Closure(_, ref _decl, id, span, _), .. }) => { (self.tcx.sess.source_map().def_span(span), diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6c3bb3ebb77..b587250bf7c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -604,7 +604,7 @@ impl<'tcx> TypeckTables<'tcx> { pub fn is_method_call(&self, expr: &hir::Expr) -> bool { // Only paths and method calls/overloaded operators have // entries in type_dependent_defs, ignore the former here. - if let hir::ExprKind::Path(_) = expr.node { + if let hir::ExprKind::Path(_) = expr.kind { return false; } diff --git a/src/librustc_ast_borrowck/borrowck/check_loans.rs b/src/librustc_ast_borrowck/borrowck/check_loans.rs index fcede3eae97..dd2aeb4276f 100644 --- a/src/librustc_ast_borrowck/borrowck/check_loans.rs +++ b/src/librustc_ast_borrowck/borrowck/check_loans.rs @@ -177,7 +177,7 @@ pub fn check_loans<'a, 'tcx>( let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap(); let movable_generator = !match bccx.tcx.hir().get(hir_id) { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), + kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => true, _ => false, diff --git a/src/librustc_ast_borrowck/borrowck/mod.rs b/src/librustc_ast_borrowck/borrowck/mod.rs index 23d5480c605..40e28299a5c 100644 --- a/src/librustc_ast_borrowck/borrowck/mod.rs +++ b/src/librustc_ast_borrowck/borrowck/mod.rs @@ -338,7 +338,7 @@ pub enum LoanPathElem<'tcx> { fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId { let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id); match tcx.hir().get(closure_id) { - Node::Expr(expr) => match expr.node { + Node::Expr(expr) => match expr.kind { hir::ExprKind::Closure(.., body_id, _, _) => { body_id.hir_id } diff --git a/src/librustc_ast_borrowck/cfg/construct.rs b/src/librustc_ast_borrowck/cfg/construct.rs index e2c5de648a2..48d0699c146 100644 --- a/src/librustc_ast_borrowck/cfg/construct.rs +++ b/src/librustc_ast_borrowck/cfg/construct.rs @@ -163,7 +163,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex { - match expr.node { + match expr.kind { hir::ExprKind::Block(ref blk, _) => { let blk_exit = self.block(&blk, pred); self.add_ast_node(expr.hir_id.local_id, &[blk_exit]) diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index b81f814de0f..12d325d5939 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -834,7 +834,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt { let expr = P(ast::Expr { id: sess.next_node_id(), - node: ast::ExprKind::Block(P(b), None), + kind: ast::ExprKind::Block(P(b), None), span: syntax_pos::DUMMY_SP, attrs: ThinVec::new(), }); @@ -848,7 +848,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess); let loop_expr = P(ast::Expr { - node: ast::ExprKind::Loop(P(empty_block), None), + kind: ast::ExprKind::Loop(P(empty_block), None), id: self.sess.next_node_id(), span: syntax_pos::DUMMY_SP, attrs: ThinVec::new(), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d08fd47dc16..875f16241a6 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -67,7 +67,7 @@ declare_lint_pass!(WhileTrue => [WHILE_TRUE]); /// Traverse through any amount of parenthesis and return the first non-parens expression. fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr { - while let ast::ExprKind::Paren(sub) = &expr.node { + while let ast::ExprKind::Paren(sub) = &expr.kind { expr = sub; } expr @@ -75,8 +75,8 @@ fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr { impl EarlyLintPass for WhileTrue { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { - if let ast::ExprKind::While(cond, ..) = &e.node { - if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).node { + if let ast::ExprKind::While(cond, ..) = &e.kind { + if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind { if let ast::LitKind::Bool(true) = lit.node { if !lit.span.from_expansion() { let msg = "denote infinite loops with `loop { ... }`"; @@ -224,7 +224,7 @@ impl EarlyLintPass for UnsafeCode { } fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { - if let ast::ExprKind::Block(ref blk, _) = e.node { + if let ast::ExprKind::Block(ref blk, _) = e.kind { // Don't warn about generated blocks; that'll just pollute the output. if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) { self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); @@ -932,7 +932,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { (cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) -> Option<(Ty<'tcx>, Ty<'tcx>)> { - let def = if let hir::ExprKind::Path(ref qpath) = expr.node { + let def = if let hir::ExprKind::Path(ref qpath) = expr.kind { cx.tables.qpath_res(qpath, expr.hir_id) } else { return None; @@ -1900,7 +1900,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { fn is_zero(expr: &hir::Expr) -> bool { use hir::ExprKind::*; use syntax::ast::LitKind::*; - match &expr.node { + match &expr.kind { Lit(lit) => if let Int(i, _) = lit.node { i == 0 @@ -1923,8 +1923,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { const TRANSMUTE_PATH: &[Symbol] = &[sym::core, sym::intrinsics, kw::Invalid, sym::transmute]; - if let hir::ExprKind::Call(ref path_expr, ref args) = expr.node { - if let hir::ExprKind::Path(ref qpath) = path_expr.node { + if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind { + if let hir::ExprKind::Path(ref qpath) = path_expr.kind { let def_id = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id()?; if cx.match_def_path(def_id, ZEROED_PATH) { diff --git a/src/librustc_lint/redundant_semicolon.rs b/src/librustc_lint/redundant_semicolon.rs index 7c9df3578b5..0bfd4c3afc9 100644 --- a/src/librustc_lint/redundant_semicolon.rs +++ b/src/librustc_lint/redundant_semicolon.rs @@ -13,7 +13,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 ExprKind::Tup(ref v) = &expr.node { + if let ExprKind::Tup(ref v) = &expr.kind { if v.is_empty() { // Strings of excess semicolons are encoded as empty tuple expressions // during the parsing stage, so we check for empty tuple expressions diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 3a037b4dfff..eacfe4be9e5 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -72,7 +72,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>( ) -> bool { // We only want to handle exclusive (`..`) ranges, // which are represented as `ExprKind::Struct`. - if let ExprKind::Struct(_, eps, _) = &parent_expr.node { + if let ExprKind::Struct(_, eps, _) = &parent_expr.kind { if eps.len() != 2 { return false; } @@ -279,7 +279,7 @@ fn lint_int_literal<'a, 'tcx>( let par_id = cx.tcx.hir().get_parent_node(e.hir_id); if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) { - if let hir::ExprKind::Struct(..) = par_e.node { + if let hir::ExprKind::Struct(..) = par_e.kind { if is_range_literal(cx.sess(), par_e) && lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t) { @@ -318,7 +318,7 @@ fn lint_uint_literal<'a, 'tcx>( if lit_val < min || lit_val > max { let parent_id = cx.tcx.hir().get_parent_node(e.hir_id); if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { - match par_e.node { + match par_e.kind { hir::ExprKind::Cast(..) => { if let ty::Char = cx.tables.expr_ty(par_e).kind { let mut err = cx.struct_span_lint( @@ -400,7 +400,7 @@ fn lint_literal<'a, 'tcx>( impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref expr) => { // propagate negation, if the negation itself isn't negated if self.negated_expr_id != e.hir_id { @@ -445,7 +445,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { l: &hir::Expr, r: &hir::Expr) -> bool { - let (lit, expr, swap) = match (&l.node, &r.node) { + let (lit, expr, swap) = match (&l.kind, &r.kind) { (&hir::ExprKind::Lit(_), _) => (l, r, true), (_, &hir::ExprKind::Lit(_)) => (r, l, false), _ => return true, @@ -456,7 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { match cx.tables.node_type(expr.hir_id).kind { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); - let lit_val: i128 = match lit.node { + let lit_val: i128 = match lit.kind { hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | @@ -470,7 +470,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } ty::Uint(uint_ty) => { let (min, max) :(u128, u128) = uint_ty_range(uint_ty); - let lit_val: u128 = match lit.node { + let lit_val: u128 = match lit.kind { hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, _) => v, diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 86df0b9f681..cd9cebd6c6f 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { _ => return, }; - if let hir::ExprKind::Ret(..) = expr.node { + if let hir::ExprKind::Ret(..) = expr.kind { return; } @@ -52,9 +52,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { let mut fn_warned = false; let mut op_warned = false; - let maybe_def_id = match expr.node { + let maybe_def_id = match expr.kind { hir::ExprKind::Call(ref callee, _) => { - match callee.node { + match callee.kind { hir::ExprKind::Path(ref qpath) => { match cx.tables.qpath_res(qpath, callee.hir_id) { Res::Def(DefKind::Fn, def_id) @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { return; } - let must_use_op = match expr.node { + let must_use_op = match expr.kind { // Hardcoding operators here seemed more expedient than the // refactoring that would be needed to look up the `#[must_use]` // attribute which does exist on the comparison trait methods @@ -193,7 +193,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } ty::Tuple(ref tys) => { let mut has_emitted = false; - let spans = if let hir::ExprKind::Tup(comps) = &expr.node { + let spans = if let hir::ExprKind::Tup(comps) = &expr.kind { debug_assert_eq!(comps.len(), tys.len()); comps.iter().map(|e| e.span).collect() } else { @@ -270,7 +270,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::ExprKind::Path(_) = expr.node { + if let hir::ExprKind::Path(_) = expr.kind { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); } } @@ -363,7 +363,7 @@ declare_lint_pass!(UnusedParens => [UNUSED_PARENS]); impl UnusedParens { fn is_expr_parens_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool { - followed_by_block && match inner.node { + followed_by_block && match inner.kind { ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true, _ => parser::contains_exterior_struct_lit(&inner), } @@ -376,7 +376,7 @@ impl UnusedParens { followed_by_block: bool, left_pos: Option, right_pos: Option) { - match value.node { + match value.kind { ast::ExprKind::Paren(ref inner) => { if !Self::is_expr_parens_necessary(inner, followed_by_block) && value.attrs.is_empty() { @@ -501,7 +501,7 @@ impl UnusedParens { impl EarlyLintPass for UnusedParens { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { use syntax::ast::ExprKind::*; - let (value, msg, followed_by_block, left_pos, right_pos) = match e.node { + let (value, msg, followed_by_block, left_pos, right_pos) = match e.kind { Let(ref pat, ..) => { self.check_unused_parens_pat(cx, pat, false, false); return; @@ -663,7 +663,7 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Box(_) => {} _ => return, } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 8a68581ff8b..c8402018570 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1810,7 +1810,7 @@ impl EncodeContext<'tcx> { } fn encode_info_for_expr(&mut self, expr: &hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Closure(..) => { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.record(def_id, EncodeContext::encode_info_for_closure, def_id); diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index c0c0e7a32b6..dc7e4b22065 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -890,7 +890,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { def_id, target_place, places ); let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?; - let expr = &self.infcx.tcx.hir().expect_expr(hir_id).node; + let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); if let hir::ExprKind::Closure( .., args_span, _ diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index b12af1a0e95..811ad6bb466 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -236,7 +236,7 @@ fn do_mir_borrowck<'a, 'tcx>( let movable_generator = match tcx.hir().get(id) { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), + kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => false, _ => true, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 90e5480d2fb..b39378f0cb7 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -292,7 +292,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { if let DefiningTy::Closure(def_id, substs) = def_ty { let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = - tcx.hir().expect_expr(mir_hir_id).node + tcx.hir().expect_expr(mir_hir_id).kind { span } else { @@ -758,7 +758,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) { hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move), + kind: hir::ExprKind::Closure(_, return_ty, _, span, gen_move), .. }) => ( match return_ty.output { @@ -821,7 +821,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let yield_span = match tcx.hir().get(mir_hir_id) { hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Closure(_, _, _, span, _), + kind: hir::ExprKind::Closure(_, _, _, span, _), .. }) => ( tcx.sess.source_map().end_point(*span) diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index cf3d8778da1..0cd32acdb66 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -159,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let ExprKind::Block { body } = expr.kind { if let Some(tail_expr) = &body.expr { let mut expr = tail_expr; - while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.node { + while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.kind { if let Some(subtail_expr) = &subblock.expr { expr = subtail_expr } else { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index b0572df9d08..8b80c9d7d67 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -27,7 +27,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> { // Figure out what primary body this item has. let (body_id, return_ty_span) = match tcx.hir().get(id) { - Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) + Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) | Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. }) | Node::ImplItem( hir::ImplItem { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index a24b14598eb..da1b9ed7693 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -204,7 +204,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( let expr_ty = cx.tables().expr_ty(expr); let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); - let kind = match expr.node { + let kind = match expr.kind { // Here comes the interesting stuff: hir::ExprKind::MethodCall(_, method_span, ref args) => { // Rewrite a.b(c) into UFCS form like Trait::b(a, c) @@ -247,7 +247,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( } } else { let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = - fun.node + fun.kind { // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. expr_ty.ty_adt_def().and_then(|adt_def| { @@ -427,7 +427,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![arg.to_ref()]) } else { - if let hir::ExprKind::Lit(ref lit) = arg.node { + if let hir::ExprKind::Lit(ref lit) = arg.kind { ExprKind::Literal { literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), user_ty: None, @@ -639,7 +639,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( // } // The correct solution would be to add symbolic computations to miri, // so we wouldn't have to compute and store the actual value - let var = if let hir::ExprKind::Path(ref qpath) = source.node { + let var = if let hir::ExprKind::Path(ref qpath) = source.kind { let res = cx.tables().qpath_res(qpath, source.hir_id); cx .tables() diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 3791ae1c41e..a49955b02df 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -59,7 +59,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx hir::Expr) { intravisit::walk_expr(self, ex); - if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.node { + if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.kind { self.check_match(scrut, arms, source); } } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index e42f6125f21..435244965f4 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -933,7 +933,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { /// which would overflow if we tried to evaluate `128_i8` and then negate /// afterwards. fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> { - match expr.node { + match expr.kind { hir::ExprKind::Lit(ref lit) => { let ty = self.tables.expr_ty(expr); match lit_to_const(&lit.node, self.tcx, ty, false) { @@ -954,7 +954,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { hir::ExprKind::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind, hir::ExprKind::Unary(hir::UnNeg, ref expr) => { let ty = self.tables.expr_ty(expr); - let lit = match expr.node { + let lit = match expr.kind { hir::ExprKind::Lit(ref lit) => lit, _ => span_bug!(expr.span, "not a literal: {:?}", expr), }; diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 5b78727fdd5..75d6fcf95ad 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -286,11 +286,11 @@ impl<'a> AstValidator<'a> { // m!(S); // ``` fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) { - match expr.node { + match expr.kind { ExprKind::Lit(..) | ExprKind::Err => {} ExprKind::Path(..) if allow_paths => {} ExprKind::Unary(UnOp::Neg, ref inner) - if match inner.node { ExprKind::Lit(_) => true, _ => false } => {} + if match inner.kind { ExprKind::Lit(_) => true, _ => false } => {} _ => self.err_handler().span_err(expr.span, "arbitrary expressions aren't allowed \ in patterns") } @@ -442,7 +442,7 @@ fn validate_generics_order<'a>( impl<'a> Visitor<'a> for AstValidator<'a> { fn visit_expr(&mut self, expr: &'a Expr) { - match &expr.node { + match &expr.kind { ExprKind::Closure(_, _, _, fn_decl, _, _) => { self.check_fn_decl(fn_decl); } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index dbfbec32a6f..6c9e018fafc 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -54,7 +54,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { } fn visit_expr(&mut self, e: &'hir hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Loop(ref b, _, source) => { self.with_context(Loop(source), |v| v.visit_block(&b)); } @@ -99,7 +99,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { let loop_kind = if loop_id == hir::DUMMY_HIR_ID { None } else { - Some(match self.hir_map.expect_expr(loop_id).node { + Some(match self.hir_map.expect_expr(loop_id).kind { hir::ExprKind::Loop(_, _, source) => source, ref r => span_bug!(e.span, "break label resolved to a non-loop: {:?}", r), diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index d4c3dc917e5..ddc85cd364c 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -280,7 +280,7 @@ fn check_expr_kind<'a, 'tcx>( _ => Promotable }; - let node_result = match e.node { + let kind_result = match e.kind { hir::ExprKind::Box(ref expr) => { let _ = v.check_expr(&expr); NotPromotable @@ -376,7 +376,7 @@ fn check_expr_kind<'a, 'tcx>( } let mut callee = &**callee; loop { - callee = match callee.node { + callee = match callee.kind { hir::ExprKind::Block(ref block, _) => match block.expr { Some(ref tail) => &tail, None => break @@ -385,7 +385,7 @@ fn check_expr_kind<'a, 'tcx>( }; } // The callee is an arbitrary expression, it doesn't necessarily have a definition. - let def = if let hir::ExprKind::Path(ref qpath) = callee.node { + let def = if let hir::ExprKind::Path(ref qpath) = callee.kind { v.tables.qpath_res(qpath, callee.hir_id) } else { Res::Err @@ -553,7 +553,7 @@ fn check_expr_kind<'a, 'tcx>( NotPromotable } }; - ty_result & node_result + ty_result & kind_result } /// Checks the adjustments of an expression. diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index d7f5fdeb00c..a862a7011ef 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1028,7 +1028,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { let res = self.tables.qpath_res(qpath, expr.hir_id); let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); @@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { // Do not check nested expressions if the error already happened. return; } - match expr.node { + match expr.kind { hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => { // Do not report duplicate errors for `x = y` and `match x { ... }`. if self.check_expr_pat_type(rhs.hir_id, rhs.span) { diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 11dcf5b4b00..9f8068fbcf7 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -1120,9 +1120,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } macro_rules! method { - ($visit:ident: $ty:ty, $invoc:path, $walk:ident) => { + ($visit:ident: $ty:ty, $invoc:path, $walk:ident, $kind:ident) => { fn $visit(&mut self, node: &'b $ty) { - if let $invoc(..) = node.node { + if let $invoc(..) = node.$kind { self.visit_invoc(node.id); } else { visit::$walk(self, node); @@ -1132,10 +1132,10 @@ macro_rules! method { } impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { - method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item); - method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr); - method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat); - method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty); + method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, node); + method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind); + method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, node); + method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node); fn visit_item(&mut self, item: &'b Item) { let macro_use = match item.node { @@ -1219,7 +1219,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { if let token::NtExpr(ref expr) = *nt { - if let ast::ExprKind::Mac(..) = expr.node { + if let ast::ExprKind::Mac(..) = expr.kind { self.visit_invoc(expr.id); } } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index aae283b7452..b13b7e2b528 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -221,7 +221,7 @@ impl<'a> PathSource<'a> { ValueNS => "method or associated constant", MacroNS => bug!("associated macro"), }, - PathSource::Expr(parent) => match parent.map(|p| &p.node) { + PathSource::Expr(parent) => match parent.map(|p| &p.kind) { // "function" here means "anything callable" rather than `DefKind::Fn`, // this is not precise but usually more helpful than just "value". Some(&ExprKind::Call(..)) => "function", @@ -1836,7 +1836,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { self.record_candidate_traits_for_expr_if_necessary(expr); // Next, resolve the node. - match expr.node { + match expr.kind { ExprKind::Path(ref qself, ref path) => { self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent)); visit::walk_expr(self, expr); @@ -1968,7 +1968,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { } fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) { - match expr.node { + match expr.kind { ExprKind::Field(_, ident) => { // FIXME(#6890): Even though you can't treat a method like a // field, we need to add any trait methods we find that match diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index cd1689f21cc..e04e56cb945 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -325,7 +325,7 @@ impl<'a> LateResolutionVisitor<'a, '_> { let ns = source.namespace(); let is_expected = &|res| source.is_expected(res); - let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.node { + let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.kind { ExprKind::Field(_, ident) => { err.span_suggestion( expr.span, diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 55f6b91e714..bddc24f9443 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -1461,9 +1461,9 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { } fn visit_expr(&mut self, ex: &'l ast::Expr) { - debug!("visit_expr {:?}", ex.node); + debug!("visit_expr {:?}", ex.kind); self.process_macro_use(ex.span); - match ex.node { + match ex.kind { ast::ExprKind::Struct(ref path, ref fields, ref base) => { let expr_hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ex.id); let hir_expr = self.save_ctxt.tcx.hir().expect_expr(expr_hir_id); @@ -1509,7 +1509,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { } ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) => { self.process_var_decl(pattern); - debug!("for loop, walk sub-expr: {:?}", subexpression.node); + debug!("for loop, walk sub-expr: {:?}", subexpression.kind); self.visit_expr(subexpression); visit::walk_block(self, block); } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 7b1a6a9765b..fe5ef3ed3b7 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -518,7 +518,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { if ty.is_none() || ty.unwrap().kind == ty::Error { return None; } - match expr.node { + match expr.kind { ast::ExprKind::Field(ref sub_ex, ident) => { let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id); let hir_node = match self.tcx.hir().find(sub_ex_hir_id) { @@ -629,14 +629,14 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { } Node::Expr(&hir::Expr { - node: hir::ExprKind::Struct(ref qpath, ..), + kind: hir::ExprKind::Struct(ref qpath, ..), .. }) => { self.tables.qpath_res(qpath, hir_id) } Node::Expr(&hir::Expr { - node: hir::ExprKind::Path(ref qpath), + kind: hir::ExprKind::Path(ref qpath), .. }) | Node::Pat(&hir::Pat { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 339045a4bad..ae9c021d242 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2175,13 +2175,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option { // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments // currently have to be wrapped in curly brackets, so it's necessary to special-case. - let expr = match &expr.node { + let expr = match &expr.kind { ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() => block.expr.as_ref().unwrap(), _ => expr, }; - match &expr.node { + match &expr.kind { ExprKind::Path(hir::QPath::Resolved(_, path)) => match path.res { Res::Def(DefKind::ConstParam, did) => Some(did), _ => None, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 14a07c8c9c7..019a82350bd 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } else { - let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.node { + let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.kind { // Point at the block expr instead of the entire block blk.expr.as_ref().map(|e| e.span).unwrap_or(arm.body.span) } else { @@ -219,7 +219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { coercion.coerce_forced_unit(self, &cause, &mut |err| { if let Some((span, msg)) = &ret_reason { err.span_label(*span, msg.as_str()); - } else if let ExprKind::Block(block, _) = &then_expr.node { + } else if let ExprKind::Block(block, _) = &then_expr.kind { if let Some(expr) = &block.expr { err.span_label(expr.span, "found here".to_string()); } @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let mut remove_semicolon = None; - let error_sp = if let ExprKind::Block(block, _) = &else_expr.node { + let error_sp = if let ExprKind::Block(block, _) = &else_expr.kind { if let Some(expr) = &block.expr { expr.span } else if let Some(stmt) = block.stmts.last() { @@ -345,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Compute `Span` of `then` part of `if`-expression. - let then_sp = if let ExprKind::Block(block, _) = &then_expr.node { + let then_sp = if let ExprKind::Block(block, _) = &then_expr.kind { if let Some(expr) = &block.expr { expr.span } else if let Some(stmt) = block.stmts.last() { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index e1f239d3d08..4d8ec6fb0b8 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -247,7 +247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let hir_id = self.tcx.hir().get_parent_node(hir_id); let parent_node = self.tcx.hir().get(hir_id); if let ( - hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, sp, ..), .. }), + hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, _, _, sp, ..), .. }), hir::ExprKind::Block(..), ) = (parent_node, callee_node) { let start = sp.shrink_to_lo(); @@ -278,13 +278,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut unit_variant = None; if let &ty::Adt(adt_def, ..) = t { if adt_def.is_enum() { - if let hir::ExprKind::Call(ref expr, _) = call_expr.node { + if let hir::ExprKind::Call(ref expr, _) = call_expr.kind { unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id)) } } } - if let hir::ExprKind::Call(ref callee, _) = call_expr.node { + if let hir::ExprKind::Call(ref callee, _) = call_expr.kind { let mut err = type_error_struct!( self.tcx.sess, callee.span, @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.identify_bad_closure_def_and_call( &mut err, call_expr.hir_id, - &callee.node, + &callee.kind, callee.span, ); @@ -318,7 +318,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let mut inner_callee_path = None; - let def = match callee.node { + let def = match callee.kind { hir::ExprKind::Path(ref qpath) => { self.tables.borrow().qpath_res(qpath, callee.hir_id) } @@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MaybeIncorrect, ); } - if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.node { + if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind { inner_callee_path = Some(inner_qpath); self.tables .borrow() @@ -375,8 +375,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } else { bug!( - "call_expr.node should be an ExprKind::Call, got {:?}", - call_expr.node + "call_expr.kind should be an ExprKind::Call, got {:?}", + call_expr.kind ); } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 6c94f833196..0878e72932a 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns whether the expected type is `bool` and the expression is `x = y`. pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool { - if let hir::ExprKind::Assign(..) = expr.node { + if let hir::ExprKind::Assign(..) = expr.kind { return expected == self.tcx.types.bool; } false @@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &hir::Expr, ) -> Option<(Span, &'static str, String)> { - let path = match expr.node { + let path = match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => path, _ => return None }; @@ -255,7 +255,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let param_parent = self.tcx.hir().get_parent_node(*param_hir_id); let (expr_hir_id, closure_fn_decl) = match self.tcx.hir().find(param_parent) { Some(Node::Expr( - hir::Expr { hir_id, node: hir::ExprKind::Closure(_, decl, ..), .. } + hir::Expr { hir_id, kind: hir::ExprKind::Closure(_, decl, ..), .. } )) => (hir_id, decl), _ => return None }; @@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let closure_params_len = closure_fn_decl.inputs.len(); let (method_path, method_span, method_expr) = match (hir, closure_params_len) { (Some(Node::Expr( - hir::Expr { node: hir::ExprKind::MethodCall(path, span, expr), .. } + hir::Expr { kind: hir::ExprKind::MethodCall(path, span, expr), .. } )), 1) => (path, span, expr), _ => return None }; @@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(parent) = self.tcx.hir().find(parent_id) { // Account for fields if let Node::Expr(hir::Expr { - node: hir::ExprKind::Struct(_, fields, ..), .. + kind: hir::ExprKind::Struct(_, fields, ..), .. }) = parent { if let Ok(src) = cm.span_to_snippet(sp) { for field in fields { @@ -351,11 +351,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // and make a good suggestion, so don't bother. let is_macro = sp.from_expansion(); - match (&expr.node, &expected.kind, &checked_ty.kind) { + match (&expr.kind, &expected.kind, &checked_ty.kind) { (_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.kind, &check.kind) { (&ty::Str, &ty::Array(arr, _)) | (&ty::Str, &ty::Slice(arr)) if arr == self.tcx.types.u8 => { - if let hir::ExprKind::Lit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.kind { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("b\"") { return Some((sp, @@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }, (&ty::Array(arr, _), &ty::Str) | (&ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => { - if let hir::ExprKind::Lit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.kind { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("\"") { return Some((sp, @@ -398,7 +398,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if self.can_coerce(ref_ty, expected) { let mut sugg_sp = sp; - if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.node { + if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind { let clone_trait = self.tcx.lang_items().clone_trait().unwrap(); if let ([arg], Some(true), "clone") = ( &args[..], @@ -414,7 +414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } if let Ok(src) = cm.span_to_snippet(sugg_sp) { - let needs_parens = match expr.node { + let needs_parens = match expr.kind { // parenthesize if needed (Issue #46756) hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true, @@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { String::new() }; if let Some(hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Assign(left_expr, _), + kind: hir::ExprKind::Assign(left_expr, _), .. })) = self.tcx.hir().find( self.tcx.hir().get_parent_node(expr.hir_id), @@ -571,7 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut prefix = String::new(); if let Some(hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Struct(_, fields, _), + kind: hir::ExprKind::Struct(_, fields, _), .. })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) { // `expr` is a literal field for a struct, only suggest if appropriate @@ -587,11 +587,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } } - if let hir::ExprKind::Call(path, args) = &expr.node { + if let hir::ExprKind::Call(path, args) = &expr.kind { if let ( hir::ExprKind::Path(hir::QPath::TypeRelative(base_ty, path_segment)), 1, - ) = (&path.node, args.len()) { + ) = (&path.kind, args.len()) { // `expr` is a conversion like `u32::from(val)`, do not suggest anything (#63697). if let ( hir::TyKind::Path(hir::QPath::Resolved(None, base_ty_path)), @@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if needs_paren { ")" } else { "" }, ); let literal_is_ty_suffixed = |expr: &hir::Expr| { - if let hir::ExprKind::Lit(lit) = &expr.node { + if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 97fcfd7151a..58f41ca4f88 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -84,7 +84,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { - let expr = match &expr.node { + let expr = match &expr.kind { ExprKind::DropTemps(expr) => expr, _ => expr, }; @@ -159,7 +159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = self.check_expr_kind(expr, expected, needs); // Warn for non-block expressions with diverging children. - match expr.node { + match expr.kind { ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {}, ExprKind::Call(ref callee, _) => self.warn_if_unreachable(expr.hir_id, callee.span, "call"), @@ -202,7 +202,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let tcx = self.tcx; - match expr.node { + match expr.kind { ExprKind::Box(ref subexpr) => { self.check_expr_box(subexpr, expected) } @@ -602,7 +602,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // ... except when we try to 'break rust;'. // ICE this expression in particular (see #43162). - if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.node { + if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.kind { if path.segments.len() == 1 && path.segments[0].ident.name == sym::rust { fatally_break_rust(self.tcx.sess); @@ -1604,7 +1604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: - if let ExprKind::Lit(ref lit) = idx.node { + if let ExprKind::Lit(ref lit) = idx.kind { if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node { let snip = self.tcx.sess.source_map().span_to_snippet(base.span); if let Ok(snip) = snip { diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 5d4893ae754..9baf06be3f6 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -436,7 +436,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let mut exprs = vec![self.self_expr]; loop { - match exprs.last().unwrap().node { + match exprs.last().unwrap().kind { hir::ExprKind::Field(ref expr, _) | hir::ExprKind::Index(ref expr, _) | hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&expr), @@ -480,7 +480,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.tables.borrow_mut().adjustments_mut().insert(expr.hir_id, adjustments); } - match expr.node { + match expr.kind { hir::ExprKind::Index(ref base_expr, ref index_expr) => { let index_expr_ty = self.node_ty(index_expr.hir_id); self.convert_place_op_to_mutable( diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 408532d1d1e..4b02bc58d66 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -258,7 +258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "f32" }; - match expr.node { + match expr.kind { ExprKind::Lit(ref lit) => { // numeric literal let snippet = tcx.sess.source_map().span_to_snippet(lit.span) @@ -446,7 +446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) { report_function!(expr.span, expr_string); } else if let ExprKind::Path(QPath::Resolved(_, ref path)) = - expr.node + expr.kind { if let Some(segment) = path.segments.last() { report_function!(expr.span, segment.ident); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c1eb65ee956..486f4a1d5f6 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3376,7 +3376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.warn_if_unreachable(arg.hir_id, arg.span, "expression"); } - let is_closure = match arg.node { + let is_closure = match arg.kind { ExprKind::Closure(..) => true, _ => false }; @@ -3495,8 +3495,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { errors: &mut Vec>, call_expr: &'tcx hir::Expr, ) { - if let hir::ExprKind::Call(path, _) = &call_expr.node { - if let hir::ExprKind::Path(qpath) = &path.node { + if let hir::ExprKind::Call(path, _) = &call_expr.kind { + if let hir::ExprKind::Path(qpath) = &path.kind { if let hir::QPath::Resolved(_, path) = &qpath { for error in errors { if let ty::Predicate::Trait(predicate) = error.obligation.predicate { @@ -3912,7 +3912,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// // ^^^^ point at this instead of the whole `if` expression /// ``` fn get_expr_coercion_span(&self, expr: &hir::Expr) -> syntax_pos::Span { - if let hir::ExprKind::Match(_, arms, _) = &expr.node { + if let hir::ExprKind::Match(_, arms, _) = &expr.kind { let arm_spans: Vec = arms.iter().filter_map(|arm| { self.in_progress_tables .and_then(|tables| tables.borrow().node_type_opt(arm.body.hir_id)) @@ -3920,7 +3920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if arm_ty.is_never() { None } else { - Some(match &arm.body.node { + Some(match &arm.body.kind { // Point at the tail expression when possible. hir::ExprKind::Block(block, _) => block.expr .as_ref() @@ -4075,7 +4075,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { node: hir::ImplItemKind::Method(_, body_id), .. }) => { let body = self.tcx.hir().body(body_id); - if let ExprKind::Block(block, _) = &body.value.node { + if let ExprKind::Block(block, _) = &body.value.kind { return Some(block.span); } } @@ -4212,7 +4212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }).collect::>().join(", "); } Some(Node::Expr(hir::Expr { - node: ExprKind::Closure(_, _, body_id, closure_span, _), + kind: ExprKind::Closure(_, _, body_id, closure_span, _), span: full_closure_span, .. })) => { @@ -4388,7 +4388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if expected.is_unit() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. - match expression.node { + match expression.kind { ExprKind::Call(..) | ExprKind::MethodCall(..) | ExprKind::Loop(..) | @@ -4893,7 +4893,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Node::Expr(expr) = self.tcx.hir().get( self.tcx.hir().get_parent_node(hir_id)) { - if let ExprKind::Call(ref callee, ..) = expr.node { + if let ExprKind::Call(ref callee, ..) = expr.kind { if callee.hir_id == hir_id { return } @@ -4968,7 +4968,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { while let hir::Node::Expr(parent_expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id)) { - match &parent_expr.node { + match &parent_expr.kind { hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => { if lhs.hir_id == expr_id { contained_in_place = true; diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index b20b5bb8dc3..77564bf141a 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -306,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Byte string patterns behave the same way as array patterns // They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; - if let hir::ExprKind::Lit(ref lt) = lt.node { + if let hir::ExprKind::Lit(ref lt) = lt.kind { if let ast::LitKind::ByteStr(_) = lt.node { let expected_ty = self.structurally_resolved_type(span, expected); if let ty::Ref(_, r_ty, _) = expected_ty.kind { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 23280542c2b..1ba21651812 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -526,7 +526,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { // arguments for its type parameters are well-formed, and all the regions // provided as arguments outlive the call. if is_method_call { - let origin = match expr.node { + let origin = match expr.kind { hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall, hir::ExprKind::Unary(op, _) if op == hir::UnDeref => { infer::ParameterOrigin::OverloadedDeref @@ -557,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { "regionck::visit_expr(e={:?}, repeating_scope={:?}) - visiting subexprs", expr, self.repeating_scope ); - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => { let substs = self.tables.borrow().node_substs(expr.hir_id); let origin = infer::ParameterOrigin::Path; diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index d57fec9947d..71ea938a803 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -64,7 +64,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.node { + if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind { let body = self.fcx.tcx.hir().body(body_id); self.visit_body(body); self.fcx diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index f3ee64e9d13..b22decf6eb9 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -134,7 +134,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // we observe that something like `a+b` is (known to be) // operating on scalars, we clear the overload. fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref inner) | hir::ExprKind::Unary(hir::UnNot, ref inner) => { let inner_ty = self.fcx.node_ty(inner.hir_id); @@ -159,7 +159,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { tables.type_dependent_defs_mut().remove(e.hir_id); tables.node_substs_mut().remove(e.hir_id); - match e.node { + match e.kind { hir::ExprKind::Binary(..) => { if !op.node.is_by_value() { let mut adjustments = tables.adjustments_mut(); @@ -186,7 +186,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // to use builtin indexing because the index type is known to be // usize-ish fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { - if let hir::ExprKind::Index(ref base, ref index) = e.node { + if let hir::ExprKind::Index(ref base, ref index) = e.kind { let mut tables = self.fcx.tables.borrow_mut(); // All valid indexing looks like this; might encounter non-valid indexes at this point @@ -241,7 +241,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { self.visit_node_id(e.span, e.hir_id); - match e.node { + match e.kind { hir::ExprKind::Closure(_, _, body, _, _) => { let body = self.fcx.tcx.hir().body(body); for param in &body.params { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 82d55e0df59..91975253c81 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -135,7 +135,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(..) = expr.node { + if let hir::ExprKind::Closure(..) = expr.kind { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.tcx.generics_of(def_id); self.tcx.type_of(def_id); @@ -915,7 +915,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { } } Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(..), + kind: hir::ExprKind::Closure(..), .. }) => Some(tcx.closure_base_def_id(def_id)), Node::Item(item) => match item.node { @@ -1072,7 +1072,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { // cares about anything but the length is instantiation, // and we don't do that for closures. if let Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., gen), + kind: hir::ExprKind::Closure(.., gen), .. }) = node { @@ -1355,7 +1355,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option icx.to_ty(&field.ty), Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., gen), + kind: hir::ExprKind::Closure(.., gen), .. }) => { if gen.is_some() { @@ -1381,7 +1381,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { @@ -1400,8 +1400,8 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { let path = match parent_node { Node::Ty(&hir::Ty { @@ -1409,12 +1409,12 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { Some(&**path) } - Node::Expr(&hir::Expr { node: ExprKind::Struct(ref path, ..), .. }) => { + Node::Expr(&hir::Expr { kind: ExprKind::Struct(ref path, ..), .. }) => { if let QPath::Resolved(_, ref path) = **path { Some(&**path) } else { @@ -1847,7 +1847,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { } Expr(&hir::Expr { - node: hir::ExprKind::Closure(..), + kind: hir::ExprKind::Closure(..), .. }) => { // Closure signatures are not like other function diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b634dcca7fc..966e65fd5e5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -977,7 +977,7 @@ pub struct AnonConst { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Expr { pub id: NodeId, - pub node: ExprKind, + pub kind: ExprKind, pub span: Span, pub attrs: ThinVec, } @@ -990,12 +990,12 @@ impl Expr { /// Returns `true` if this expression would be valid somewhere that expects a value; /// for example, an `if` condition. pub fn returns(&self) -> bool { - if let ExprKind::Block(ref block, _) = self.node { + if let ExprKind::Block(ref block, _) = self.kind { match block.stmts.last().map(|last_stmt| &last_stmt.node) { // Implicit return Some(&StmtKind::Expr(_)) => true, Some(&StmtKind::Semi(ref expr)) => { - if let ExprKind::Ret(_) = expr.node { + if let ExprKind::Ret(_) = expr.kind { // Last statement is explicit return. true } else { @@ -1012,7 +1012,7 @@ impl Expr { } fn to_bound(&self) -> Option { - match &self.node { + match &self.kind { ExprKind::Path(None, path) => Some(GenericBound::Trait( PolyTraitRef::new(Vec::new(), path.clone(), self.span), TraitBoundModifier::None, @@ -1022,7 +1022,7 @@ impl Expr { } pub(super) fn to_ty(&self) -> Option> { - let node = match &self.node { + let kind = match &self.kind { ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), ExprKind::Mac(mac) => TyKind::Mac(mac.clone()), ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?, @@ -1051,14 +1051,14 @@ impl Expr { }; Some(P(Ty { - node, + node: kind, id: self.id, span: self.span, })) } pub fn precedence(&self) -> ExprPrecedence { - match self.node { + match self.kind { ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Call(..) => ExprPrecedence::Call, diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 7eeea4e7bdf..0c3922ee96e 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -321,13 +321,13 @@ impl<'a> MutVisitor for StripUnconfigured<'a> { fn visit_expr(&mut self, expr: &mut P) { self.configure_expr(expr); - self.configure_expr_kind(&mut expr.node); + self.configure_expr_kind(&mut expr.kind); noop_visit_expr(expr, self); } fn filter_map_expr(&mut self, expr: P) -> Option> { let mut expr = configure!(self, expr); - self.configure_expr_kind(&mut expr.node); + self.configure_expr_kind(&mut expr.kind); noop_visit_expr(&mut expr, self); Some(expr) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index aa76667c2e9..3079382a3b2 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -507,7 +507,7 @@ impl MacResult for MacEager { return Some(p); } if let Some(e) = self.expr { - if let ast::ExprKind::Lit(_) = e.node { + if let ast::ExprKind::Lit(_) = e.kind { return Some(P(ast::Pat { id: ast::DUMMY_NODE_ID, span: e.span, @@ -549,7 +549,7 @@ impl DummyResult { pub fn raw_expr(sp: Span, is_error: bool) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, + kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, span: sp, attrs: ThinVec::new(), }) @@ -1098,7 +1098,7 @@ pub fn expr_to_spanned_string<'a>( // We want to be able to handle e.g., `concat!("foo", "bar")`. let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); - Err(match expr.node { + Err(match expr.kind { ast::ExprKind::Lit(ref l) => match l.node { ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)), ast::LitKind::Err(_) => None, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f903b66e296..4f61a7e427e 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -73,12 +73,12 @@ impl<'a> ExtCtxt<'a> { self.ty_path(self.path_ident(span, ident)) } - pub fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst { + pub fn anon_const(&self, span: Span, kind: ast::ExprKind) -> ast::AnonConst { ast::AnonConst { id: ast::DUMMY_NODE_ID, value: P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: expr, + kind, span, attrs: ThinVec::new(), }) @@ -239,10 +239,10 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn expr(&self, span: Span, node: ast::ExprKind) -> P { + pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node, + kind, span, attrs: ThinVec::new(), }) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c8078d2bb71..3cec7c1e7ec 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1035,7 +1035,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_expr(&mut self, expr: &mut P) { self.cfg.configure_expr(expr); visit_clobber(expr.deref_mut(), |mut expr| { - self.cfg.configure_expr_kind(&mut expr.node); + self.cfg.configure_expr_kind(&mut expr.kind); // ignore derives so they remain unused let (attr, after_derive) = self.classify_nonitem(&mut expr); @@ -1052,7 +1052,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .into_inner() } - if let ast::ExprKind::Mac(mac) = expr.node { + if let ast::ExprKind::Mac(mac) = expr.kind { self.check_attributes(&expr.attrs); self.collect_bang(mac, expr.span, AstFragmentKind::Expr) .make_expr() @@ -1145,7 +1145,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn filter_map_expr(&mut self, expr: P) -> Option> { let expr = configure!(self, expr); expr.filter_map(|mut expr| { - self.cfg.configure_expr_kind(&mut expr.node); + self.cfg.configure_expr_kind(&mut expr.kind); // Ignore derives so they remain unused. let (attr, after_derive) = self.classify_nonitem(&mut expr); @@ -1159,7 +1159,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .map(|expr| expr.into_inner()) } - if let ast::ExprKind::Mac(mac) = expr.node { + if let ast::ExprKind::Mac(mac) = expr.kind { self.check_attributes(&expr.attrs); self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr) .make_opt_expr() diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 52a0f95bce7..827a2f9da32 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -30,7 +30,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { let expr_placeholder = || P(ast::Expr { id, span, attrs: ThinVec::new(), - node: ast::ExprKind::Mac(mac_placeholder()), + kind: ast::ExprKind::Mac(mac_placeholder()), }); let ty = P(ast::Ty { id, @@ -282,14 +282,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { } fn visit_expr(&mut self, expr: &mut P) { - match expr.node { + match expr.kind { ast::ExprKind::Mac(_) => *expr = self.remove(expr.id).make_expr(), _ => noop_visit_expr(expr, self), } } fn filter_map_expr(&mut self, expr: P) -> Option> { - match expr.node { + match expr.kind { ast::ExprKind::Mac(_) => self.remove(expr.id).make_opt_expr(), _ => noop_filter_map_expr(expr, self), } diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index b50ca1ad1cf..516f3bb0e9e 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -456,7 +456,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_expr(&mut self, e: &'a ast::Expr) { - match e.node { + match e.kind { ast::ExprKind::Box(_) => { gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX); } diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 5a37222ee55..6b7c574b82f 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -1097,8 +1097,8 @@ pub fn noop_visit_anon_const(AnonConst { id, value }: &mut AnonCo vis.visit_expr(value); } -pub fn noop_visit_expr(Expr { node, id, span, attrs }: &mut Expr, vis: &mut T) { - match node { +pub fn noop_visit_expr(Expr { kind, id, span, attrs }: &mut Expr, vis: &mut T) { + match kind { ExprKind::Box(expr) => vis.visit_expr(expr), ExprKind::Array(exprs) => visit_exprs(exprs, vis), ExprKind::Repeat(expr, count) => { diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 6ebfab3a133..44560688750 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -12,7 +12,7 @@ use crate::ast; /// |x| 5 /// isn't parsed as (if true {...} else {...} | x) | 5 pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { - match e.node { + match e.kind { ast::ExprKind::If(..) | ast::ExprKind::Match(..) | ast::ExprKind::Block(..) | diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index 59de5f14123..c73ef982b07 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -161,7 +161,7 @@ impl RecoverQPath for Expr { fn recovered(qself: Option, path: ast::Path) -> Self { Self { span: path.span, - node: ExprKind::Path(qself, path), + kind: ExprKind::Path(qself, path), attrs: ThinVec::new(), id: ast::DUMMY_NODE_ID, } @@ -549,7 +549,7 @@ impl<'a> Parser<'a> { debug_assert!(outer_op.is_comparison(), "check_no_chained_comparison: {:?} is not comparison", outer_op); - match lhs.node { + match lhs.kind { ExprKind::Binary(op, _, _) if op.node.is_comparison() => { // Respan to include both operators. let op_span = op.span.to(self.token.span); @@ -915,7 +915,7 @@ impl<'a> Parser<'a> { .unwrap_or_else(|_| pprust::expr_to_string(&expr)); let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" }); let sp = lo.to(hi); - let app = match expr.node { + let app = match expr.kind { ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await ?` _ => Applicability::MachineApplicable, }; diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index 36233de3cfb..973c54017b6 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -267,7 +267,7 @@ impl Lit { lit, token::Interpolated(ref nt) => { if let token::NtExpr(expr) | token::NtLiteral(expr) = &**nt { - if let ast::ExprKind::Lit(lit) = &expr.node { + if let ast::ExprKind::Lit(lit) = &expr.kind { return Ok(lit.clone()); } } diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index d0c865a7b8e..deb2140f797 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -210,7 +210,7 @@ impl<'a> Parser<'a> { // it refers to. Interpolated identifiers are unwrapped early and never show up here // as `PrevTokenKind::Interpolated` so if LHS is a single identifier we always process // it as "interpolated", it doesn't change the answer for non-interpolated idents. - let lhs_span = match (self.prev_token_kind, &lhs.node) { + let lhs_span = match (self.prev_token_kind, &lhs.kind) { (PrevTokenKind::Interpolated, _) => self.prev_span, (PrevTokenKind::Ident, &ExprKind::Path(None, ref path)) if path.segments.len() == 1 => self.prev_span, @@ -245,7 +245,7 @@ impl<'a> Parser<'a> { lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?; continue } else if op == AssocOp::Colon { - let maybe_path = self.could_ascription_be_path(&lhs.node); + let maybe_path = self.could_ascription_be_path(&lhs.kind); self.last_type_ascription = Some((self.prev_span, maybe_path)); lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?; @@ -614,7 +614,7 @@ impl<'a> Parser<'a> { expr.map(|mut expr| { attrs.extend::>(expr.attrs.into()); expr.attrs = attrs; - match expr.node { + match expr.kind { ExprKind::If(..) if !expr.attrs.is_empty() => { // Just point to the first attribute in there... let span = expr.attrs[0].span; @@ -1242,7 +1242,7 @@ impl<'a> Parser<'a> { fn parse_cond_expr(&mut self) -> PResult<'a, P> { let cond = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; - if let ExprKind::Let(..) = cond.node { + if let ExprKind::Let(..) = cond.kind { // Remove the last feature gating of a `let` expression since it's stable. let last = self.sess.gated_spans.let_chains.borrow_mut().pop(); debug_assert_eq!(cond.span, last.unwrap()); @@ -1779,7 +1779,7 @@ impl<'a> Parser<'a> { Ok(await_expr) } - crate fn mk_expr(&self, span: Span, node: ExprKind, attrs: ThinVec) -> P { - P(Expr { node, span, attrs, id: DUMMY_NODE_ID }) + crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec) -> P { + P(Expr { kind, span, attrs, id: DUMMY_NODE_ID }) } } diff --git a/src/libsyntax/parse/tests.rs b/src/libsyntax/parse/tests.rs index 5cb59b3f827..984a2018e7a 100644 --- a/src/libsyntax/parse/tests.rs +++ b/src/libsyntax/parse/tests.rs @@ -272,7 +272,7 @@ fn ttdelim_span() { let expr = parse_expr_from_source_str(PathBuf::from("foo").into(), "foo!( fn main() { body } )".to_string(), &sess).unwrap(); - let tts: Vec<_> = match expr.node { + let tts: Vec<_> = match expr.kind { ast::ExprKind::Mac(ref mac) => mac.stream().trees().collect(), _ => panic!("not a macro"), }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index bf36c0d2f56..d43b7782413 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1734,33 +1734,30 @@ impl<'a> State<'a> { } fn print_else(&mut self, els: Option<&ast::Expr>) { - match els { - Some(_else) => { - match _else.node { - // Another `else if` block. - ast::ExprKind::If(ref i, ref then, ref e) => { - self.cbox(INDENT_UNIT - 1); - self.ibox(0); - self.s.word(" else if "); - self.print_expr_as_cond(i); - self.s.space(); - self.print_block(then); - self.print_else(e.as_ref().map(|e| &**e)) - } - // Final `else` block. - ast::ExprKind::Block(ref b, _) => { - self.cbox(INDENT_UNIT - 1); - self.ibox(0); - self.s.word(" else "); - self.print_block(b) - } - // Constraints would be great here! - _ => { - panic!("print_if saw if with weird alternative"); - } + if let Some(_else) = els { + match _else.kind { + // Another `else if` block. + ast::ExprKind::If(ref i, ref then, ref e) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else if "); + self.print_expr_as_cond(i); + self.s.space(); + self.print_block(then); + self.print_else(e.as_ref().map(|e| &**e)) + } + // Final `else` block. + ast::ExprKind::Block(ref b, _) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else "); + self.print_block(b) + } + // Constraints would be great here! + _ => { + panic!("print_if saw if with weird alternative"); } } - _ => {} } } @@ -1805,7 +1802,7 @@ impl<'a> State<'a> { /// Does `expr` need parenthesis when printed in a condition position? fn cond_needs_par(expr: &ast::Expr) -> bool { - match expr.node { + match expr.kind { // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. ast::ExprKind::Closure(..) | @@ -1905,7 +1902,7 @@ impl<'a> State<'a> { func: &ast::Expr, args: &[P]) { let prec = - match func.node { + match func.kind { ast::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, _ => parser::PREC_POSTFIX, }; @@ -1941,7 +1938,7 @@ impl<'a> State<'a> { Fixity::None => (prec + 1, prec + 1), }; - let left_prec = match (&lhs.node, op.node) { + let left_prec = match (&lhs.kind, op.node) { // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead // of `(x as i32) < ...`. We need to convince it _not_ to do that. @@ -2000,7 +1997,7 @@ impl<'a> State<'a> { self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); - match expr.node { + match expr.kind { ast::ExprKind::Box(ref expr) => { self.word_space("box"); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); @@ -2477,7 +2474,7 @@ impl<'a> State<'a> { } self.word_space("=>"); - match arm.body.node { + match arm.body.kind { ast::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident); diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index fceaed360cd..982755e8680 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -375,7 +375,7 @@ crate fn needs_par_as_let_scrutinee(order: i8) -> bool { /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not. pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { - match value.node { + match value.kind { ast::ExprKind::Struct(..) => true, ast::ExprKind::Assign(ref lhs, ref rhs) | diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4fc29d70540..c91b9f8bc3a 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -683,7 +683,7 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { walk_list!(visitor, visit_attribute, expression.attrs.iter()); - match expression.node { + match expression.kind { ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 75d727b9fb6..becbf6d60a0 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -61,7 +61,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>, MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::InlineAsm(P(inline_asm)), + kind: ast::ExprKind::InlineAsm(P(inline_asm)), span: cx.with_def_site_ctxt(sp), attrs: ThinVec::new(), })) diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 16f016036ea..ded8f2bc094 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -18,7 +18,7 @@ pub fn expand_concat( let mut missing_literal = vec![]; let mut has_errors = false; for e in es { - match e.node { + match e.kind { ast::ExprKind::Lit(ref lit) => match lit.node { ast::LitKind::Str(ref s, _) | ast::LitKind::Float(ref s, _) diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index f344706d4eb..912eba94b1f 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -47,7 +47,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>, fn make_expr(self: Box) -> Option> { Some(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), + kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), span: self.ident.span, attrs: ThinVec::new(), })) diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 596f515da2f..7e4fd467e13 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -172,7 +172,7 @@ struct RemoveParens; impl MutVisitor for RemoveParens { fn visit_expr(&mut self, e: &mut P) { - match e.node.clone() { + match e.kind.clone() { ExprKind::Paren(inner) => *e = inner, _ => {} }; @@ -190,7 +190,7 @@ impl MutVisitor for AddParens { visit_clobber(e, |e| { P(Expr { id: DUMMY_NODE_ID, - node: ExprKind::Paren(e), + kind: ExprKind::Paren(e), span: DUMMY_SP, attrs: ThinVec::new(), })