Skip to content
Permalink
Browse files

Rename `Expr.node` to `Expr.kind`

For both `ast::Expr` and `hir::Expr`.
  • Loading branch information...
varkor committed Sep 26, 2019
1 parent ddf4386 commit 95f6d72a60461a4a432d7e8971bb6a1899456b56
Showing with 281 additions and 290 deletions.
  1. +1 −1 src/librustc/hir/check_attr.rs
  2. +1 −1 src/librustc/hir/intravisit.rs
  3. +2 −2 src/librustc/hir/lowering.rs
  4. +11 −16 src/librustc/hir/lowering/expr.rs
  5. +2 −2 src/librustc/hir/map/blocks.rs
  6. +2 −2 src/librustc/hir/map/def_collector.rs
  7. +6 −6 src/librustc/hir/map/mod.rs
  8. +3 −3 src/librustc/hir/mod.rs
  9. +10 −11 src/librustc/hir/print.rs
  10. +1 −1 src/librustc/hir/upvars.rs
  11. +2 −2 src/librustc/ich/impls_hir.rs
  12. +2 −2 src/librustc/infer/error_reporting/mod.rs
  13. +3 −3 src/librustc/infer/error_reporting/need_type_info.rs
  14. +1 −1 src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs
  15. +1 −1 src/librustc/middle/dead.rs
  16. +1 −1 src/librustc/middle/expr_use_visitor.rs
  17. +1 −1 src/librustc/middle/intrinsicck.rs
  18. +6 −6 src/librustc/middle/liveness.rs
  19. +1 −1 src/librustc/middle/mem_categorization.rs
  20. +2 −2 src/librustc/middle/reachable.rs
  21. +5 −5 src/librustc/middle/region.rs
  22. +1 −1 src/librustc/middle/resolve_lifetime.rs
  23. +3 −3 src/librustc/traits/error_reporting.rs
  24. +1 −1 src/librustc/ty/context.rs
  25. +1 −1 src/librustc_ast_borrowck/borrowck/check_loans.rs
  26. +1 −1 src/librustc_ast_borrowck/borrowck/mod.rs
  27. +1 −1 src/librustc_ast_borrowck/cfg/construct.rs
  28. +2 −2 src/librustc_interface/util.rs
  29. +8 −8 src/librustc_lint/builtin.rs
  30. +1 −1 src/librustc_lint/redundant_semicolon.rs
  31. +7 −7 src/librustc_lint/types.rs
  32. +10 −10 src/librustc_lint/unused.rs
  33. +1 −1 src/librustc_metadata/encoder.rs
  34. +1 −1 src/librustc_mir/borrow_check/error_reporting.rs
  35. +1 −1 src/librustc_mir/borrow_check/mod.rs
  36. +3 −3 src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
  37. +1 −1 src/librustc_mir/build/expr/stmt.rs
  38. +1 −1 src/librustc_mir/build/mod.rs
  39. +4 −4 src/librustc_mir/hair/cx/expr.rs
  40. +1 −1 src/librustc_mir/hair/pattern/check_match.rs
  41. +2 −2 src/librustc_mir/hair/pattern/mod.rs
  42. +3 −3 src/librustc_passes/ast_validation.rs
  43. +2 −2 src/librustc_passes/loops.rs
  44. +4 −4 src/librustc_passes/rvalue_promotion.rs
  45. +2 −2 src/librustc_privacy/lib.rs
  46. +7 −7 src/librustc_resolve/build_reduced_graph.rs
  47. +3 −3 src/librustc_resolve/late.rs
  48. +1 −1 src/librustc_resolve/late/diagnostics.rs
  49. +3 −3 src/librustc_save_analysis/dump_visitor.rs
  50. +3 −3 src/librustc_save_analysis/lib.rs
  51. +2 −2 src/librustc_typeck/astconv.rs
  52. +4 −4 src/librustc_typeck/check/_match.rs
  53. +8 −8 src/librustc_typeck/check/callee.rs
  54. +15 −15 src/librustc_typeck/check/demand.rs
  55. +5 −5 src/librustc_typeck/check/expr.rs
  56. +2 −2 src/librustc_typeck/check/method/confirm.rs
  57. +2 −2 src/librustc_typeck/check/method/suggest.rs
  58. +10 −10 src/librustc_typeck/check/mod.rs
  59. +1 −1 src/librustc_typeck/check/pat.rs
  60. +2 −2 src/librustc_typeck/check/regionck.rs
  61. +1 −1 src/librustc_typeck/check/upvar.rs
  62. +4 −4 src/librustc_typeck/check/writeback.rs
  63. +10 −10 src/librustc_typeck/collect.rs
  64. +7 −7 src/libsyntax/ast.rs
  65. +2 −2 src/libsyntax/config.rs
  66. +3 −3 src/libsyntax/ext/base.rs
  67. +4 −4 src/libsyntax/ext/build.rs
  68. +4 −4 src/libsyntax/ext/expand.rs
  69. +3 −3 src/libsyntax/ext/placeholders.rs
  70. +1 −1 src/libsyntax/feature_gate/check.rs
  71. +2 −2 src/libsyntax/mut_visit.rs
  72. +1 −1 src/libsyntax/parse/classify.rs
  73. +3 −3 src/libsyntax/parse/diagnostics.rs
  74. +1 −1 src/libsyntax/parse/literal.rs
  75. +6 −6 src/libsyntax/parse/parser/expr.rs
  76. +1 −1 src/libsyntax/parse/tests.rs
  77. +27 −30 src/libsyntax/print/pprust.rs
  78. +1 −1 src/libsyntax/util/parser.rs
  79. +1 −1 src/libsyntax/visit.rs
  80. +1 −1 src/libsyntax_ext/asm.rs
  81. +1 −1 src/libsyntax_ext/concat.rs
  82. +1 −1 src/libsyntax_ext/concat_idents.rs
  83. +2 −2 src/test/ui-fulldeps/pprust-expr-roundtrip.rs
@@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> {
}

fn check_expr_attributes(&self, expr: &hir::Expr) {
let target = match expr.node {
let target = match expr.kind {
hir::ExprKind::Closure(..) => Target::Closure,
_ => Target::Expression,
};
@@ -992,7 +992,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor.visit_id(expression.hir_id);
walk_list!(visitor, visit_attribute, expression.attrs.iter());
match expression.node {
match expression.kind {
ExprKind::Box(ref subexpression) => {
visitor.visit_expr(subexpression)
}
@@ -3378,7 +3378,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
}
};

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

// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
ExprKind::Call(ref func, _) => {
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node {
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
let new_call = segment.ident.as_str() == "new";
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;
@@ -17,7 +17,7 @@ impl LoweringContext<'_> {
}

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

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

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

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

// `static || -> <ret_ty> { body }`:
let generator_node = hir::ExprKind::Closure(
let generator_kind = hir::ExprKind::Closure(
capture_clause,
decl,
body_id,
@@ -468,7 +468,7 @@ impl LoweringContext<'_> {
);
let generator = hir::Expr {
hir_id: self.lower_node_id(closure_node_id),
node: generator_node,
kind: generator_kind,
span,
attrs: ThinVec::new(),
};
@@ -625,7 +625,7 @@ impl LoweringContext<'_> {
// loop { .. }
let loop_expr = P(hir::Expr {
hir_id: loop_hir_id,
node: hir::ExprKind::Loop(
kind: hir::ExprKind::Loop(
loop_block,
None,
hir::LoopSource::Loop,
@@ -1135,14 +1135,14 @@ impl LoweringContext<'_> {
));

// `[opt_ident]: loop { ... }`
let loop_expr = hir::ExprKind::Loop(
let kind = hir::ExprKind::Loop(
loop_block,
self.lower_label(opt_label),
hir::LoopSource::ForLoop,
);
let loop_expr = P(hir::Expr {
hir_id: self.lower_node_id(e.id),
node: loop_expr,
kind,
span: e.span,
attrs: ThinVec::new(),
});
@@ -1443,15 +1443,10 @@ impl LoweringContext<'_> {
pub(super) fn expr(
&mut self,
span: Span,
node: hir::ExprKind,
kind: hir::ExprKind,
attrs: ThinVec<Attribute>
) -> hir::Expr {
hir::Expr {
hir_id: self.next_id(),
node,
span,
attrs,
}
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
}

fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
@@ -58,7 +58,7 @@ impl MaybeFnLike for ast::TraitItem {

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

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

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

Node::Expr(expr) => {
match expr.node {
match expr.kind {
ExprKind::Closure(.., body, _, _) => Some(body),
_ => None,
}
@@ -468,7 +468,7 @@ impl<'hir> Map<'hir> {
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
BodyOwnerKind::Static(m)
}
Node::Expr(&Expr { node: ExprKind::Closure(..), .. }) => {
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
BodyOwnerKind::Closure
}
node => bug!("{:#?} is not a body node", node),
@@ -634,7 +634,7 @@ impl<'hir> Map<'hir> {
Some(Node::TraitItem(_)) |
Some(Node::ImplItem(_)) => true,
Some(Node::Expr(e)) => {
match e.node {
match e.kind {
ExprKind::Closure(..) => true,
_ => false,
}
@@ -749,15 +749,15 @@ impl<'hir> Map<'hir> {
Node::Item(_) |
Node::ForeignItem(_) |
Node::TraitItem(_) |
Node::Expr(Expr { node: ExprKind::Closure(..), ..}) |
Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) |
Node::ImplItem(_) => true,
_ => false,
}
};
let match_non_returning_block = |node: &Node<'_>| {
match *node {
Node::Expr(ref expr) => {
match expr.node {
match expr.kind {
ExprKind::Loop(..) | ExprKind::Ret(..) => true,
_ => false,
}
@@ -1434,7 +1434,7 @@ pub struct AnonConst {
#[derive(RustcEncodable, RustcDecodable)]
pub struct Expr {
pub hir_id: HirId,
pub node: ExprKind,
pub kind: ExprKind,
pub attrs: ThinVec<Attribute>,
pub span: Span,
}
@@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72);

impl Expr {
pub fn precedence(&self) -> ExprPrecedence {
match self.node {
match self.kind {
ExprKind::Box(_) => ExprPrecedence::Box,
ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call,
@@ -1478,7 +1478,7 @@ impl Expr {
}

pub fn is_place_expr(&self) -> bool {
match self.node {
match self.kind {
ExprKind::Path(QPath::Resolved(_, ref path)) => {
match path.res {
Res::Local(..)
@@ -1035,7 +1035,7 @@ impl<'a> State<'a> {
/// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in
/// `if cond { ... }`.
pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) {
let needs_par = match expr.node {
let needs_par = match expr.kind {
// These cases need parens due to the parse error observed in #26461: `if return {}`
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
hir::ExprKind::Closure(..) |
@@ -1119,11 +1119,10 @@ impl<'a> State<'a> {
}

fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
let prec =
match func.node {
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
_ => parser::PREC_POSTFIX,
};
let prec = match func.kind {
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
_ => parser::PREC_POSTFIX,
};

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

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

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

hir::ExprKind::Assign(ref lhs, ref rhs) |
@@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
}

fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
if let hir::ExprKind::Closure(..) = expr.node {
if let hir::ExprKind::Closure(..) = expr.kind {
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
// Every capture of a closure expression is a local in scope,
@@ -173,12 +173,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
let hir::Expr {
hir_id: _,
ref span,
ref node,
ref kind,
ref attrs
} = *self;

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

fn visit_expr(&mut self, expr: &'tcx Expr) {
if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = (
&expr.node,
&expr.kind,
self.node_matches_type(expr.hir_id),
) {
self.found_closure = Some(&expr.node);
self.found_closure = Some(&expr.kind);
}
intravisit::walk_expr(self, expr);
}
@@ -114,7 +114,7 @@ fn closure_return_type_suggestion(
FunctionRetTy::DefaultReturn(_) => ("-> ", " "),
_ => ("", ""),
};
let suggestion = match body.value.node {
let suggestion = match body.value.kind {
ExprKind::Block(..) => {
vec![(output.span(), format!("{}{}{}", arrow, ret, post))]
}
@@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let hir = &self.tcx().hir();
if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) {
if let Node::Expr(Expr {
node: Closure(_, _, _, closure_span, None),
kind: Closure(_, _, _, closure_span, None),
..
}) = hir.get(hir_id) {
let sup_sp = sup_origin.span();

0 comments on commit 95f6d72

Please sign in to comment.
You can’t perform that action at this time.