1
Fork 0

Rename Expr.node to Expr.kind

For both `ast::Expr` and `hir::Expr`.
This commit is contained in:
varkor 2019-09-26 14:39:48 +01:00
parent ddf43867a9
commit 95f6d72a60
83 changed files with 281 additions and 290 deletions

View file

@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> {
} }
fn check_expr_attributes(&self, expr: &hir::Expr) { fn check_expr_attributes(&self, expr: &hir::Expr) {
let target = match expr.node { let target = match expr.kind {
hir::ExprKind::Closure(..) => Target::Closure, hir::ExprKind::Closure(..) => Target::Closure,
_ => Target::Expression, _ => Target::Expression,
}; };

View file

@ -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) { pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor.visit_id(expression.hir_id); visitor.visit_id(expression.hir_id);
walk_list!(visitor, visit_attribute, expression.attrs.iter()); walk_list!(visitor, visit_attribute, expression.attrs.iter());
match expression.node { match expression.kind {
ExprKind::Box(ref subexpression) => { ExprKind::Box(ref subexpression) => {
visitor.visit_expr(subexpression) visitor.visit_expr(subexpression)
} }

View file

@ -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. // All built-in range literals but `..=` and `..` desugar to `Struct`s.
ExprKind::Struct(ref qpath, _, _) => { ExprKind::Struct(ref qpath, _, _) => {
if let QPath::Resolved(None, ref path) = **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(...)`. // `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
ExprKind::Call(ref func, _) => { 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 { if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
let new_call = segment.ident.as_str() == "new"; let new_call = segment.ident.as_str() == "new";
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call; return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;

View file

@ -17,7 +17,7 @@ impl LoweringContext<'_> {
} }
pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr { 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::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))),
ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
ExprKind::Repeat(ref expr, ref count) => { ExprKind::Repeat(ref expr, ref count) => {
@ -184,7 +184,7 @@ impl LoweringContext<'_> {
hir::Expr { hir::Expr {
hir_id: self.lower_node_id(e.id), hir_id: self.lower_node_id(e.id),
node: kind, kind,
span: e.span, span: e.span,
attrs: e.attrs.clone(), attrs: e.attrs.clone(),
} }
@ -282,7 +282,7 @@ impl LoweringContext<'_> {
// Handle then + scrutinee: // Handle then + scrutinee:
let then_expr = self.lower_block_expr(then); let then_expr = self.lower_block_expr(then);
let (then_pat, scrutinee, desugar) = match cond.node { let (then_pat, scrutinee, desugar) = match cond.kind {
// `<pat> => <then>`: // `<pat> => <then>`:
ExprKind::Let(ref pat, ref scrutinee) => { ExprKind::Let(ref pat, ref scrutinee) => {
let scrutinee = self.lower_expr(scrutinee); let scrutinee = self.lower_expr(scrutinee);
@ -332,7 +332,7 @@ impl LoweringContext<'_> {
// Handle then + scrutinee: // Handle then + scrutinee:
let then_expr = self.lower_block_expr(body); 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) => { ExprKind::Let(ref pat, ref scrutinee) => {
// to: // to:
// //
@ -459,7 +459,7 @@ impl LoweringContext<'_> {
}); });
// `static || -> <ret_ty> { body }`: // `static || -> <ret_ty> { body }`:
let generator_node = hir::ExprKind::Closure( let generator_kind = hir::ExprKind::Closure(
capture_clause, capture_clause,
decl, decl,
body_id, body_id,
@ -468,7 +468,7 @@ impl LoweringContext<'_> {
); );
let generator = hir::Expr { let generator = hir::Expr {
hir_id: self.lower_node_id(closure_node_id), hir_id: self.lower_node_id(closure_node_id),
node: generator_node, kind: generator_kind,
span, span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
}; };
@ -625,7 +625,7 @@ impl LoweringContext<'_> {
// loop { .. } // loop { .. }
let loop_expr = P(hir::Expr { let loop_expr = P(hir::Expr {
hir_id: loop_hir_id, hir_id: loop_hir_id,
node: hir::ExprKind::Loop( kind: hir::ExprKind::Loop(
loop_block, loop_block,
None, None,
hir::LoopSource::Loop, hir::LoopSource::Loop,
@ -1135,14 +1135,14 @@ impl LoweringContext<'_> {
)); ));
// `[opt_ident]: loop { ... }` // `[opt_ident]: loop { ... }`
let loop_expr = hir::ExprKind::Loop( let kind = hir::ExprKind::Loop(
loop_block, loop_block,
self.lower_label(opt_label), self.lower_label(opt_label),
hir::LoopSource::ForLoop, hir::LoopSource::ForLoop,
); );
let loop_expr = P(hir::Expr { let loop_expr = P(hir::Expr {
hir_id: self.lower_node_id(e.id), hir_id: self.lower_node_id(e.id),
node: loop_expr, kind,
span: e.span, span: e.span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
}); });
@ -1443,15 +1443,10 @@ impl LoweringContext<'_> {
pub(super) fn expr( pub(super) fn expr(
&mut self, &mut self,
span: Span, span: Span,
node: hir::ExprKind, kind: hir::ExprKind,
attrs: ThinVec<Attribute> attrs: ThinVec<Attribute>
) -> hir::Expr { ) -> hir::Expr {
hir::Expr { hir::Expr { hir_id: self.next_id(), kind, span, attrs }
hir_id: self.next_id(),
node,
span,
attrs,
}
} }
fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field { fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {

View file

@ -58,7 +58,7 @@ impl MaybeFnLike for ast::TraitItem {
impl MaybeFnLike for ast::Expr { impl MaybeFnLike for ast::Expr {
fn is_fn_like(&self) -> bool { fn is_fn_like(&self) -> bool {
match self.node { match self.kind {
ast::ExprKind::Closure(..) => true, ast::ExprKind::Closure(..) => true,
_ => false, _ => false,
} }
@ -241,7 +241,7 @@ impl<'a> FnLikeNode<'a> {
_ => bug!("impl method FnLikeNode that is not fn-like") _ => 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) => ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)), closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
_ => bug!("expr FnLikeNode that is not fn-like"), _ => bug!("expr FnLikeNode that is not fn-like"),

View file

@ -271,7 +271,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
} }
fn visit_expr(&mut self, expr: &'a Expr) { 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::Mac(..) => return self.visit_macro_invoc(expr.id),
ExprKind::Closure(_, asyncness, ..) => { ExprKind::Closure(_, asyncness, ..) => {
// Async closures desugar to closures inside of closures, so // 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) { fn visit_token(&mut self, t: Token) {
if let token::Interpolated(nt) = t.kind { if let token::Interpolated(nt) = t.kind {
if let token::NtExpr(ref expr) = *nt { 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); self.visit_macro_invoc(expr.id);
} }
} }

View file

@ -71,7 +71,7 @@ impl<'hir> Entry<'hir> {
} }
Node::Expr(ref expr) => { Node::Expr(ref expr) => {
match expr.node { match expr.kind {
ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl), ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl),
_ => None, _ => None,
} }
@ -111,7 +111,7 @@ impl<'hir> Entry<'hir> {
Node::AnonConst(constant) => Some(constant.body), Node::AnonConst(constant) => Some(constant.body),
Node::Expr(expr) => { Node::Expr(expr) => {
match expr.node { match expr.kind {
ExprKind::Closure(.., body, _, _) => Some(body), ExprKind::Closure(.., body, _, _) => Some(body),
_ => None, _ => None,
} }
@ -468,7 +468,7 @@ impl<'hir> Map<'hir> {
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => { Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
BodyOwnerKind::Static(m) BodyOwnerKind::Static(m)
} }
Node::Expr(&Expr { node: ExprKind::Closure(..), .. }) => { Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
BodyOwnerKind::Closure BodyOwnerKind::Closure
} }
node => bug!("{:#?} is not a body node", node), node => bug!("{:#?} is not a body node", node),
@ -634,7 +634,7 @@ impl<'hir> Map<'hir> {
Some(Node::TraitItem(_)) | Some(Node::TraitItem(_)) |
Some(Node::ImplItem(_)) => true, Some(Node::ImplItem(_)) => true,
Some(Node::Expr(e)) => { Some(Node::Expr(e)) => {
match e.node { match e.kind {
ExprKind::Closure(..) => true, ExprKind::Closure(..) => true,
_ => false, _ => false,
} }
@ -749,7 +749,7 @@ impl<'hir> Map<'hir> {
Node::Item(_) | Node::Item(_) |
Node::ForeignItem(_) | Node::ForeignItem(_) |
Node::TraitItem(_) | Node::TraitItem(_) |
Node::Expr(Expr { node: ExprKind::Closure(..), ..}) | Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) |
Node::ImplItem(_) => true, Node::ImplItem(_) => true,
_ => false, _ => false,
} }
@ -757,7 +757,7 @@ impl<'hir> Map<'hir> {
let match_non_returning_block = |node: &Node<'_>| { let match_non_returning_block = |node: &Node<'_>| {
match *node { match *node {
Node::Expr(ref expr) => { Node::Expr(ref expr) => {
match expr.node { match expr.kind {
ExprKind::Loop(..) | ExprKind::Ret(..) => true, ExprKind::Loop(..) | ExprKind::Ret(..) => true,
_ => false, _ => false,
} }

View file

@ -1434,7 +1434,7 @@ pub struct AnonConst {
#[derive(RustcEncodable, RustcDecodable)] #[derive(RustcEncodable, RustcDecodable)]
pub struct Expr { pub struct Expr {
pub hir_id: HirId, pub hir_id: HirId,
pub node: ExprKind, pub kind: ExprKind,
pub attrs: ThinVec<Attribute>, pub attrs: ThinVec<Attribute>,
pub span: Span, pub span: Span,
} }
@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72);
impl Expr { impl Expr {
pub fn precedence(&self) -> ExprPrecedence { pub fn precedence(&self) -> ExprPrecedence {
match self.node { match self.kind {
ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Box(_) => ExprPrecedence::Box,
ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call, ExprKind::Call(..) => ExprPrecedence::Call,
@ -1478,7 +1478,7 @@ impl Expr {
} }
pub fn is_place_expr(&self) -> bool { pub fn is_place_expr(&self) -> bool {
match self.node { match self.kind {
ExprKind::Path(QPath::Resolved(_, ref path)) => { ExprKind::Path(QPath::Resolved(_, ref path)) => {
match path.res { match path.res {
Res::Local(..) Res::Local(..)

View file

@ -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 /// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in
/// `if cond { ... }`. /// `if cond { ... }`.
pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) { 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 {}` // These cases need parens due to the parse error observed in #26461: `if return {}`
// parses as the erroneous construct `if (return {})`, not `if (return) {}`. // parses as the erroneous construct `if (return {})`, not `if (return) {}`.
hir::ExprKind::Closure(..) | hir::ExprKind::Closure(..) |
@ -1119,11 +1119,10 @@ impl<'a> State<'a> {
} }
fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) { fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
let prec = let prec = match func.kind {
match func.node { hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, _ => parser::PREC_POSTFIX,
_ => parser::PREC_POSTFIX, };
};
self.print_expr_maybe_paren(func, prec); self.print_expr_maybe_paren(func, prec);
self.print_call_post(args) self.print_call_post(args)
@ -1161,7 +1160,7 @@ impl<'a> State<'a> {
Fixity::None => (prec + 1, prec + 1), 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 // 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 // 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. // 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.print_outer_attributes(&expr.attrs);
self.ibox(INDENT_UNIT); self.ibox(INDENT_UNIT);
self.ann.pre(self, AnnNode::Expr(expr)); self.ann.pre(self, AnnNode::Expr(expr));
match expr.node { match expr.kind {
hir::ExprKind::Box(ref expr) => { hir::ExprKind::Box(ref expr) => {
self.word_space("box"); self.word_space("box");
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
@ -1803,7 +1802,7 @@ impl<'a> State<'a> {
} }
self.word_space("=>"); self.word_space("=>");
match arm.body.node { match arm.body.kind {
hir::ExprKind::Block(ref blk, opt_label) => { hir::ExprKind::Block(ref blk, opt_label) => {
if let Some(label) = opt_label { if let Some(label) = opt_label {
self.print_ident(label.ident); self.print_ident(label.ident);
@ -2222,7 +2221,7 @@ impl<'a> State<'a> {
// //
// Duplicated from `parse::classify`, but adapted for the HIR. // Duplicated from `parse::classify`, but adapted for the HIR.
fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
match e.node { match e.kind {
hir::ExprKind::Match(..) | hir::ExprKind::Match(..) |
hir::ExprKind::Block(..) | hir::ExprKind::Block(..) |
hir::ExprKind::Loop(..) => false, 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 /// 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. /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
fn contains_exterior_struct_lit(value: &hir::Expr) -> bool { fn contains_exterior_struct_lit(value: &hir::Expr) -> bool {
match value.node { match value.kind {
hir::ExprKind::Struct(..) => true, hir::ExprKind::Struct(..) => true,
hir::ExprKind::Assign(ref lhs, ref rhs) | hir::ExprKind::Assign(ref lhs, ref rhs) |

View file

@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { 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); let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
if let Some(upvars) = self.tcx.upvars(closure_def_id) { if let Some(upvars) = self.tcx.upvars(closure_def_id) {
// Every capture of a closure expression is a local in scope, // Every capture of a closure expression is a local in scope,

View file

@ -173,12 +173,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
let hir::Expr { let hir::Expr {
hir_id: _, hir_id: _,
ref span, ref span,
ref node, ref kind,
ref attrs ref attrs
} = *self; } = *self;
span.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher); kind.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher);
}) })
} }

View file

@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> {
let span = scope.span(self, region_scope_tree); let span = scope.span(self, region_scope_tree);
let tag = match self.hir().find(scope.hir_id(region_scope_tree)) { let tag = match self.hir().find(scope.hir_id(region_scope_tree)) {
Some(Node::Block(_)) => "block", Some(Node::Block(_)) => "block",
Some(Node::Expr(expr)) => match expr.node { Some(Node::Expr(expr)) => match expr.kind {
hir::ExprKind::Call(..) => "call", hir::ExprKind::Call(..) => "call",
hir::ExprKind::MethodCall(..) => "method call", hir::ExprKind::MethodCall(..) => "method call",
hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let", hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
@ -639,7 +639,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
hir::MatchSource::TryDesugar => { hir::MatchSource::TryDesugar => {
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found { if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id); 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"); let arg_expr = args.first().expect("try desugaring call w/out arg");
self.in_progress_tables.and_then(|tables| { self.in_progress_tables.and_then(|tables| {
tables.borrow().expr_ty_opt(arg_expr) tables.borrow().expr_ty_opt(arg_expr)

View file

@ -92,10 +92,10 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) { fn visit_expr(&mut self, expr: &'tcx Expr) {
if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = ( if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = (
&expr.node, &expr.kind,
self.node_matches_type(expr.hir_id), self.node_matches_type(expr.hir_id),
) { ) {
self.found_closure = Some(&expr.node); self.found_closure = Some(&expr.kind);
} }
intravisit::walk_expr(self, expr); intravisit::walk_expr(self, expr);
} }
@ -114,7 +114,7 @@ fn closure_return_type_suggestion(
FunctionRetTy::DefaultReturn(_) => ("-> ", " "), FunctionRetTy::DefaultReturn(_) => ("-> ", " "),
_ => ("", ""), _ => ("", ""),
}; };
let suggestion = match body.value.node { let suggestion = match body.value.kind {
ExprKind::Block(..) => { ExprKind::Block(..) => {
vec![(output.span(), format!("{}{}{}", arrow, ret, post))] vec![(output.span(), format!("{}{}{}", arrow, ret, post))]
} }

View file

@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let hir = &self.tcx().hir(); let hir = &self.tcx().hir();
if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) { if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) {
if let Node::Expr(Expr { if let Node::Expr(Expr {
node: Closure(_, _, _, closure_span, None), kind: Closure(_, _, _, closure_span, None),
.. ..
}) = hir.get(hir_id) { }) = hir.get(hir_id) {
let sup_sp = sup_origin.span(); let sup_sp = sup_origin.span();

View file

@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
match expr.node { match expr.kind {
hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => { hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => {
let res = self.tables.qpath_res(qpath, expr.hir_id); let res = self.tables.qpath_res(qpath, expr.hir_id);
self.handle_res(res); self.handle_res(res);

View file

@ -397,7 +397,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
self.walk_adjustment(expr); self.walk_adjustment(expr);
match expr.node { match expr.kind {
hir::ExprKind::Path(_) => { } hir::ExprKind::Path(_) => { }
hir::ExprKind::Type(ref subexpr, _) => { hir::ExprKind::Type(ref subexpr, _) => {

View file

@ -150,7 +150,7 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { 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) self.tables.qpath_res(qpath, expr.hir_id)
} else { } else {
Res::Err Res::Err

View file

@ -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) { 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: // live nodes required for uses or definitions of variables:
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res); debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res);
@ -991,7 +991,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
-> LiveNode { -> LiveNode {
debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)); 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 // Interesting cases with control flow or which gen/kill
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) 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 // these errors are detected in the later pass borrowck. We
// just ignore such cases and treat them as reads. // just ignore such cases and treat them as reads.
match expr.node { match expr.kind {
hir::ExprKind::Path(_) => succ, hir::ExprKind::Path(_) => succ,
hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ),
_ => self.propagate_through_expr(expr, succ) _ => self.propagate_through_expr(expr, succ)
@ -1268,7 +1268,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// see comment on propagate_through_place() // see comment on propagate_through_place()
fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { 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)) => { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
self.access_path(expr.hir_id, path, succ, acc) 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) { fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
match expr.node { match expr.kind {
hir::ExprKind::Assign(ref l, _) => { hir::ExprKind::Assign(ref l, _) => {
this.check_place(&l); this.check_place(&l);
} }
@ -1420,7 +1420,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
impl<'tcx> Liveness<'_, 'tcx> { impl<'tcx> Liveness<'_, 'tcx> {
fn check_place(&mut self, expr: &'tcx Expr) { fn check_place(&mut self, expr: &'tcx Expr) {
match expr.node { match expr.kind {
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
if let Res::Local(var_hid) = path.res { if let Res::Local(var_hid) = path.res {
let upvars = self.ir.tcx.upvars(self.ir.body_owner); let upvars = self.ir.tcx.upvars(self.ir.body_owner);

View file

@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
let expr_ty = self.expr_ty(expr)?; let expr_ty = self.expr_ty(expr)?;
match expr.node { match expr.kind {
hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { hir::ExprKind::Unary(hir::UnDeref, ref e_base) => {
if self.tables.is_method_call(expr) { if self.tables.is_method_call(expr) {
self.cat_overloaded_place(expr, e_base, NoteNone) self.cat_overloaded_place(expr, e_base, NoteNone)

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
let res = match expr.node { let res = match expr.kind {
hir::ExprKind::Path(ref qpath) => { hir::ExprKind::Path(ref qpath) => {
Some(self.tables.qpath_res(qpath, expr.hir_id)) Some(self.tables.qpath_res(qpath, expr.hir_id))
} }
@ -313,7 +313,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::ImplItemKind::TyAlias(_) => {} 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); self.visit_nested_body(body);
} }
// Nothing to recurse on for these // Nothing to recurse on for these

View file

@ -893,7 +893,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
let mut terminating = |id: hir::ItemLocalId| { let mut terminating = |id: hir::ItemLocalId| {
terminating_scopes.insert(id); terminating_scopes.insert(id);
}; };
match expr.node { match expr.kind {
// Conditional or repeating scopes are always terminating // Conditional or repeating scopes are always terminating
// scopes, meaning that temporaries cannot outlive them. // scopes, meaning that temporaries cannot outlive them.
// This ensures fixed size stacks. // 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. // properly, we can't miss any types.
match expr.node { match expr.kind {
// Manually recurse over closures, because they are the only // Manually recurse over closures, because they are the only
// case of nested bodies that share the parent environment. // case of nested bodies that share the parent environment.
hir::ExprKind::Closure(.., body, _, _) => { 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); 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`. // 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 }; let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node };
loop { loop {
@ -1240,7 +1240,7 @@ fn resolve_local<'tcx>(
expr: &hir::Expr, expr: &hir::Expr,
blk_id: Option<Scope>, blk_id: Option<Scope>,
) { ) {
match expr.node { match expr.kind {
hir::ExprKind::AddrOf(_, ref subexpr) => { hir::ExprKind::AddrOf(_, ref subexpr) => {
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
record_rvalue_scope(visitor, &subexpr, blk_id); record_rvalue_scope(visitor, &subexpr, blk_id);
@ -1300,7 +1300,7 @@ fn resolve_local<'tcx>(
// outer expression. // outer expression.
visitor.scope_tree.record_rvalue_scope(expr.hir_id.local_id, blk_scope); 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::AddrOf(_, ref subexpr) |
hir::ExprKind::Unary(hir::UnDeref, ref subexpr) | hir::ExprKind::Unary(hir::UnDeref, ref subexpr) |
hir::ExprKind::Field(ref subexpr, _) | hir::ExprKind::Field(ref subexpr, _) |

View file

@ -1214,7 +1214,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
} }
fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> { fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> {
if let hir::ExprKind::Loop(_, Some(label), _) = ex.node { if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind {
Some(label.ident) Some(label.ident)
} else { } else {
None None

View file

@ -956,7 +956,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let parent_node = self.tcx.hir().get_parent_node(hir_id); 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(Node::Local(ref local)) = self.tcx.hir().find(parent_node) {
if let Some(ref expr) = local.init { 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) { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
err.span_suggestion( err.span_suggestion(
expr.span, expr.span,
@ -1110,7 +1110,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.. ..
})) = node { })) = node {
let body = hir.body(*body_id); 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() && if decl.output.span().overlaps(span) && blk.expr.is_none() &&
"()" == &trait_ref.self_ty().to_string() "()" == &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<ArgKind>) { pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec<ArgKind>) {
match node { match node {
Node::Expr(&hir::Expr { 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), (self.tcx.sess.source_map().def_span(span),

View file

@ -604,7 +604,7 @@ impl<'tcx> TypeckTables<'tcx> {
pub fn is_method_call(&self, expr: &hir::Expr) -> bool { pub fn is_method_call(&self, expr: &hir::Expr) -> bool {
// Only paths and method calls/overloaded operators have // Only paths and method calls/overloaded operators have
// entries in type_dependent_defs, ignore the former here. // 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; return false;
} }

View file

@ -177,7 +177,7 @@ pub fn check_loans<'a, 'tcx>(
let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap(); let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap();
let movable_generator = !match bccx.tcx.hir().get(hir_id) { let movable_generator = !match bccx.tcx.hir().get(hir_id) {
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
.. ..
}) => true, }) => true,
_ => false, _ => false,

View file

@ -338,7 +338,7 @@ pub enum LoanPathElem<'tcx> {
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId { fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId {
let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id); let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id);
match tcx.hir().get(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, _, _) => { hir::ExprKind::Closure(.., body_id, _, _) => {
body_id.hir_id body_id.hir_id
} }

View file

@ -163,7 +163,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
} }
fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex { fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
match expr.node { match expr.kind {
hir::ExprKind::Block(ref blk, _) => { hir::ExprKind::Block(ref blk, _) => {
let blk_exit = self.block(&blk, pred); let blk_exit = self.block(&blk, pred);
self.add_ast_node(expr.hir_id.local_id, &[blk_exit]) self.add_ast_node(expr.hir_id.local_id, &[blk_exit])

View file

@ -834,7 +834,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt { fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
let expr = P(ast::Expr { let expr = P(ast::Expr {
id: sess.next_node_id(), id: sess.next_node_id(),
node: ast::ExprKind::Block(P(b), None), kind: ast::ExprKind::Block(P(b), None),
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
attrs: ThinVec::new(), 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 empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
let loop_expr = P(ast::Expr { 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(), id: self.sess.next_node_id(),
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
attrs: ThinVec::new(), attrs: ThinVec::new(),

View file

@ -67,7 +67,7 @@ declare_lint_pass!(WhileTrue => [WHILE_TRUE]);
/// Traverse through any amount of parenthesis and return the first non-parens expression. /// Traverse through any amount of parenthesis and return the first non-parens expression.
fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr { 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 = sub;
} }
expr expr
@ -75,8 +75,8 @@ fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr {
impl EarlyLintPass for WhileTrue { impl EarlyLintPass for WhileTrue {
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
if let ast::ExprKind::While(cond, ..) = &e.node { if let ast::ExprKind::While(cond, ..) = &e.kind {
if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).node { if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind {
if let ast::LitKind::Bool(true) = lit.node { if let ast::LitKind::Bool(true) = lit.node {
if !lit.span.from_expansion() { if !lit.span.from_expansion() {
let msg = "denote infinite loops with `loop { ... }`"; 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) { 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. // Don't warn about generated blocks; that'll just pollute the output.
if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) { if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) {
self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); 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>, (cx: &LateContext<'a, 'tcx>,
expr: &hir::Expr) expr: &hir::Expr)
-> Option<(Ty<'tcx>, Ty<'tcx>)> { -> 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) cx.tables.qpath_res(qpath, expr.hir_id)
} else { } else {
return None; return None;
@ -1900,7 +1900,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
fn is_zero(expr: &hir::Expr) -> bool { fn is_zero(expr: &hir::Expr) -> bool {
use hir::ExprKind::*; use hir::ExprKind::*;
use syntax::ast::LitKind::*; use syntax::ast::LitKind::*;
match &expr.node { match &expr.kind {
Lit(lit) => Lit(lit) =>
if let Int(i, _) = lit.node { if let Int(i, _) = lit.node {
i == 0 i == 0
@ -1923,8 +1923,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
const TRANSMUTE_PATH: &[Symbol] = const TRANSMUTE_PATH: &[Symbol] =
&[sym::core, sym::intrinsics, kw::Invalid, sym::transmute]; &[sym::core, sym::intrinsics, kw::Invalid, sym::transmute];
if let hir::ExprKind::Call(ref path_expr, ref args) = expr.node { if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind {
if let hir::ExprKind::Path(ref qpath) = path_expr.node { 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()?; let def_id = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id()?;
if cx.match_def_path(def_id, ZEROED_PATH) { if cx.match_def_path(def_id, ZEROED_PATH) {

View file

@ -13,7 +13,7 @@ declare_lint_pass!(RedundantSemicolon => [REDUNDANT_SEMICOLON]);
impl EarlyLintPass for RedundantSemicolon { impl EarlyLintPass for RedundantSemicolon {
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) { fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) {
if let StmtKind::Semi(expr) = &stmt.node { 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() { if v.is_empty() {
// Strings of excess semicolons are encoded as empty tuple expressions // Strings of excess semicolons are encoded as empty tuple expressions
// during the parsing stage, so we check for empty tuple expressions // during the parsing stage, so we check for empty tuple expressions

View file

@ -72,7 +72,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
) -> bool { ) -> bool {
// We only want to handle exclusive (`..`) ranges, // We only want to handle exclusive (`..`) ranges,
// which are represented as `ExprKind::Struct`. // 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 { if eps.len() != 2 {
return false; return false;
} }
@ -279,7 +279,7 @@ fn lint_int_literal<'a, 'tcx>(
let par_id = cx.tcx.hir().get_parent_node(e.hir_id); 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 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) if is_range_literal(cx.sess(), par_e)
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t) && 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 { if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir().get_parent_node(e.hir_id); let parent_id = cx.tcx.hir().get_parent_node(e.hir_id);
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
match par_e.node { match par_e.kind {
hir::ExprKind::Cast(..) => { hir::ExprKind::Cast(..) => {
if let ty::Char = cx.tables.expr_ty(par_e).kind { if let ty::Char = cx.tables.expr_ty(par_e).kind {
let mut err = cx.struct_span_lint( let mut err = cx.struct_span_lint(
@ -400,7 +400,7 @@ fn lint_literal<'a, 'tcx>(
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { 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) => { hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
// propagate negation, if the negation itself isn't negated // propagate negation, if the negation itself isn't negated
if self.negated_expr_id != e.hir_id { if self.negated_expr_id != e.hir_id {
@ -445,7 +445,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
l: &hir::Expr, l: &hir::Expr,
r: &hir::Expr) r: &hir::Expr)
-> bool { -> 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(_), _) => (l, r, true),
(_, &hir::ExprKind::Lit(_)) => (r, l, false), (_, &hir::ExprKind::Lit(_)) => (r, l, false),
_ => return true, _ => return true,
@ -456,7 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
match cx.tables.node_type(expr.hir_id).kind { match cx.tables.node_type(expr.hir_id).kind {
ty::Int(int_ty) => { ty::Int(int_ty) => {
let (min, max) = int_ty_range(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) => { hir::ExprKind::Lit(ref li) => {
match li.node { match li.node {
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
@ -470,7 +470,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
} }
ty::Uint(uint_ty) => { ty::Uint(uint_ty) => {
let (min, max) :(u128, u128) = uint_ty_range(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) => { hir::ExprKind::Lit(ref li) => {
match li.node { match li.node {
ast::LitKind::Int(v, _) => v, ast::LitKind::Int(v, _) => v,

View file

@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
_ => return, _ => return,
}; };
if let hir::ExprKind::Ret(..) = expr.node { if let hir::ExprKind::Ret(..) = expr.kind {
return; return;
} }
@ -52,9 +52,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
let mut fn_warned = false; let mut fn_warned = false;
let mut op_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, _) => { hir::ExprKind::Call(ref callee, _) => {
match callee.node { match callee.kind {
hir::ExprKind::Path(ref qpath) => { hir::ExprKind::Path(ref qpath) => {
match cx.tables.qpath_res(qpath, callee.hir_id) { match cx.tables.qpath_res(qpath, callee.hir_id) {
Res::Def(DefKind::Fn, def_id) Res::Def(DefKind::Fn, def_id)
@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
return; return;
} }
let must_use_op = match expr.node { let must_use_op = match expr.kind {
// Hardcoding operators here seemed more expedient than the // Hardcoding operators here seemed more expedient than the
// refactoring that would be needed to look up the `#[must_use]` // refactoring that would be needed to look up the `#[must_use]`
// attribute which does exist on the comparison trait methods // 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) => { ty::Tuple(ref tys) => {
let mut has_emitted = false; 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()); debug_assert_eq!(comps.len(), tys.len());
comps.iter().map(|e| e.span).collect() comps.iter().map(|e| e.span).collect()
} else { } else {
@ -270,7 +270,7 @@ declare_lint_pass!(PathStatements => [PATH_STATEMENTS]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
if let hir::StmtKind::Semi(ref expr) = s.node { if let hir::StmtKind::Semi(ref expr) = s.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"); cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
} }
} }
@ -363,7 +363,7 @@ declare_lint_pass!(UnusedParens => [UNUSED_PARENS]);
impl UnusedParens { impl UnusedParens {
fn is_expr_parens_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool { 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, ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true,
_ => parser::contains_exterior_struct_lit(&inner), _ => parser::contains_exterior_struct_lit(&inner),
} }
@ -376,7 +376,7 @@ impl UnusedParens {
followed_by_block: bool, followed_by_block: bool,
left_pos: Option<BytePos>, left_pos: Option<BytePos>,
right_pos: Option<BytePos>) { right_pos: Option<BytePos>) {
match value.node { match value.kind {
ast::ExprKind::Paren(ref inner) => { ast::ExprKind::Paren(ref inner) => {
if !Self::is_expr_parens_necessary(inner, followed_by_block) && if !Self::is_expr_parens_necessary(inner, followed_by_block) &&
value.attrs.is_empty() { value.attrs.is_empty() {
@ -501,7 +501,7 @@ impl UnusedParens {
impl EarlyLintPass for UnusedParens { impl EarlyLintPass for UnusedParens {
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
use syntax::ast::ExprKind::*; 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, ..) => { Let(ref pat, ..) => {
self.check_unused_parens_pat(cx, pat, false, false); self.check_unused_parens_pat(cx, pat, false, false);
return; return;
@ -663,7 +663,7 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
match e.node { match e.kind {
hir::ExprKind::Box(_) => {} hir::ExprKind::Box(_) => {}
_ => return, _ => return,
} }

View file

@ -1810,7 +1810,7 @@ impl EncodeContext<'tcx> {
} }
fn encode_info_for_expr(&mut self, expr: &hir::Expr) { fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
match expr.node { match expr.kind {
hir::ExprKind::Closure(..) => { hir::ExprKind::Closure(..) => {
let def_id = self.tcx.hir().local_def_id(expr.hir_id); let def_id = self.tcx.hir().local_def_id(expr.hir_id);
self.record(def_id, EncodeContext::encode_info_for_closure, def_id); self.record(def_id, EncodeContext::encode_info_for_closure, def_id);

View file

@ -890,7 +890,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
def_id, target_place, places def_id, target_place, places
); );
let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?; 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); debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
if let hir::ExprKind::Closure( if let hir::ExprKind::Closure(
.., args_span, _ .., args_span, _

View file

@ -236,7 +236,7 @@ fn do_mir_borrowck<'a, 'tcx>(
let movable_generator = match tcx.hir().get(id) { let movable_generator = match tcx.hir().get(id) {
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
.. ..
}) => false, }) => false,
_ => true, _ => true,

View file

@ -292,7 +292,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
if let DefiningTy::Closure(def_id, substs) = def_ty { if let DefiningTy::Closure(def_id, substs) = def_ty {
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = 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 span
} else { } else {
@ -758,7 +758,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) { let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr { 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 { match return_ty.output {
@ -821,7 +821,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let yield_span = match tcx.hir().get(mir_hir_id) { let yield_span = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr { hir::Node::Expr(hir::Expr {
node: hir::ExprKind::Closure(_, _, _, span, _), kind: hir::ExprKind::Closure(_, _, _, span, _),
.. ..
}) => ( }) => (
tcx.sess.source_map().end_point(*span) tcx.sess.source_map().end_point(*span)

View file

@ -159,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if let ExprKind::Block { body } = expr.kind { if let ExprKind::Block { body } = expr.kind {
if let Some(tail_expr) = &body.expr { if let Some(tail_expr) = &body.expr {
let mut expr = tail_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 { if let Some(subtail_expr) = &subblock.expr {
expr = subtail_expr expr = subtail_expr
} else { } else {

View file

@ -27,7 +27,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
// Figure out what primary body this item has. // Figure out what primary body this item has.
let (body_id, return_ty_span) = match tcx.hir().get(id) { 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::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
| Node::ImplItem( | Node::ImplItem(
hir::ImplItem { hir::ImplItem {

View file

@ -204,7 +204,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
let expr_ty = cx.tables().expr_ty(expr); let expr_ty = cx.tables().expr_ty(expr);
let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); 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: // Here comes the interesting stuff:
hir::ExprKind::MethodCall(_, method_span, ref args) => { hir::ExprKind::MethodCall(_, method_span, ref args) => {
// Rewrite a.b(c) into UFCS form like Trait::b(a, c) // Rewrite a.b(c) into UFCS form like Trait::b(a, c)
@ -247,7 +247,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
} }
} else { } else {
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = 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. // Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
expr_ty.ty_adt_def().and_then(|adt_def| { 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) { if cx.tables().is_method_call(expr) {
overloaded_operator(cx, expr, vec![arg.to_ref()]) overloaded_operator(cx, expr, vec![arg.to_ref()])
} else { } else {
if let hir::ExprKind::Lit(ref lit) = arg.node { if let hir::ExprKind::Lit(ref lit) = arg.kind {
ExprKind::Literal { ExprKind::Literal {
literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true),
user_ty: None, user_ty: None,
@ -639,7 +639,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
// } // }
// The correct solution would be to add symbolic computations to miri, // The correct solution would be to add symbolic computations to miri,
// so we wouldn't have to compute and store the actual value // 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); let res = cx.tables().qpath_res(qpath, source.hir_id);
cx cx
.tables() .tables()

View file

@ -59,7 +59,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
fn visit_expr(&mut self, ex: &'tcx hir::Expr) { fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
intravisit::walk_expr(self, ex); 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); self.check_match(scrut, arms, source);
} }
} }

View file

@ -933,7 +933,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
/// which would overflow if we tried to evaluate `128_i8` and then negate /// which would overflow if we tried to evaluate `128_i8` and then negate
/// afterwards. /// afterwards.
fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> { fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> {
match expr.node { match expr.kind {
hir::ExprKind::Lit(ref lit) => { hir::ExprKind::Lit(ref lit) => {
let ty = self.tables.expr_ty(expr); let ty = self.tables.expr_ty(expr);
match lit_to_const(&lit.node, self.tcx, ty, false) { 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::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind,
hir::ExprKind::Unary(hir::UnNeg, ref expr) => { hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
let ty = self.tables.expr_ty(expr); let ty = self.tables.expr_ty(expr);
let lit = match expr.node { let lit = match expr.kind {
hir::ExprKind::Lit(ref lit) => lit, hir::ExprKind::Lit(ref lit) => lit,
_ => span_bug!(expr.span, "not a literal: {:?}", expr), _ => span_bug!(expr.span, "not a literal: {:?}", expr),
}; };

View file

@ -286,11 +286,11 @@ impl<'a> AstValidator<'a> {
// m!(S); // m!(S);
// ``` // ```
fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) { fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) {
match expr.node { match expr.kind {
ExprKind::Lit(..) | ExprKind::Err => {} ExprKind::Lit(..) | ExprKind::Err => {}
ExprKind::Path(..) if allow_paths => {} ExprKind::Path(..) if allow_paths => {}
ExprKind::Unary(UnOp::Neg, ref inner) 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 \ _ => self.err_handler().span_err(expr.span, "arbitrary expressions aren't allowed \
in patterns") in patterns")
} }
@ -442,7 +442,7 @@ fn validate_generics_order<'a>(
impl<'a> Visitor<'a> for AstValidator<'a> { impl<'a> Visitor<'a> for AstValidator<'a> {
fn visit_expr(&mut self, expr: &'a Expr) { fn visit_expr(&mut self, expr: &'a Expr) {
match &expr.node { match &expr.kind {
ExprKind::Closure(_, _, _, fn_decl, _, _) => { ExprKind::Closure(_, _, _, fn_decl, _, _) => {
self.check_fn_decl(fn_decl); self.check_fn_decl(fn_decl);
} }

View file

@ -54,7 +54,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
} }
fn visit_expr(&mut self, e: &'hir hir::Expr) { fn visit_expr(&mut self, e: &'hir hir::Expr) {
match e.node { match e.kind {
hir::ExprKind::Loop(ref b, _, source) => { hir::ExprKind::Loop(ref b, _, source) => {
self.with_context(Loop(source), |v| v.visit_block(&b)); 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 { let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
None None
} else { } 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, hir::ExprKind::Loop(_, _, source) => source,
ref r => span_bug!(e.span, ref r => span_bug!(e.span,
"break label resolved to a non-loop: {:?}", r), "break label resolved to a non-loop: {:?}", r),

View file

@ -280,7 +280,7 @@ fn check_expr_kind<'a, 'tcx>(
_ => Promotable _ => Promotable
}; };
let node_result = match e.node { let kind_result = match e.kind {
hir::ExprKind::Box(ref expr) => { hir::ExprKind::Box(ref expr) => {
let _ = v.check_expr(&expr); let _ = v.check_expr(&expr);
NotPromotable NotPromotable
@ -376,7 +376,7 @@ fn check_expr_kind<'a, 'tcx>(
} }
let mut callee = &**callee; let mut callee = &**callee;
loop { loop {
callee = match callee.node { callee = match callee.kind {
hir::ExprKind::Block(ref block, _) => match block.expr { hir::ExprKind::Block(ref block, _) => match block.expr {
Some(ref tail) => &tail, Some(ref tail) => &tail,
None => break 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. // 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) v.tables.qpath_res(qpath, callee.hir_id)
} else { } else {
Res::Err Res::Err
@ -553,7 +553,7 @@ fn check_expr_kind<'a, 'tcx>(
NotPromotable NotPromotable
} }
}; };
ty_result & node_result ty_result & kind_result
} }
/// Checks the adjustments of an expression. /// Checks the adjustments of an expression.

View file

@ -1028,7 +1028,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
match expr.node { match expr.kind {
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { hir::ExprKind::Struct(ref qpath, ref fields, ref base) => {
let res = self.tables.qpath_res(qpath, expr.hir_id); let res = self.tables.qpath_res(qpath, expr.hir_id);
let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); 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. // Do not check nested expressions if the error already happened.
return; return;
} }
match expr.node { match expr.kind {
hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => { hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => {
// Do not report duplicate errors for `x = y` and `match x { ... }`. // Do not report duplicate errors for `x = y` and `match x { ... }`.
if self.check_expr_pat_type(rhs.hir_id, rhs.span) { if self.check_expr_pat_type(rhs.hir_id, rhs.span) {

View file

@ -1120,9 +1120,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
} }
macro_rules! method { 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) { fn $visit(&mut self, node: &'b $ty) {
if let $invoc(..) = node.node { if let $invoc(..) = node.$kind {
self.visit_invoc(node.id); self.visit_invoc(node.id);
} else { } else {
visit::$walk(self, node); visit::$walk(self, node);
@ -1132,10 +1132,10 @@ macro_rules! method {
} }
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item); method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, node);
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr); method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind);
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat); method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, node);
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty); method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node);
fn visit_item(&mut self, item: &'b Item) { fn visit_item(&mut self, item: &'b Item) {
let macro_use = match item.node { 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) { fn visit_token(&mut self, t: Token) {
if let token::Interpolated(nt) = t.kind { if let token::Interpolated(nt) = t.kind {
if let token::NtExpr(ref expr) = *nt { 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); self.visit_invoc(expr.id);
} }
} }

View file

@ -221,7 +221,7 @@ impl<'a> PathSource<'a> {
ValueNS => "method or associated constant", ValueNS => "method or associated constant",
MacroNS => bug!("associated macro"), 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`, // "function" here means "anything callable" rather than `DefKind::Fn`,
// this is not precise but usually more helpful than just "value". // this is not precise but usually more helpful than just "value".
Some(&ExprKind::Call(..)) => "function", Some(&ExprKind::Call(..)) => "function",
@ -1836,7 +1836,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
self.record_candidate_traits_for_expr_if_necessary(expr); self.record_candidate_traits_for_expr_if_necessary(expr);
// Next, resolve the node. // Next, resolve the node.
match expr.node { match expr.kind {
ExprKind::Path(ref qself, ref path) => { ExprKind::Path(ref qself, ref path) => {
self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent)); self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent));
visit::walk_expr(self, expr); 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) { fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) {
match expr.node { match expr.kind {
ExprKind::Field(_, ident) => { ExprKind::Field(_, ident) => {
// FIXME(#6890): Even though you can't treat a method like a // FIXME(#6890): Even though you can't treat a method like a
// field, we need to add any trait methods we find that match // field, we need to add any trait methods we find that match

View file

@ -325,7 +325,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
let ns = source.namespace(); let ns = source.namespace();
let is_expected = &|res| source.is_expected(res); 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) => { ExprKind::Field(_, ident) => {
err.span_suggestion( err.span_suggestion(
expr.span, expr.span,

View file

@ -1461,9 +1461,9 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
} }
fn visit_expr(&mut self, ex: &'l ast::Expr) { 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); self.process_macro_use(ex.span);
match ex.node { match ex.kind {
ast::ExprKind::Struct(ref path, ref fields, ref base) => { 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 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); 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, _) => { ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) => {
self.process_var_decl(pattern); 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); self.visit_expr(subexpression);
visit::walk_block(self, block); visit::walk_block(self, block);
} }

View file

@ -518,7 +518,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
if ty.is_none() || ty.unwrap().kind == ty::Error { if ty.is_none() || ty.unwrap().kind == ty::Error {
return None; return None;
} }
match expr.node { match expr.kind {
ast::ExprKind::Field(ref sub_ex, ident) => { ast::ExprKind::Field(ref sub_ex, ident) => {
let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id); 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) { 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::Expr(&hir::Expr {
node: hir::ExprKind::Struct(ref qpath, ..), kind: hir::ExprKind::Struct(ref qpath, ..),
.. ..
}) => { }) => {
self.tables.qpath_res(qpath, hir_id) self.tables.qpath_res(qpath, hir_id)
} }
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Path(ref qpath), kind: hir::ExprKind::Path(ref qpath),
.. ..
}) | }) |
Node::Pat(&hir::Pat { Node::Pat(&hir::Pat {

View file

@ -2175,13 +2175,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option<DefId> { pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option<DefId> {
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments // 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. // 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() => ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() =>
block.expr.as_ref().unwrap(), block.expr.as_ref().unwrap(),
_ => expr, _ => expr,
}; };
match &expr.node { match &expr.kind {
ExprKind::Path(hir::QPath::Resolved(_, path)) => match path.res { ExprKind::Path(hir::QPath::Resolved(_, path)) => match path.res {
Res::Def(DefKind::ConstParam, did) => Some(did), Res::Def(DefKind::ConstParam, did) => Some(did),
_ => None, _ => None,

View file

@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
} else { } 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 // Point at the block expr instead of the entire block
blk.expr.as_ref().map(|e| e.span).unwrap_or(arm.body.span) blk.expr.as_ref().map(|e| e.span).unwrap_or(arm.body.span)
} else { } else {
@ -219,7 +219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
coercion.coerce_forced_unit(self, &cause, &mut |err| { coercion.coerce_forced_unit(self, &cause, &mut |err| {
if let Some((span, msg)) = &ret_reason { if let Some((span, msg)) = &ret_reason {
err.span_label(*span, msg.as_str()); 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 { if let Some(expr) = &block.expr {
err.span_label(expr.span, "found here".to_string()); 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 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 { if let Some(expr) = &block.expr {
expr.span expr.span
} else if let Some(stmt) = block.stmts.last() { } 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. // 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 { if let Some(expr) = &block.expr {
expr.span expr.span
} else if let Some(stmt) = block.stmts.last() { } else if let Some(stmt) = block.stmts.last() {

View file

@ -247,7 +247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let hir_id = self.tcx.hir().get_parent_node(hir_id); let hir_id = self.tcx.hir().get_parent_node(hir_id);
let parent_node = self.tcx.hir().get(hir_id); let parent_node = self.tcx.hir().get(hir_id);
if let ( 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(..), hir::ExprKind::Block(..),
) = (parent_node, callee_node) { ) = (parent_node, callee_node) {
let start = sp.shrink_to_lo(); let start = sp.shrink_to_lo();
@ -278,13 +278,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut unit_variant = None; let mut unit_variant = None;
if let &ty::Adt(adt_def, ..) = t { if let &ty::Adt(adt_def, ..) = t {
if adt_def.is_enum() { 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)) 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!( let mut err = type_error_struct!(
self.tcx.sess, self.tcx.sess,
callee.span, callee.span,
@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.identify_bad_closure_def_and_call( self.identify_bad_closure_def_and_call(
&mut err, &mut err,
call_expr.hir_id, call_expr.hir_id,
&callee.node, &callee.kind,
callee.span, callee.span,
); );
@ -318,7 +318,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
let mut inner_callee_path = None; let mut inner_callee_path = None;
let def = match callee.node { let def = match callee.kind {
hir::ExprKind::Path(ref qpath) => { hir::ExprKind::Path(ref qpath) => {
self.tables.borrow().qpath_res(qpath, callee.hir_id) self.tables.borrow().qpath_res(qpath, callee.hir_id)
} }
@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MaybeIncorrect, 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); inner_callee_path = Some(inner_qpath);
self.tables self.tables
.borrow() .borrow()
@ -375,8 +375,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.emit(); err.emit();
} else { } else {
bug!( bug!(
"call_expr.node should be an ExprKind::Call, got {:?}", "call_expr.kind should be an ExprKind::Call, got {:?}",
call_expr.node call_expr.kind
); );
} }

View file

@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Returns whether the expected type is `bool` and the expression is `x = y`. /// 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 { 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; return expected == self.tcx.types.bool;
} }
false false
@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr: &hir::Expr, expr: &hir::Expr,
) -> Option<(Span, &'static str, String)> { ) -> Option<(Span, &'static str, String)> {
let path = match expr.node { let path = match expr.kind {
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => path, hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => path,
_ => return None _ => 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 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) { let (expr_hir_id, closure_fn_decl) = match self.tcx.hir().find(param_parent) {
Some(Node::Expr( Some(Node::Expr(
hir::Expr { hir_id, node: hir::ExprKind::Closure(_, decl, ..), .. } hir::Expr { hir_id, kind: hir::ExprKind::Closure(_, decl, ..), .. }
)) => (hir_id, decl), )) => (hir_id, decl),
_ => return None _ => return None
}; };
@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let closure_params_len = closure_fn_decl.inputs.len(); let closure_params_len = closure_fn_decl.inputs.len();
let (method_path, method_span, method_expr) = match (hir, closure_params_len) { let (method_path, method_span, method_expr) = match (hir, closure_params_len) {
(Some(Node::Expr( (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), )), 1) => (path, span, expr),
_ => return None _ => return None
}; };
@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(parent) = self.tcx.hir().find(parent_id) { if let Some(parent) = self.tcx.hir().find(parent_id) {
// Account for fields // Account for fields
if let Node::Expr(hir::Expr { if let Node::Expr(hir::Expr {
node: hir::ExprKind::Struct(_, fields, ..), .. kind: hir::ExprKind::Struct(_, fields, ..), ..
}) = parent { }) = parent {
if let Ok(src) = cm.span_to_snippet(sp) { if let Ok(src) = cm.span_to_snippet(sp) {
for field in fields { for field in fields {
@ -351,11 +351,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// and make a good suggestion, so don't bother. // and make a good suggestion, so don't bother.
let is_macro = sp.from_expansion(); 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::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.kind, &check.kind) {
(&ty::Str, &ty::Array(arr, _)) | (&ty::Str, &ty::Array(arr, _)) |
(&ty::Str, &ty::Slice(arr)) if arr == self.tcx.types.u8 => { (&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 let Ok(src) = cm.span_to_snippet(sp) {
if src.starts_with("b\"") { if src.starts_with("b\"") {
return Some((sp, return Some((sp,
@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}, },
(&ty::Array(arr, _), &ty::Str) | (&ty::Array(arr, _), &ty::Str) |
(&ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => { (&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 let Ok(src) = cm.span_to_snippet(sp) {
if src.starts_with("\"") { if src.starts_with("\"") {
return Some((sp, return Some((sp,
@ -398,7 +398,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
if self.can_coerce(ref_ty, expected) { if self.can_coerce(ref_ty, expected) {
let mut sugg_sp = sp; 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(); let clone_trait = self.tcx.lang_items().clone_trait().unwrap();
if let ([arg], Some(true), "clone") = ( if let ([arg], Some(true), "clone") = (
&args[..], &args[..],
@ -414,7 +414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
if let Ok(src) = cm.span_to_snippet(sugg_sp) { 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) // parenthesize if needed (Issue #46756)
hir::ExprKind::Cast(_, _) | hir::ExprKind::Cast(_, _) |
hir::ExprKind::Binary(_, _, _) => true, hir::ExprKind::Binary(_, _, _) => true,
@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
String::new() String::new()
}; };
if let Some(hir::Node::Expr(hir::Expr { 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().find(
self.tcx.hir().get_parent_node(expr.hir_id), self.tcx.hir().get_parent_node(expr.hir_id),
@ -571,7 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut prefix = String::new(); let mut prefix = String::new();
if let Some(hir::Node::Expr(hir::Expr { 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)) { })) = 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 // `expr` is a literal field for a struct, only suggest if appropriate
@ -587,11 +587,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return false; return false;
} }
} }
if let hir::ExprKind::Call(path, args) = &expr.node { if let hir::ExprKind::Call(path, args) = &expr.kind {
if let ( if let (
hir::ExprKind::Path(hir::QPath::TypeRelative(base_ty, path_segment)), hir::ExprKind::Path(hir::QPath::TypeRelative(base_ty, path_segment)),
1, 1,
) = (&path.node, args.len()) { ) = (&path.kind, args.len()) {
// `expr` is a conversion like `u32::from(val)`, do not suggest anything (#63697). // `expr` is a conversion like `u32::from(val)`, do not suggest anything (#63697).
if let ( if let (
hir::TyKind::Path(hir::QPath::Resolved(None, base_ty_path)), hir::TyKind::Path(hir::QPath::Resolved(None, base_ty_path)),
@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if needs_paren { ")" } else { "" }, if needs_paren { ")" } else { "" },
); );
let literal_is_ty_suffixed = |expr: &hir::Expr| { 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() lit.node.is_suffixed()
} else { } else {
false false

View file

@ -84,7 +84,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { 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, ExprKind::DropTemps(expr) => expr,
_ => expr, _ => expr,
}; };
@ -159,7 +159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let ty = self.check_expr_kind(expr, expected, needs); let ty = self.check_expr_kind(expr, expected, needs);
// Warn for non-block expressions with diverging children. // Warn for non-block expressions with diverging children.
match expr.node { match expr.kind {
ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {}, ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {},
ExprKind::Call(ref callee, _) => ExprKind::Call(ref callee, _) =>
self.warn_if_unreachable(expr.hir_id, callee.span, "call"), self.warn_if_unreachable(expr.hir_id, callee.span, "call"),
@ -202,7 +202,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
); );
let tcx = self.tcx; let tcx = self.tcx;
match expr.node { match expr.kind {
ExprKind::Box(ref subexpr) => { ExprKind::Box(ref subexpr) => {
self.check_expr_box(subexpr, expected) self.check_expr_box(subexpr, expected)
} }
@ -602,7 +602,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// ... except when we try to 'break rust;'. // ... except when we try to 'break rust;'.
// ICE this expression in particular (see #43162). // 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 && if path.segments.len() == 1 &&
path.segments[0].ident.name == sym::rust { path.segments[0].ident.name == sym::rust {
fatally_break_rust(self.tcx.sess); fatally_break_rust(self.tcx.sess);
@ -1604,7 +1604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut needs_note = true; let mut needs_note = true;
// If the index is an integer, we can show the actual // If the index is an integer, we can show the actual
// fixed expression: // 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 { if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node {
let snip = self.tcx.sess.source_map().span_to_snippet(base.span); let snip = self.tcx.sess.source_map().span_to_snippet(base.span);
if let Ok(snip) = snip { if let Ok(snip) = snip {

View file

@ -436,7 +436,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
let mut exprs = vec![self.self_expr]; let mut exprs = vec![self.self_expr];
loop { loop {
match exprs.last().unwrap().node { match exprs.last().unwrap().kind {
hir::ExprKind::Field(ref expr, _) | hir::ExprKind::Field(ref expr, _) |
hir::ExprKind::Index(ref expr, _) | hir::ExprKind::Index(ref expr, _) |
hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&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); 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) => { hir::ExprKind::Index(ref base_expr, ref index_expr) => {
let index_expr_ty = self.node_ty(index_expr.hir_id); let index_expr_ty = self.node_ty(index_expr.hir_id);
self.convert_place_op_to_mutable( self.convert_place_op_to_mutable(

View file

@ -258,7 +258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
"f32" "f32"
}; };
match expr.node { match expr.kind {
ExprKind::Lit(ref lit) => { ExprKind::Lit(ref lit) => {
// numeric literal // numeric literal
let snippet = tcx.sess.source_map().span_to_snippet(lit.span) 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) { if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) {
report_function!(expr.span, expr_string); report_function!(expr.span, expr_string);
} else if let ExprKind::Path(QPath::Resolved(_, ref path)) = } else if let ExprKind::Path(QPath::Resolved(_, ref path)) =
expr.node expr.kind
{ {
if let Some(segment) = path.segments.last() { if let Some(segment) = path.segments.last() {
report_function!(expr.span, segment.ident); report_function!(expr.span, segment.ident);

View file

@ -3376,7 +3376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.warn_if_unreachable(arg.hir_id, arg.span, "expression"); 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, ExprKind::Closure(..) => true,
_ => false _ => false
}; };
@ -3495,8 +3495,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
errors: &mut Vec<traits::FulfillmentError<'_>>, errors: &mut Vec<traits::FulfillmentError<'_>>,
call_expr: &'tcx hir::Expr, call_expr: &'tcx hir::Expr,
) { ) {
if let hir::ExprKind::Call(path, _) = &call_expr.node { if let hir::ExprKind::Call(path, _) = &call_expr.kind {
if let hir::ExprKind::Path(qpath) = &path.node { if let hir::ExprKind::Path(qpath) = &path.kind {
if let hir::QPath::Resolved(_, path) = &qpath { if let hir::QPath::Resolved(_, path) = &qpath {
for error in errors { for error in errors {
if let ty::Predicate::Trait(predicate) = error.obligation.predicate { 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 /// // ^^^^ point at this instead of the whole `if` expression
/// ``` /// ```
fn get_expr_coercion_span(&self, expr: &hir::Expr) -> syntax_pos::Span { 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<Span> = arms.iter().filter_map(|arm| { let arm_spans: Vec<Span> = arms.iter().filter_map(|arm| {
self.in_progress_tables self.in_progress_tables
.and_then(|tables| tables.borrow().node_type_opt(arm.body.hir_id)) .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() { if arm_ty.is_never() {
None None
} else { } else {
Some(match &arm.body.node { Some(match &arm.body.kind {
// Point at the tail expression when possible. // Point at the tail expression when possible.
hir::ExprKind::Block(block, _) => block.expr hir::ExprKind::Block(block, _) => block.expr
.as_ref() .as_ref()
@ -4075,7 +4075,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
node: hir::ImplItemKind::Method(_, body_id), .. node: hir::ImplItemKind::Method(_, body_id), ..
}) => { }) => {
let body = self.tcx.hir().body(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); return Some(block.span);
} }
} }
@ -4212,7 +4212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}).collect::<Vec<_>>().join(", "); }).collect::<Vec<_>>().join(", ");
} }
Some(Node::Expr(hir::Expr { Some(Node::Expr(hir::Expr {
node: ExprKind::Closure(_, _, body_id, closure_span, _), kind: ExprKind::Closure(_, _, body_id, closure_span, _),
span: full_closure_span, span: full_closure_span,
.. ..
})) => { })) => {
@ -4388,7 +4388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if expected.is_unit() { if expected.is_unit() {
// `BlockTailExpression` only relevant if the tail expr would be // `BlockTailExpression` only relevant if the tail expr would be
// useful on its own. // useful on its own.
match expression.node { match expression.kind {
ExprKind::Call(..) | ExprKind::Call(..) |
ExprKind::MethodCall(..) | ExprKind::MethodCall(..) |
ExprKind::Loop(..) | ExprKind::Loop(..) |
@ -4893,7 +4893,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Node::Expr(expr) = self.tcx.hir().get( if let Node::Expr(expr) = self.tcx.hir().get(
self.tcx.hir().get_parent_node(hir_id)) 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 { if callee.hir_id == hir_id {
return return
} }
@ -4968,7 +4968,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
while let hir::Node::Expr(parent_expr) = while let hir::Node::Expr(parent_expr) =
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id)) 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, ..) => { hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
if lhs.hir_id == expr_id { if lhs.hir_id == expr_id {
contained_in_place = true; contained_in_place = true;

View file

@ -306,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Byte string patterns behave the same way as array patterns // Byte string patterns behave the same way as array patterns
// They can denote both statically and dynamically-sized byte arrays. // They can denote both statically and dynamically-sized byte arrays.
let mut pat_ty = ty; 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 { if let ast::LitKind::ByteStr(_) = lt.node {
let expected_ty = self.structurally_resolved_type(span, expected); let expected_ty = self.structurally_resolved_type(span, expected);
if let ty::Ref(_, r_ty, _) = expected_ty.kind { if let ty::Ref(_, r_ty, _) = expected_ty.kind {

View file

@ -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 // arguments for its type parameters are well-formed, and all the regions
// provided as arguments outlive the call. // provided as arguments outlive the call.
if is_method_call { if is_method_call {
let origin = match expr.node { let origin = match expr.kind {
hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall, hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall,
hir::ExprKind::Unary(op, _) if op == hir::UnDeref => { hir::ExprKind::Unary(op, _) if op == hir::UnDeref => {
infer::ParameterOrigin::OverloadedDeref infer::ParameterOrigin::OverloadedDeref
@ -557,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
"regionck::visit_expr(e={:?}, repeating_scope={:?}) - visiting subexprs", "regionck::visit_expr(e={:?}, repeating_scope={:?}) - visiting subexprs",
expr, self.repeating_scope expr, self.repeating_scope
); );
match expr.node { match expr.kind {
hir::ExprKind::Path(_) => { hir::ExprKind::Path(_) => {
let substs = self.tables.borrow().node_substs(expr.hir_id); let substs = self.tables.borrow().node_substs(expr.hir_id);
let origin = infer::ParameterOrigin::Path; let origin = infer::ParameterOrigin::Path;

View file

@ -64,7 +64,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { 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); let body = self.fcx.tcx.hir().body(body_id);
self.visit_body(body); self.visit_body(body);
self.fcx self.fcx

View file

@ -134,7 +134,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
// we observe that something like `a+b` is (known to be) // we observe that something like `a+b` is (known to be)
// operating on scalars, we clear the overload. // operating on scalars, we clear the overload.
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { 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::UnNeg, ref inner)
| hir::ExprKind::Unary(hir::UnNot, ref inner) => { | hir::ExprKind::Unary(hir::UnNot, ref inner) => {
let inner_ty = self.fcx.node_ty(inner.hir_id); 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.type_dependent_defs_mut().remove(e.hir_id);
tables.node_substs_mut().remove(e.hir_id); tables.node_substs_mut().remove(e.hir_id);
match e.node { match e.kind {
hir::ExprKind::Binary(..) => { hir::ExprKind::Binary(..) => {
if !op.node.is_by_value() { if !op.node.is_by_value() {
let mut adjustments = tables.adjustments_mut(); 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 // to use builtin indexing because the index type is known to be
// usize-ish // usize-ish
fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { 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(); let mut tables = self.fcx.tables.borrow_mut();
// All valid indexing looks like this; might encounter non-valid indexes at this point // 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); self.visit_node_id(e.span, e.hir_id);
match e.node { match e.kind {
hir::ExprKind::Closure(_, _, body, _, _) => { hir::ExprKind::Closure(_, _, body, _, _) => {
let body = self.fcx.tcx.hir().body(body); let body = self.fcx.tcx.hir().body(body);
for param in &body.params { for param in &body.params {

View file

@ -135,7 +135,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { 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); let def_id = self.tcx.hir().local_def_id(expr.hir_id);
self.tcx.generics_of(def_id); self.tcx.generics_of(def_id);
self.tcx.type_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::Expr(&hir::Expr {
node: hir::ExprKind::Closure(..), kind: hir::ExprKind::Closure(..),
.. ..
}) => Some(tcx.closure_base_def_id(def_id)), }) => Some(tcx.closure_base_def_id(def_id)),
Node::Item(item) => match item.node { 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, // cares about anything but the length is instantiation,
// and we don't do that for closures. // and we don't do that for closures.
if let Node::Expr(&hir::Expr { if let Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., gen), kind: hir::ExprKind::Closure(.., gen),
.. ..
}) = node }) = node
{ {
@ -1355,7 +1355,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
Node::Field(field) => icx.to_ty(&field.ty), Node::Field(field) => icx.to_ty(&field.ty),
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., gen), kind: hir::ExprKind::Closure(.., gen),
.. ..
}) => { }) => {
if gen.is_some() { if gen.is_some() {
@ -1381,7 +1381,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
.. ..
}) })
| Node::Expr(&hir::Expr { | Node::Expr(&hir::Expr {
node: ExprKind::Repeat(_, ref constant), kind: ExprKind::Repeat(_, ref constant),
.. ..
}) if constant.hir_id == hir_id => }) if constant.hir_id == hir_id =>
{ {
@ -1400,8 +1400,8 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
} }
Node::Ty(&hir::Ty { node: hir::TyKind::Path(_), .. }) | Node::Ty(&hir::Ty { node: hir::TyKind::Path(_), .. }) |
Node::Expr(&hir::Expr { node: ExprKind::Struct(..), .. }) | Node::Expr(&hir::Expr { kind: ExprKind::Struct(..), .. }) |
Node::Expr(&hir::Expr { node: ExprKind::Path(_), .. }) | Node::Expr(&hir::Expr { kind: ExprKind::Path(_), .. }) |
Node::TraitRef(..) => { Node::TraitRef(..) => {
let path = match parent_node { let path = match parent_node {
Node::Ty(&hir::Ty { Node::Ty(&hir::Ty {
@ -1409,12 +1409,12 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
.. ..
}) })
| Node::Expr(&hir::Expr { | Node::Expr(&hir::Expr {
node: ExprKind::Path(QPath::Resolved(_, ref path)), kind: ExprKind::Path(QPath::Resolved(_, ref path)),
.. ..
}) => { }) => {
Some(&**path) 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 { if let QPath::Resolved(_, ref path) = **path {
Some(&**path) Some(&**path)
} else { } else {
@ -1847,7 +1847,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
} }
Expr(&hir::Expr { Expr(&hir::Expr {
node: hir::ExprKind::Closure(..), kind: hir::ExprKind::Closure(..),
.. ..
}) => { }) => {
// Closure signatures are not like other function // Closure signatures are not like other function

View file

@ -977,7 +977,7 @@ pub struct AnonConst {
#[derive(Clone, RustcEncodable, RustcDecodable)] #[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Expr { pub struct Expr {
pub id: NodeId, pub id: NodeId,
pub node: ExprKind, pub kind: ExprKind,
pub span: Span, pub span: Span,
pub attrs: ThinVec<Attribute>, pub attrs: ThinVec<Attribute>,
} }
@ -990,12 +990,12 @@ impl Expr {
/// Returns `true` if this expression would be valid somewhere that expects a value; /// Returns `true` if this expression would be valid somewhere that expects a value;
/// for example, an `if` condition. /// for example, an `if` condition.
pub fn returns(&self) -> bool { 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) { match block.stmts.last().map(|last_stmt| &last_stmt.node) {
// Implicit return // Implicit return
Some(&StmtKind::Expr(_)) => true, Some(&StmtKind::Expr(_)) => true,
Some(&StmtKind::Semi(ref expr)) => { Some(&StmtKind::Semi(ref expr)) => {
if let ExprKind::Ret(_) = expr.node { if let ExprKind::Ret(_) = expr.kind {
// Last statement is explicit return. // Last statement is explicit return.
true true
} else { } else {
@ -1012,7 +1012,7 @@ impl Expr {
} }
fn to_bound(&self) -> Option<GenericBound> { fn to_bound(&self) -> Option<GenericBound> {
match &self.node { match &self.kind {
ExprKind::Path(None, path) => Some(GenericBound::Trait( ExprKind::Path(None, path) => Some(GenericBound::Trait(
PolyTraitRef::new(Vec::new(), path.clone(), self.span), PolyTraitRef::new(Vec::new(), path.clone(), self.span),
TraitBoundModifier::None, TraitBoundModifier::None,
@ -1022,7 +1022,7 @@ impl Expr {
} }
pub(super) fn to_ty(&self) -> Option<P<Ty>> { pub(super) fn to_ty(&self) -> Option<P<Ty>> {
let node = match &self.node { let kind = match &self.kind {
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()), ExprKind::Mac(mac) => TyKind::Mac(mac.clone()),
ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?, ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
@ -1051,14 +1051,14 @@ impl Expr {
}; };
Some(P(Ty { Some(P(Ty {
node, node: kind,
id: self.id, id: self.id,
span: self.span, span: self.span,
})) }))
} }
pub fn precedence(&self) -> ExprPrecedence { pub fn precedence(&self) -> ExprPrecedence {
match self.node { match self.kind {
ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Box(_) => ExprPrecedence::Box,
ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call, ExprKind::Call(..) => ExprPrecedence::Call,

View file

@ -321,13 +321,13 @@ impl<'a> MutVisitor for StripUnconfigured<'a> {
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) { fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
self.configure_expr(expr); self.configure_expr(expr);
self.configure_expr_kind(&mut expr.node); self.configure_expr_kind(&mut expr.kind);
noop_visit_expr(expr, self); noop_visit_expr(expr, self);
} }
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> { fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let mut expr = configure!(self, expr); 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); noop_visit_expr(&mut expr, self);
Some(expr) Some(expr)
} }

View file

@ -507,7 +507,7 @@ impl MacResult for MacEager {
return Some(p); return Some(p);
} }
if let Some(e) = self.expr { 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 { return Some(P(ast::Pat {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
span: e.span, span: e.span,
@ -549,7 +549,7 @@ impl DummyResult {
pub fn raw_expr(sp: Span, is_error: bool) -> P<ast::Expr> { pub fn raw_expr(sp: Span, is_error: bool) -> P<ast::Expr> {
P(ast::Expr { P(ast::Expr {
id: ast::DUMMY_NODE_ID, 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, span: sp,
attrs: ThinVec::new(), 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")`. // We want to be able to handle e.g., `concat!("foo", "bar")`.
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); 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::ExprKind::Lit(ref l) => match l.node {
ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)), ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)),
ast::LitKind::Err(_) => None, ast::LitKind::Err(_) => None,

View file

@ -73,12 +73,12 @@ impl<'a> ExtCtxt<'a> {
self.ty_path(self.path_ident(span, ident)) 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 { ast::AnonConst {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
value: P(ast::Expr { value: P(ast::Expr {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: expr, kind,
span, span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
}) })
@ -239,10 +239,10 @@ impl<'a> ExtCtxt<'a> {
}) })
} }
pub fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr> { pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P<ast::Expr> {
P(ast::Expr { P(ast::Expr {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node, kind,
span, span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
}) })

View file

@ -1035,7 +1035,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) { fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
self.cfg.configure_expr(expr); self.cfg.configure_expr(expr);
visit_clobber(expr.deref_mut(), |mut 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 // ignore derives so they remain unused
let (attr, after_derive) = self.classify_nonitem(&mut expr); let (attr, after_derive) = self.classify_nonitem(&mut expr);
@ -1052,7 +1052,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
.into_inner() .into_inner()
} }
if let ast::ExprKind::Mac(mac) = expr.node { if let ast::ExprKind::Mac(mac) = expr.kind {
self.check_attributes(&expr.attrs); self.check_attributes(&expr.attrs);
self.collect_bang(mac, expr.span, AstFragmentKind::Expr) self.collect_bang(mac, expr.span, AstFragmentKind::Expr)
.make_expr() .make_expr()
@ -1145,7 +1145,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> { fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let expr = configure!(self, expr); let expr = configure!(self, expr);
expr.filter_map(|mut 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. // Ignore derives so they remain unused.
let (attr, after_derive) = self.classify_nonitem(&mut expr); 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()) .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.check_attributes(&expr.attrs);
self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr) self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr)
.make_opt_expr() .make_opt_expr()

View file

@ -30,7 +30,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
let expr_placeholder = || P(ast::Expr { let expr_placeholder = || P(ast::Expr {
id, span, id, span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
node: ast::ExprKind::Mac(mac_placeholder()), kind: ast::ExprKind::Mac(mac_placeholder()),
}); });
let ty = P(ast::Ty { let ty = P(ast::Ty {
id, id,
@ -282,14 +282,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
} }
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) { fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
match expr.node { match expr.kind {
ast::ExprKind::Mac(_) => *expr = self.remove(expr.id).make_expr(), ast::ExprKind::Mac(_) => *expr = self.remove(expr.id).make_expr(),
_ => noop_visit_expr(expr, self), _ => noop_visit_expr(expr, self),
} }
} }
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> { fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
match expr.node { match expr.kind {
ast::ExprKind::Mac(_) => self.remove(expr.id).make_opt_expr(), ast::ExprKind::Mac(_) => self.remove(expr.id).make_opt_expr(),
_ => noop_filter_map_expr(expr, self), _ => noop_filter_map_expr(expr, self),
} }

View file

@ -456,7 +456,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
} }
fn visit_expr(&mut self, e: &'a ast::Expr) { fn visit_expr(&mut self, e: &'a ast::Expr) {
match e.node { match e.kind {
ast::ExprKind::Box(_) => { ast::ExprKind::Box(_) => {
gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX); gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX);
} }

View file

@ -1097,8 +1097,8 @@ pub fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonCo
vis.visit_expr(value); vis.visit_expr(value);
} }
pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr, vis: &mut T) { pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr, vis: &mut T) {
match node { match kind {
ExprKind::Box(expr) => vis.visit_expr(expr), ExprKind::Box(expr) => vis.visit_expr(expr),
ExprKind::Array(exprs) => visit_exprs(exprs, vis), ExprKind::Array(exprs) => visit_exprs(exprs, vis),
ExprKind::Repeat(expr, count) => { ExprKind::Repeat(expr, count) => {

View file

@ -12,7 +12,7 @@ use crate::ast;
/// |x| 5 /// |x| 5
/// isn't parsed as (if true {...} else {...} | x) | 5 /// isn't parsed as (if true {...} else {...} | x) | 5
pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
match e.node { match e.kind {
ast::ExprKind::If(..) | ast::ExprKind::If(..) |
ast::ExprKind::Match(..) | ast::ExprKind::Match(..) |
ast::ExprKind::Block(..) | ast::ExprKind::Block(..) |

View file

@ -161,7 +161,7 @@ impl RecoverQPath for Expr {
fn recovered(qself: Option<QSelf>, path: ast::Path) -> Self { fn recovered(qself: Option<QSelf>, path: ast::Path) -> Self {
Self { Self {
span: path.span, span: path.span,
node: ExprKind::Path(qself, path), kind: ExprKind::Path(qself, path),
attrs: ThinVec::new(), attrs: ThinVec::new(),
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
} }
@ -549,7 +549,7 @@ impl<'a> Parser<'a> {
debug_assert!(outer_op.is_comparison(), debug_assert!(outer_op.is_comparison(),
"check_no_chained_comparison: {:?} is not comparison", "check_no_chained_comparison: {:?} is not comparison",
outer_op); outer_op);
match lhs.node { match lhs.kind {
ExprKind::Binary(op, _, _) if op.node.is_comparison() => { ExprKind::Binary(op, _, _) if op.node.is_comparison() => {
// Respan to include both operators. // Respan to include both operators.
let op_span = op.span.to(self.token.span); 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)); .unwrap_or_else(|_| pprust::expr_to_string(&expr));
let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" }); let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" });
let sp = lo.to(hi); let sp = lo.to(hi);
let app = match expr.node { let app = match expr.kind {
ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await <expr>?` ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await <expr>?`
_ => Applicability::MachineApplicable, _ => Applicability::MachineApplicable,
}; };

View file

@ -267,7 +267,7 @@ impl Lit {
lit, lit,
token::Interpolated(ref nt) => { token::Interpolated(ref nt) => {
if let token::NtExpr(expr) | token::NtLiteral(expr) = &**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()); return Ok(lit.clone());
} }
} }

View file

@ -210,7 +210,7 @@ impl<'a> Parser<'a> {
// it refers to. Interpolated identifiers are unwrapped early and never show up here // 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 // 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. // 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::Interpolated, _) => self.prev_span,
(PrevTokenKind::Ident, &ExprKind::Path(None, ref path)) (PrevTokenKind::Ident, &ExprKind::Path(None, ref path))
if path.segments.len() == 1 => self.prev_span, 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)?; lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?;
continue continue
} else if op == AssocOp::Colon { } 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)); self.last_type_ascription = Some((self.prev_span, maybe_path));
lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?; lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?;
@ -614,7 +614,7 @@ impl<'a> Parser<'a> {
expr.map(|mut expr| { expr.map(|mut expr| {
attrs.extend::<Vec<_>>(expr.attrs.into()); attrs.extend::<Vec<_>>(expr.attrs.into());
expr.attrs = attrs; expr.attrs = attrs;
match expr.node { match expr.kind {
ExprKind::If(..) if !expr.attrs.is_empty() => { ExprKind::If(..) if !expr.attrs.is_empty() => {
// Just point to the first attribute in there... // Just point to the first attribute in there...
let span = expr.attrs[0].span; let span = expr.attrs[0].span;
@ -1242,7 +1242,7 @@ impl<'a> Parser<'a> {
fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> { fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> {
let cond = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; 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. // Remove the last feature gating of a `let` expression since it's stable.
let last = self.sess.gated_spans.let_chains.borrow_mut().pop(); let last = self.sess.gated_spans.let_chains.borrow_mut().pop();
debug_assert_eq!(cond.span, last.unwrap()); debug_assert_eq!(cond.span, last.unwrap());
@ -1779,7 +1779,7 @@ impl<'a> Parser<'a> {
Ok(await_expr) Ok(await_expr)
} }
crate fn mk_expr(&self, span: Span, node: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> { crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
P(Expr { node, span, attrs, id: DUMMY_NODE_ID }) P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
} }
} }

View file

@ -272,7 +272,7 @@ fn ttdelim_span() {
let expr = parse_expr_from_source_str(PathBuf::from("foo").into(), let expr = parse_expr_from_source_str(PathBuf::from("foo").into(),
"foo!( fn main() { body } )".to_string(), &sess).unwrap(); "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(), ast::ExprKind::Mac(ref mac) => mac.stream().trees().collect(),
_ => panic!("not a macro"), _ => panic!("not a macro"),
}; };

View file

@ -1734,33 +1734,30 @@ impl<'a> State<'a> {
} }
fn print_else(&mut self, els: Option<&ast::Expr>) { fn print_else(&mut self, els: Option<&ast::Expr>) {
match els { if let Some(_else) = els {
Some(_else) => { match _else.kind {
match _else.node { // Another `else if` block.
// Another `else if` block. ast::ExprKind::If(ref i, ref then, ref e) => {
ast::ExprKind::If(ref i, ref then, ref e) => { self.cbox(INDENT_UNIT - 1);
self.cbox(INDENT_UNIT - 1); self.ibox(0);
self.ibox(0); self.s.word(" else if ");
self.s.word(" else if "); self.print_expr_as_cond(i);
self.print_expr_as_cond(i); self.s.space();
self.s.space(); self.print_block(then);
self.print_block(then); self.print_else(e.as_ref().map(|e| &**e))
self.print_else(e.as_ref().map(|e| &**e)) }
} // Final `else` block.
// Final `else` block. ast::ExprKind::Block(ref b, _) => {
ast::ExprKind::Block(ref b, _) => { self.cbox(INDENT_UNIT - 1);
self.cbox(INDENT_UNIT - 1); self.ibox(0);
self.ibox(0); self.s.word(" else ");
self.s.word(" else "); self.print_block(b)
self.print_block(b) }
} // Constraints would be great here!
// Constraints would be great here! _ => {
_ => { panic!("print_if saw if with weird alternative");
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? /// Does `expr` need parenthesis when printed in a condition position?
fn cond_needs_par(expr: &ast::Expr) -> bool { 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 {}` // These cases need parens due to the parse error observed in #26461: `if return {}`
// parses as the erroneous construct `if (return {})`, not `if (return) {}`. // parses as the erroneous construct `if (return {})`, not `if (return) {}`.
ast::ExprKind::Closure(..) | ast::ExprKind::Closure(..) |
@ -1905,7 +1902,7 @@ impl<'a> State<'a> {
func: &ast::Expr, func: &ast::Expr,
args: &[P<ast::Expr>]) { args: &[P<ast::Expr>]) {
let prec = let prec =
match func.node { match func.kind {
ast::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, ast::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
_ => parser::PREC_POSTFIX, _ => parser::PREC_POSTFIX,
}; };
@ -1941,7 +1938,7 @@ impl<'a> State<'a> {
Fixity::None => (prec + 1, prec + 1), 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 // 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 // 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. // 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.ibox(INDENT_UNIT);
self.ann.pre(self, AnnNode::Expr(expr)); self.ann.pre(self, AnnNode::Expr(expr));
match expr.node { match expr.kind {
ast::ExprKind::Box(ref expr) => { ast::ExprKind::Box(ref expr) => {
self.word_space("box"); self.word_space("box");
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
@ -2477,7 +2474,7 @@ impl<'a> State<'a> {
} }
self.word_space("=>"); self.word_space("=>");
match arm.body.node { match arm.body.kind {
ast::ExprKind::Block(ref blk, opt_label) => { ast::ExprKind::Block(ref blk, opt_label) => {
if let Some(label) = opt_label { if let Some(label) = opt_label {
self.print_ident(label.ident); self.print_ident(label.ident);

View file

@ -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 /// 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. /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
match value.node { match value.kind {
ast::ExprKind::Struct(..) => true, ast::ExprKind::Struct(..) => true,
ast::ExprKind::Assign(ref lhs, ref rhs) | ast::ExprKind::Assign(ref lhs, ref rhs) |

View file

@ -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) { pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
walk_list!(visitor, visit_attribute, expression.attrs.iter()); walk_list!(visitor, visit_attribute, expression.attrs.iter());
match expression.node { match expression.kind {
ExprKind::Box(ref subexpression) => { ExprKind::Box(ref subexpression) => {
visitor.visit_expr(subexpression) visitor.visit_expr(subexpression)
} }

View file

@ -61,7 +61,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
MacEager::expr(P(ast::Expr { MacEager::expr(P(ast::Expr {
id: ast::DUMMY_NODE_ID, 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), span: cx.with_def_site_ctxt(sp),
attrs: ThinVec::new(), attrs: ThinVec::new(),
})) }))

View file

@ -18,7 +18,7 @@ pub fn expand_concat(
let mut missing_literal = vec![]; let mut missing_literal = vec![];
let mut has_errors = false; let mut has_errors = false;
for e in es { for e in es {
match e.node { match e.kind {
ast::ExprKind::Lit(ref lit) => match lit.node { ast::ExprKind::Lit(ref lit) => match lit.node {
ast::LitKind::Str(ref s, _) ast::LitKind::Str(ref s, _)
| ast::LitKind::Float(ref s, _) | ast::LitKind::Float(ref s, _)

View file

@ -47,7 +47,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>,
fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> { fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
Some(P(ast::Expr { Some(P(ast::Expr {
id: ast::DUMMY_NODE_ID, 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, span: self.ident.span,
attrs: ThinVec::new(), attrs: ThinVec::new(),
})) }))

View file

@ -172,7 +172,7 @@ struct RemoveParens;
impl MutVisitor for RemoveParens { impl MutVisitor for RemoveParens {
fn visit_expr(&mut self, e: &mut P<Expr>) { fn visit_expr(&mut self, e: &mut P<Expr>) {
match e.node.clone() { match e.kind.clone() {
ExprKind::Paren(inner) => *e = inner, ExprKind::Paren(inner) => *e = inner,
_ => {} _ => {}
}; };
@ -190,7 +190,7 @@ impl MutVisitor for AddParens {
visit_clobber(e, |e| { visit_clobber(e, |e| {
P(Expr { P(Expr {
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
node: ExprKind::Paren(e), kind: ExprKind::Paren(e),
span: DUMMY_SP, span: DUMMY_SP,
attrs: ThinVec::new(), attrs: ThinVec::new(),
}) })