Skip to content
Permalink
Browse files

Rename `Pat.node` to `Pat.kind`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent 95f6d72 commit 8bd0382134368d8bc017185baba9e5276693ef6a
Showing with 135 additions and 135 deletions.
  1. +1 −1 src/librustc/hir/intravisit.rs
  2. +11 −11 src/librustc/hir/lowering.rs
  3. +1 −1 src/librustc/hir/lowering/item.rs
  4. +1 −1 src/librustc/hir/map/collector.rs
  5. +1 −1 src/librustc/hir/map/def_collector.rs
  6. +1 −1 src/librustc/hir/map/mod.rs
  7. +4 −4 src/librustc/hir/mod.rs
  8. +7 −7 src/librustc/hir/pat_util.rs
  9. +4 −4 src/librustc/hir/print.rs
  10. +1 −1 src/librustc/hir/upvars.rs
  11. +2 −2 src/librustc/middle/dead.rs
  12. +3 −3 src/librustc/middle/expr_use_visitor.rs
  13. +2 −2 src/librustc/middle/liveness.rs
  14. +3 −3 src/librustc/middle/mem_categorization.rs
  15. +2 −2 src/librustc/middle/region.rs
  16. +2 −2 src/librustc/traits/error_reporting.rs
  17. +1 −1 src/librustc_ast_borrowck/cfg/construct.rs
  18. +5 −5 src/librustc_lint/builtin.rs
  19. +2 −2 src/librustc_lint/nonstandard_style.rs
  20. +3 −3 src/librustc_lint/unused.rs
  21. +1 −1 src/librustc_metadata/encoder.rs
  22. +1 −1 src/librustc_mir/borrow_check/mutability_errors.rs
  23. +1 −1 src/librustc_mir/build/mod.rs
  24. +5 −5 src/librustc_mir/hair/pattern/check_match.rs
  25. +1 −1 src/librustc_mir/hair/pattern/mod.rs
  26. +1 −1 src/librustc_mir/interpret/validity.rs
  27. +2 −2 src/librustc_passes/ast_validation.rs
  28. +1 −1 src/librustc_privacy/lib.rs
  29. +1 −1 src/librustc_resolve/build_reduced_graph.rs
  30. +4 −4 src/librustc_resolve/late.rs
  31. +1 −1 src/librustc_save_analysis/dump_visitor.rs
  32. +5 −5 src/librustc_save_analysis/lib.rs
  33. +1 −1 src/librustc_typeck/check/generator_interior.rs
  34. +3 −3 src/librustc_typeck/check/mod.rs
  35. +7 −7 src/librustc_typeck/check/pat.rs
  36. +1 −1 src/librustc_typeck/check/regionck.rs
  37. +1 −1 src/librustc_typeck/check/writeback.rs
  38. +1 −1 src/librustdoc/clean/mod.rs
  39. +7 −7 src/libsyntax/ast.rs
  40. +1 −1 src/libsyntax/config.rs
  41. +2 −2 src/libsyntax/ext/base.rs
  42. +2 −2 src/libsyntax/ext/build.rs
  43. +2 −2 src/libsyntax/ext/expand.rs
  44. +3 −3 src/libsyntax/ext/placeholders.rs
  45. +2 −2 src/libsyntax/feature_gate/check.rs
  46. +2 −2 src/libsyntax/mut_visit.rs
  47. +7 −7 src/libsyntax/parse/diagnostics.rs
  48. +7 −7 src/libsyntax/parse/parser/pat.rs
  49. +1 −1 src/libsyntax/parse/tests.rs
  50. +2 −2 src/libsyntax/print/pprust.rs
  51. +1 −1 src/libsyntax/visit.rs
  52. +1 −1 src/test/ui-fulldeps/pprust-expr-roundtrip.rs
@@ -696,7 +696,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,

pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor.visit_id(pattern.hir_id);
match pattern.node {
match pattern.kind {
PatKind::TupleStruct(ref qpath, ref children, _) => {
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
walk_list!(visitor, visit_pat, children);
@@ -425,7 +425,7 @@ impl<'a> LoweringContext<'a> {

impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
fn visit_pat(&mut self, p: &'tcx Pat) {
if let PatKind::Paren(..) | PatKind::Rest = p.node {
if let PatKind::Paren(..) | PatKind::Rest = p.kind {
// Doesn't generate a HIR node
} else if let Some(owner) = self.hir_id_owner {
self.lctx.lower_node_id_with_owner(p.id, owner);
@@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> {
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> hir::HirVec<Ident> {
decl.inputs
.iter()
.map(|param| match param.pat.node {
.map(|param| match param.pat.kind {
PatKind::Ident(_, ident, _) => ident,
_ => Ident::new(kw::Invalid, param.pat.span),
})
@@ -2172,7 +2172,7 @@ impl<'a> LoweringContext<'a> {
implicit_self: decl.inputs.get(0).map_or(
hir::ImplicitSelfKind::None,
|arg| {
let is_mutable_pat = match arg.pat.node {
let is_mutable_pat = match arg.pat.kind {
PatKind::Ident(BindingMode::ByValue(mt), _, _) |
PatKind::Ident(BindingMode::ByRef(mt), _, _) =>
mt == Mutability::Mutable,
@@ -2688,7 +2688,7 @@ impl<'a> LoweringContext<'a> {
}

fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
let node = match p.node {
let node = match p.kind {
PatKind::Wild => hir::PatKind::Wild,
PatKind::Ident(ref binding_mode, ident, ref sub) => {
let lower_sub = |this: &mut Self| sub.as_ref().map(|x| this.lower_pat(x));
@@ -2805,7 +2805,7 @@ impl<'a> LoweringContext<'a> {
let mut iter = pats.iter();
while let Some(pat) = iter.next() {
// Interpret the first `((ref mut?)? x @)? ..` pattern as a subslice pattern.
match pat.node {
match pat.kind {
PatKind::Rest => {
prev_rest_span = Some(pat.span);
slice = Some(self.pat_wild_with_node_id_of(pat));
@@ -2827,7 +2827,7 @@ impl<'a> LoweringContext<'a> {

while let Some(pat) = iter.next() {
// There was a previous subslice pattern; make sure we don't allow more.
let rest_span = match pat.node {
let rest_span = match pat.kind {
PatKind::Rest => Some(pat.span),
PatKind::Ident(.., Some(ref sub)) if sub.is_rest() => {
// The `HirValidator` is merciless; add a `_` pattern to avoid ICEs.
@@ -2884,10 +2884,10 @@ impl<'a> LoweringContext<'a> {
}

/// Construct a `Pat` with the `HirId` of `p.id` lowered.
fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P<hir::Pat> {
P(hir::Pat {
hir_id: self.lower_node_id(p.id),
node,
kind,
span: p.span,
})
}
@@ -3112,7 +3112,7 @@ impl<'a> LoweringContext<'a> {
(
P(hir::Pat {
hir_id,
node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
span,
}),
hir_id
@@ -3123,10 +3123,10 @@ impl<'a> LoweringContext<'a> {
self.pat(span, hir::PatKind::Wild)
}

fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
fn pat(&mut self, span: Span, kind: hir::PatKind) -> P<hir::Pat> {
P(hir::Pat {
hir_id: self.next_id(),
node: pat,
kind,
span,
})
}
@@ -1133,7 +1133,7 @@ impl LoweringContext<'_> {

// Check if this is a binding pattern, if so, we can optimize and avoid adding a
// `let <pat> = __argN;` statement. In this case, we do not rename the parameter.
let (ident, is_simple_parameter) = match parameter.pat.node {
let (ident, is_simple_parameter) = match parameter.pat.kind {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _) =>
(ident, true),
_ => {
@@ -427,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
}

fn visit_pat(&mut self, pat: &'hir Pat) {
let node = if let PatKind::Binding(..) = pat.node {
let node = if let PatKind::Binding(..) = pat.kind {
Node::Binding(pat)
} else {
Node::Pat(pat)
@@ -257,7 +257,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}

fn visit_pat(&mut self, pat: &'a Pat) {
match pat.node {
match pat.kind {
PatKind::Mac(..) => return self.visit_macro_invoc(pat.id),
_ => visit::walk_pat(self, pat),
}
@@ -948,7 +948,7 @@ impl<'hir> Map<'hir> {
Node::Field(f) => f.ident.name,
Node::Lifetime(lt) => lt.name.ident().name,
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Ctor(..) => self.name(self.get_parent_item(id)),
_ => bug!("no name for {}", self.node_to_string(id))
}
@@ -869,7 +869,7 @@ pub struct Block {
pub struct Pat {
#[stable_hasher(ignore)]
pub hir_id: HirId,
pub node: PatKind,
pub kind: PatKind,
pub span: Span,
}

@@ -888,7 +888,7 @@ impl Pat {
}

use PatKind::*;
match &self.node {
match &self.kind {
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => true,
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it),
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
@@ -919,7 +919,7 @@ impl Pat {
}

use PatKind::*;
match &self.node {
match &self.kind {
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => {},
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it),
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
@@ -1295,7 +1295,7 @@ impl Arm {
// HACK(or_patterns; Centril | dlrobertson): Remove this and
// correctly handle each case in which this method is used.
pub fn top_pats_hack(&self) -> &[P<Pat>] {
match &self.pat.node {
match &self.pat.kind {
PatKind::Or(pats) => pats,
_ => std::slice::from_ref(&self.pat),
}
@@ -45,7 +45,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {

impl hir::Pat {
pub fn is_refutable(&self) -> bool {
match self.node {
match self.kind {
PatKind::Lit(_) |
PatKind::Range(..) |
PatKind::Path(hir::QPath::Resolved(Some(..), _)) |
@@ -68,7 +68,7 @@ impl hir::Pat {
/// `match foo() { Some(a) => (), None => () }`
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) {
self.walk(|p| {
if let PatKind::Binding(binding_mode, _, ident, _) = p.node {
if let PatKind::Binding(binding_mode, _, ident, _) = p.kind {
f(binding_mode, p.hir_id, p.span, ident);
}
true
@@ -83,7 +83,7 @@ impl hir::Pat {
&self,
f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident),
) {
self.walk(|p| match &p.node {
self.walk(|p| match &p.kind {
PatKind::Or(ps) => {
ps[0].each_binding_or_first(f);
false
@@ -99,7 +99,7 @@ impl hir::Pat {
/// Checks if the pattern contains any patterns that bind something to
/// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
pub fn contains_bindings(&self) -> bool {
self.satisfies(|p| match p.node {
self.satisfies(|p| match p.kind {
PatKind::Binding(..) => true,
_ => false,
})
@@ -108,7 +108,7 @@ impl hir::Pat {
/// Checks if the pattern contains any patterns that bind something to
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
pub fn contains_bindings_or_wild(&self) -> bool {
self.satisfies(|p| match p.node {
self.satisfies(|p| match p.kind {
PatKind::Binding(..) | PatKind::Wild => true,
_ => false,
})
@@ -129,7 +129,7 @@ impl hir::Pat {
}

pub fn simple_ident(&self) -> Option<ast::Ident> {
match self.node {
match self.kind {
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
_ => None,
@@ -139,7 +139,7 @@ impl hir::Pat {
/// Returns variants that are necessary to exist for the pattern to match.
pub fn necessary_variants(&self) -> Vec<DefId> {
let mut variants = vec![];
self.walk(|p| match &p.node {
self.walk(|p| match &p.kind {
PatKind::Or(_) => false,
PatKind::Path(hir::QPath::Resolved(_, path)) |
PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..) |
@@ -1617,7 +1617,7 @@ impl<'a> State<'a> {
self.ann.pre(self, AnnNode::Pat(pat));
// Pat isn't normalized, but the beauty of it
// is that it doesn't matter
match pat.node {
match pat.kind {
PatKind::Wild => self.s.word("_"),
PatKind::Binding(binding_mode, _, ident, ref sub) => {
match binding_mode {
@@ -1710,7 +1710,7 @@ impl<'a> State<'a> {
self.pclose();
}
PatKind::Box(ref inner) => {
let is_range_inner = match inner.node {
let is_range_inner = match inner.kind {
PatKind::Range(..) => true,
_ => false,
};
@@ -1724,7 +1724,7 @@ impl<'a> State<'a> {
}
}
PatKind::Ref(ref inner, mutbl) => {
let is_range_inner = match inner.node {
let is_range_inner = match inner.kind {
PatKind::Range(..) => true,
_ => false,
};
@@ -1757,7 +1757,7 @@ impl<'a> State<'a> {
if !before.is_empty() {
self.word_space(",");
}
if let PatKind::Wild = p.node {
if let PatKind::Wild = p.kind {
// Print nothing.
} else {
self.print_pat(&p);
@@ -47,7 +47,7 @@ impl Visitor<'tcx> for LocalCollector {
}

fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
if let hir::PatKind::Binding(_, hir_id, ..) = pat.node {
if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind {
self.locals.insert(hir_id);
}
intravisit::walk_pat(self, pat);
@@ -133,7 +133,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
};
for pat in pats {
if let PatKind::Wild = pat.pat.node {
if let PatKind::Wild = pat.pat.kind {
continue;
}
let index = self.tcx.field_index(pat.hir_id, self.tables);
@@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}

fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
match pat.node {
match pat.kind {
PatKind::Struct(ref path, ref fields, _) => {
let res = self.tables.qpath_res(path, pat.hir_id);
self.handle_field_pattern_match(pat, res, fields);
@@ -812,7 +812,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat);

return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
if let PatKind::Binding(..) = pat.node {
if let PatKind::Binding(..) = pat.kind {
let bm = *self.mc.tables.pat_binding_modes()
.get(pat.hir_id)
.expect("missing binding mode");
@@ -839,7 +839,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
let tcx = self.tcx();
let ExprUseVisitor { ref mc, ref mut delegate, param_env } = *self;
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |cmt_pat, pat| {
if let PatKind::Binding(_, canonical_id, ..) = pat.node {
if let PatKind::Binding(_, canonical_id, ..) = pat.kind {
debug!(
"walk_pat: binding cmt_pat={:?} pat={:?} match_mode={:?}",
cmt_pat,
@@ -885,7 +885,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
// to the above loop's visit of than the bindings that form
// the leaves of the pattern tree structure.
return_if_err!(mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
let qpath = match pat.node {
let qpath = match pat.kind {
PatKind::Path(ref qpath) |
PatKind::TupleStruct(ref qpath, ..) |
PatKind::Struct(ref qpath, ..) => qpath,
@@ -372,7 +372,7 @@ fn visit_fn<'tcx>(
let body = ir.tcx.hir().body(body_id);

for param in &body.params {
let is_shorthand = match param.pat.node {
let is_shorthand = match param.pat.kind {
crate::hir::PatKind::Struct(..) => true,
_ => false,
};
@@ -412,7 +412,7 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P<hir::Pat>) {
pats.push_back(pat);
while let Some(pat) = pats.pop_front() {
use crate::hir::PatKind::*;
match &pat.node {
match &pat.kind {
Binding(.., inner_pat) => {
pats.extend(inner_pat.iter());
}
@@ -271,7 +271,7 @@ impl MutabilityCategory {
id: hir::HirId,
) -> MutabilityCategory {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
Node::Binding(p) => match p.kind {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
.get(p.hir_id)
@@ -486,7 +486,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {

// This code detects whether we are looking at a `ref x`,
// and if so, figures out what the type *being borrowed* is.
let ret_ty = match pat.node {
let ret_ty = match pat.kind {
PatKind::Binding(..) => {
let bm = *self.tables
.pat_binding_modes()
@@ -1212,7 +1212,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
// that (where the `ref` on `x` is implied).
op(cmt.clone(), pat);

match pat.node {
match pat.kind {
PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => {
let res = self.tables.qpath_res(qpath, pat.hir_id);
let (cmt, expected_len) = match res {
@@ -850,7 +850,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });

// If this is a binding then record the lifetime of that binding.
if let PatKind::Binding(..) = pat.node {
if let PatKind::Binding(..) = pat.kind {
record_var_lifetime(visitor, pat.hir_id.local_id, pat.span);
}

@@ -1198,7 +1198,7 @@ fn resolve_local<'tcx>(
// In the former case (the implicit ref version), the temporary is created by the
// & expression, and its lifetime would be extended to the end of the block (due
// to a different rule, not the below code).
match pat.node {
match pat.kind {
PatKind::Binding(hir::BindingAnnotation::Ref, ..) |
PatKind::Binding(hir::BindingAnnotation::RefMut, ..) => true,

0 comments on commit 8bd0382

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