Skip to content

Commit 95f6d72

Browse files
committed
Rename Expr.node to Expr.kind
For both `ast::Expr` and `hir::Expr`.
1 parent ddf4386 commit 95f6d72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+281
-290
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> {
280280
}
281281

282282
fn check_expr_attributes(&self, expr: &hir::Expr) {
283-
let target = match expr.node {
283+
let target = match expr.kind {
284284
hir::ExprKind::Closure(..) => Target::Closure,
285285
_ => Target::Expression,
286286
};

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
992992
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
993993
visitor.visit_id(expression.hir_id);
994994
walk_list!(visitor, visit_attribute, expression.attrs.iter());
995-
match expression.node {
995+
match expression.kind {
996996
ExprKind::Box(ref subexpression) => {
997997
visitor.visit_expr(subexpression)
998998
}

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
33783378
}
33793379
};
33803380

3381-
match expr.node {
3381+
match expr.kind {
33823382
// All built-in range literals but `..=` and `..` desugar to `Struct`s.
33833383
ExprKind::Struct(ref qpath, _, _) => {
33843384
if let QPath::Resolved(None, ref path) = **qpath {
@@ -3393,7 +3393,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
33933393

33943394
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
33953395
ExprKind::Call(ref func, _) => {
3396-
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node {
3396+
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
33973397
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
33983398
let new_call = segment.ident.as_str() == "new";
33993399
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;

src/librustc/hir/lowering/expr.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl LoweringContext<'_> {
1717
}
1818

1919
pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
20-
let kind = match e.node {
20+
let kind = match e.kind {
2121
ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))),
2222
ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
2323
ExprKind::Repeat(ref expr, ref count) => {
@@ -184,7 +184,7 @@ impl LoweringContext<'_> {
184184

185185
hir::Expr {
186186
hir_id: self.lower_node_id(e.id),
187-
node: kind,
187+
kind,
188188
span: e.span,
189189
attrs: e.attrs.clone(),
190190
}
@@ -282,7 +282,7 @@ impl LoweringContext<'_> {
282282

283283
// Handle then + scrutinee:
284284
let then_expr = self.lower_block_expr(then);
285-
let (then_pat, scrutinee, desugar) = match cond.node {
285+
let (then_pat, scrutinee, desugar) = match cond.kind {
286286
// `<pat> => <then>`:
287287
ExprKind::Let(ref pat, ref scrutinee) => {
288288
let scrutinee = self.lower_expr(scrutinee);
@@ -332,7 +332,7 @@ impl LoweringContext<'_> {
332332

333333
// Handle then + scrutinee:
334334
let then_expr = self.lower_block_expr(body);
335-
let (then_pat, scrutinee, desugar, source) = match cond.node {
335+
let (then_pat, scrutinee, desugar, source) = match cond.kind {
336336
ExprKind::Let(ref pat, ref scrutinee) => {
337337
// to:
338338
//
@@ -459,7 +459,7 @@ impl LoweringContext<'_> {
459459
});
460460

461461
// `static || -> <ret_ty> { body }`:
462-
let generator_node = hir::ExprKind::Closure(
462+
let generator_kind = hir::ExprKind::Closure(
463463
capture_clause,
464464
decl,
465465
body_id,
@@ -468,7 +468,7 @@ impl LoweringContext<'_> {
468468
);
469469
let generator = hir::Expr {
470470
hir_id: self.lower_node_id(closure_node_id),
471-
node: generator_node,
471+
kind: generator_kind,
472472
span,
473473
attrs: ThinVec::new(),
474474
};
@@ -625,7 +625,7 @@ impl LoweringContext<'_> {
625625
// loop { .. }
626626
let loop_expr = P(hir::Expr {
627627
hir_id: loop_hir_id,
628-
node: hir::ExprKind::Loop(
628+
kind: hir::ExprKind::Loop(
629629
loop_block,
630630
None,
631631
hir::LoopSource::Loop,
@@ -1135,14 +1135,14 @@ impl LoweringContext<'_> {
11351135
));
11361136

11371137
// `[opt_ident]: loop { ... }`
1138-
let loop_expr = hir::ExprKind::Loop(
1138+
let kind = hir::ExprKind::Loop(
11391139
loop_block,
11401140
self.lower_label(opt_label),
11411141
hir::LoopSource::ForLoop,
11421142
);
11431143
let loop_expr = P(hir::Expr {
11441144
hir_id: self.lower_node_id(e.id),
1145-
node: loop_expr,
1145+
kind,
11461146
span: e.span,
11471147
attrs: ThinVec::new(),
11481148
});
@@ -1443,15 +1443,10 @@ impl LoweringContext<'_> {
14431443
pub(super) fn expr(
14441444
&mut self,
14451445
span: Span,
1446-
node: hir::ExprKind,
1446+
kind: hir::ExprKind,
14471447
attrs: ThinVec<Attribute>
14481448
) -> hir::Expr {
1449-
hir::Expr {
1450-
hir_id: self.next_id(),
1451-
node,
1452-
span,
1453-
attrs,
1454-
}
1449+
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
14551450
}
14561451

14571452
fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {

src/librustc/hir/map/blocks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl MaybeFnLike for ast::TraitItem {
5858

5959
impl MaybeFnLike for ast::Expr {
6060
fn is_fn_like(&self) -> bool {
61-
match self.node {
61+
match self.kind {
6262
ast::ExprKind::Closure(..) => true,
6363
_ => false,
6464
}
@@ -241,7 +241,7 @@ impl<'a> FnLikeNode<'a> {
241241
_ => bug!("impl method FnLikeNode that is not fn-like")
242242
}
243243
},
244-
map::Node::Expr(e) => match e.node {
244+
map::Node::Expr(e) => match e.kind {
245245
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
246246
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
247247
_ => bug!("expr FnLikeNode that is not fn-like"),

src/librustc/hir/map/def_collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
271271
}
272272

273273
fn visit_expr(&mut self, expr: &'a Expr) {
274-
let parent_def = match expr.node {
274+
let parent_def = match expr.kind {
275275
ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id),
276276
ExprKind::Closure(_, asyncness, ..) => {
277277
// Async closures desugar to closures inside of closures, so
@@ -312,7 +312,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
312312
fn visit_token(&mut self, t: Token) {
313313
if let token::Interpolated(nt) = t.kind {
314314
if let token::NtExpr(ref expr) = *nt {
315-
if let ExprKind::Mac(..) = expr.node {
315+
if let ExprKind::Mac(..) = expr.kind {
316316
self.visit_macro_invoc(expr.id);
317317
}
318318
}

src/librustc/hir/map/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'hir> Entry<'hir> {
7171
}
7272

7373
Node::Expr(ref expr) => {
74-
match expr.node {
74+
match expr.kind {
7575
ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl),
7676
_ => None,
7777
}
@@ -111,7 +111,7 @@ impl<'hir> Entry<'hir> {
111111
Node::AnonConst(constant) => Some(constant.body),
112112

113113
Node::Expr(expr) => {
114-
match expr.node {
114+
match expr.kind {
115115
ExprKind::Closure(.., body, _, _) => Some(body),
116116
_ => None,
117117
}
@@ -468,7 +468,7 @@ impl<'hir> Map<'hir> {
468468
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
469469
BodyOwnerKind::Static(m)
470470
}
471-
Node::Expr(&Expr { node: ExprKind::Closure(..), .. }) => {
471+
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
472472
BodyOwnerKind::Closure
473473
}
474474
node => bug!("{:#?} is not a body node", node),
@@ -634,7 +634,7 @@ impl<'hir> Map<'hir> {
634634
Some(Node::TraitItem(_)) |
635635
Some(Node::ImplItem(_)) => true,
636636
Some(Node::Expr(e)) => {
637-
match e.node {
637+
match e.kind {
638638
ExprKind::Closure(..) => true,
639639
_ => false,
640640
}
@@ -749,15 +749,15 @@ impl<'hir> Map<'hir> {
749749
Node::Item(_) |
750750
Node::ForeignItem(_) |
751751
Node::TraitItem(_) |
752-
Node::Expr(Expr { node: ExprKind::Closure(..), ..}) |
752+
Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) |
753753
Node::ImplItem(_) => true,
754754
_ => false,
755755
}
756756
};
757757
let match_non_returning_block = |node: &Node<'_>| {
758758
match *node {
759759
Node::Expr(ref expr) => {
760-
match expr.node {
760+
match expr.kind {
761761
ExprKind::Loop(..) | ExprKind::Ret(..) => true,
762762
_ => false,
763763
}

src/librustc/hir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ pub struct AnonConst {
14341434
#[derive(RustcEncodable, RustcDecodable)]
14351435
pub struct Expr {
14361436
pub hir_id: HirId,
1437-
pub node: ExprKind,
1437+
pub kind: ExprKind,
14381438
pub attrs: ThinVec<Attribute>,
14391439
pub span: Span,
14401440
}
@@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72);
14451445

14461446
impl Expr {
14471447
pub fn precedence(&self) -> ExprPrecedence {
1448-
match self.node {
1448+
match self.kind {
14491449
ExprKind::Box(_) => ExprPrecedence::Box,
14501450
ExprKind::Array(_) => ExprPrecedence::Array,
14511451
ExprKind::Call(..) => ExprPrecedence::Call,
@@ -1478,7 +1478,7 @@ impl Expr {
14781478
}
14791479

14801480
pub fn is_place_expr(&self) -> bool {
1481-
match self.node {
1481+
match self.kind {
14821482
ExprKind::Path(QPath::Resolved(_, ref path)) => {
14831483
match path.res {
14841484
Res::Local(..)

src/librustc/hir/print.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ impl<'a> State<'a> {
10351035
/// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in
10361036
/// `if cond { ... }`.
10371037
pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) {
1038-
let needs_par = match expr.node {
1038+
let needs_par = match expr.kind {
10391039
// These cases need parens due to the parse error observed in #26461: `if return {}`
10401040
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
10411041
hir::ExprKind::Closure(..) |
@@ -1119,11 +1119,10 @@ impl<'a> State<'a> {
11191119
}
11201120

11211121
fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
1122-
let prec =
1123-
match func.node {
1124-
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
1125-
_ => parser::PREC_POSTFIX,
1126-
};
1122+
let prec = match func.kind {
1123+
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
1124+
_ => parser::PREC_POSTFIX,
1125+
};
11271126

11281127
self.print_expr_maybe_paren(func, prec);
11291128
self.print_call_post(args)
@@ -1161,7 +1160,7 @@ impl<'a> State<'a> {
11611160
Fixity::None => (prec + 1, prec + 1),
11621161
};
11631162

1164-
let left_prec = match (&lhs.node, op.node) {
1163+
let left_prec = match (&lhs.kind, op.node) {
11651164
// These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
11661165
// the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
11671166
// of `(x as i32) < ...`. We need to convince it _not_ to do that.
@@ -1200,7 +1199,7 @@ impl<'a> State<'a> {
12001199
self.print_outer_attributes(&expr.attrs);
12011200
self.ibox(INDENT_UNIT);
12021201
self.ann.pre(self, AnnNode::Expr(expr));
1203-
match expr.node {
1202+
match expr.kind {
12041203
hir::ExprKind::Box(ref expr) => {
12051204
self.word_space("box");
12061205
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
@@ -1803,7 +1802,7 @@ impl<'a> State<'a> {
18031802
}
18041803
self.word_space("=>");
18051804

1806-
match arm.body.node {
1805+
match arm.body.kind {
18071806
hir::ExprKind::Block(ref blk, opt_label) => {
18081807
if let Some(label) = opt_label {
18091808
self.print_ident(label.ident);
@@ -2222,7 +2221,7 @@ impl<'a> State<'a> {
22222221
//
22232222
// Duplicated from `parse::classify`, but adapted for the HIR.
22242223
fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
2225-
match e.node {
2224+
match e.kind {
22262225
hir::ExprKind::Match(..) |
22272226
hir::ExprKind::Block(..) |
22282227
hir::ExprKind::Loop(..) => false,
@@ -2273,7 +2272,7 @@ fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
22732272
/// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
22742273
/// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
22752274
fn contains_exterior_struct_lit(value: &hir::Expr) -> bool {
2276-
match value.node {
2275+
match value.kind {
22772276
hir::ExprKind::Struct(..) => true,
22782277

22792278
hir::ExprKind::Assign(ref lhs, ref rhs) |

src/librustc/hir/upvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
8282
}
8383

8484
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
85-
if let hir::ExprKind::Closure(..) = expr.node {
85+
if let hir::ExprKind::Closure(..) = expr.kind {
8686
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
8787
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
8888
// Every capture of a closure expression is a local in scope,

src/librustc/ich/impls_hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
173173
let hir::Expr {
174174
hir_id: _,
175175
ref span,
176-
ref node,
176+
ref kind,
177177
ref attrs
178178
} = *self;
179179

180180
span.hash_stable(hcx, hasher);
181-
node.hash_stable(hcx, hasher);
181+
kind.hash_stable(hcx, hasher);
182182
attrs.hash_stable(hcx, hasher);
183183
})
184184
}

src/librustc/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> {
9090
let span = scope.span(self, region_scope_tree);
9191
let tag = match self.hir().find(scope.hir_id(region_scope_tree)) {
9292
Some(Node::Block(_)) => "block",
93-
Some(Node::Expr(expr)) => match expr.node {
93+
Some(Node::Expr(expr)) => match expr.kind {
9494
hir::ExprKind::Call(..) => "call",
9595
hir::ExprKind::MethodCall(..) => "method call",
9696
hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
@@ -639,7 +639,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
639639
hir::MatchSource::TryDesugar => {
640640
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
641641
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
642-
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
642+
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.kind {
643643
let arg_expr = args.first().expect("try desugaring call w/out arg");
644644
self.in_progress_tables.and_then(|tables| {
645645
tables.borrow().expr_ty_opt(arg_expr)

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
9292

9393
fn visit_expr(&mut self, expr: &'tcx Expr) {
9494
if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = (
95-
&expr.node,
95+
&expr.kind,
9696
self.node_matches_type(expr.hir_id),
9797
) {
98-
self.found_closure = Some(&expr.node);
98+
self.found_closure = Some(&expr.kind);
9999
}
100100
intravisit::walk_expr(self, expr);
101101
}
@@ -114,7 +114,7 @@ fn closure_return_type_suggestion(
114114
FunctionRetTy::DefaultReturn(_) => ("-> ", " "),
115115
_ => ("", ""),
116116
};
117-
let suggestion = match body.value.node {
117+
let suggestion = match body.value.kind {
118118
ExprKind::Block(..) => {
119119
vec![(output.span(), format!("{}{}{}", arrow, ret, post))]
120120
}

src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5050
let hir = &self.tcx().hir();
5151
if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) {
5252
if let Node::Expr(Expr {
53-
node: Closure(_, _, _, closure_span, None),
53+
kind: Closure(_, _, _, closure_span, None),
5454
..
5555
}) = hir.get(hir_id) {
5656
let sup_sp = sup_origin.span();

0 commit comments

Comments
 (0)