Skip to content

Commit 8bd0382

Browse files
committed
Rename Pat.node to Pat.kind
1 parent 95f6d72 commit 8bd0382

File tree

52 files changed

+135
-135
lines changed

Some content is hidden

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

52 files changed

+135
-135
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
696696

697697
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
698698
visitor.visit_id(pattern.hir_id);
699-
match pattern.node {
699+
match pattern.kind {
700700
PatKind::TupleStruct(ref qpath, ref children, _) => {
701701
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
702702
walk_list!(visitor, visit_pat, children);

src/librustc/hir/lowering.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'a> LoweringContext<'a> {
425425

426426
impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
427427
fn visit_pat(&mut self, p: &'tcx Pat) {
428-
if let PatKind::Paren(..) | PatKind::Rest = p.node {
428+
if let PatKind::Paren(..) | PatKind::Rest = p.kind {
429429
// Doesn't generate a HIR node
430430
} else if let Some(owner) = self.hir_id_owner {
431431
self.lctx.lower_node_id_with_owner(p.id, owner);
@@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> {
20952095
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> hir::HirVec<Ident> {
20962096
decl.inputs
20972097
.iter()
2098-
.map(|param| match param.pat.node {
2098+
.map(|param| match param.pat.kind {
20992099
PatKind::Ident(_, ident, _) => ident,
21002100
_ => Ident::new(kw::Invalid, param.pat.span),
21012101
})
@@ -2172,7 +2172,7 @@ impl<'a> LoweringContext<'a> {
21722172
implicit_self: decl.inputs.get(0).map_or(
21732173
hir::ImplicitSelfKind::None,
21742174
|arg| {
2175-
let is_mutable_pat = match arg.pat.node {
2175+
let is_mutable_pat = match arg.pat.kind {
21762176
PatKind::Ident(BindingMode::ByValue(mt), _, _) |
21772177
PatKind::Ident(BindingMode::ByRef(mt), _, _) =>
21782178
mt == Mutability::Mutable,
@@ -2688,7 +2688,7 @@ impl<'a> LoweringContext<'a> {
26882688
}
26892689

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

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

28862886
/// Construct a `Pat` with the `HirId` of `p.id` lowered.
2887-
fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
2887+
fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P<hir::Pat> {
28882888
P(hir::Pat {
28892889
hir_id: self.lower_node_id(p.id),
2890-
node,
2890+
kind,
28912891
span: p.span,
28922892
})
28932893
}
@@ -3112,7 +3112,7 @@ impl<'a> LoweringContext<'a> {
31123112
(
31133113
P(hir::Pat {
31143114
hir_id,
3115-
node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
3115+
kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
31163116
span,
31173117
}),
31183118
hir_id
@@ -3123,10 +3123,10 @@ impl<'a> LoweringContext<'a> {
31233123
self.pat(span, hir::PatKind::Wild)
31243124
}
31253125

3126-
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
3126+
fn pat(&mut self, span: Span, kind: hir::PatKind) -> P<hir::Pat> {
31273127
P(hir::Pat {
31283128
hir_id: self.next_id(),
3129-
node: pat,
3129+
kind,
31303130
span,
31313131
})
31323132
}

src/librustc/hir/lowering/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ impl LoweringContext<'_> {
11331133

11341134
// Check if this is a binding pattern, if so, we can optimize and avoid adding a
11351135
// `let <pat> = __argN;` statement. In this case, we do not rename the parameter.
1136-
let (ident, is_simple_parameter) = match parameter.pat.node {
1136+
let (ident, is_simple_parameter) = match parameter.pat.kind {
11371137
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _) =>
11381138
(ident, true),
11391139
_ => {

src/librustc/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
427427
}
428428

429429
fn visit_pat(&mut self, pat: &'hir Pat) {
430-
let node = if let PatKind::Binding(..) = pat.node {
430+
let node = if let PatKind::Binding(..) = pat.kind {
431431
Node::Binding(pat)
432432
} else {
433433
Node::Pat(pat)

src/librustc/hir/map/def_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
257257
}
258258

259259
fn visit_pat(&mut self, pat: &'a Pat) {
260-
match pat.node {
260+
match pat.kind {
261261
PatKind::Mac(..) => return self.visit_macro_invoc(pat.id),
262262
_ => visit::walk_pat(self, pat),
263263
}

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ impl<'hir> Map<'hir> {
948948
Node::Field(f) => f.ident.name,
949949
Node::Lifetime(lt) => lt.name.ident().name,
950950
Node::GenericParam(param) => param.name.ident().name,
951-
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
951+
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
952952
Node::Ctor(..) => self.name(self.get_parent_item(id)),
953953
_ => bug!("no name for {}", self.node_to_string(id))
954954
}

src/librustc/hir/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ pub struct Block {
869869
pub struct Pat {
870870
#[stable_hasher(ignore)]
871871
pub hir_id: HirId,
872-
pub node: PatKind,
872+
pub kind: PatKind,
873873
pub span: Span,
874874
}
875875

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

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

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

src/librustc/hir/pat_util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
4545

4646
impl hir::Pat {
4747
pub fn is_refutable(&self) -> bool {
48-
match self.node {
48+
match self.kind {
4949
PatKind::Lit(_) |
5050
PatKind::Range(..) |
5151
PatKind::Path(hir::QPath::Resolved(Some(..), _)) |
@@ -68,7 +68,7 @@ impl hir::Pat {
6868
/// `match foo() { Some(a) => (), None => () }`
6969
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) {
7070
self.walk(|p| {
71-
if let PatKind::Binding(binding_mode, _, ident, _) = p.node {
71+
if let PatKind::Binding(binding_mode, _, ident, _) = p.kind {
7272
f(binding_mode, p.hir_id, p.span, ident);
7373
}
7474
true
@@ -83,7 +83,7 @@ impl hir::Pat {
8383
&self,
8484
f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident),
8585
) {
86-
self.walk(|p| match &p.node {
86+
self.walk(|p| match &p.kind {
8787
PatKind::Or(ps) => {
8888
ps[0].each_binding_or_first(f);
8989
false
@@ -99,7 +99,7 @@ impl hir::Pat {
9999
/// Checks if the pattern contains any patterns that bind something to
100100
/// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
101101
pub fn contains_bindings(&self) -> bool {
102-
self.satisfies(|p| match p.node {
102+
self.satisfies(|p| match p.kind {
103103
PatKind::Binding(..) => true,
104104
_ => false,
105105
})
@@ -108,7 +108,7 @@ impl hir::Pat {
108108
/// Checks if the pattern contains any patterns that bind something to
109109
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
110110
pub fn contains_bindings_or_wild(&self) -> bool {
111-
self.satisfies(|p| match p.node {
111+
self.satisfies(|p| match p.kind {
112112
PatKind::Binding(..) | PatKind::Wild => true,
113113
_ => false,
114114
})
@@ -129,7 +129,7 @@ impl hir::Pat {
129129
}
130130

131131
pub fn simple_ident(&self) -> Option<ast::Ident> {
132-
match self.node {
132+
match self.kind {
133133
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
134134
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
135135
_ => None,
@@ -139,7 +139,7 @@ impl hir::Pat {
139139
/// Returns variants that are necessary to exist for the pattern to match.
140140
pub fn necessary_variants(&self) -> Vec<DefId> {
141141
let mut variants = vec![];
142-
self.walk(|p| match &p.node {
142+
self.walk(|p| match &p.kind {
143143
PatKind::Or(_) => false,
144144
PatKind::Path(hir::QPath::Resolved(_, path)) |
145145
PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..) |

src/librustc/hir/print.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ impl<'a> State<'a> {
16171617
self.ann.pre(self, AnnNode::Pat(pat));
16181618
// Pat isn't normalized, but the beauty of it
16191619
// is that it doesn't matter
1620-
match pat.node {
1620+
match pat.kind {
16211621
PatKind::Wild => self.s.word("_"),
16221622
PatKind::Binding(binding_mode, _, ident, ref sub) => {
16231623
match binding_mode {
@@ -1710,7 +1710,7 @@ impl<'a> State<'a> {
17101710
self.pclose();
17111711
}
17121712
PatKind::Box(ref inner) => {
1713-
let is_range_inner = match inner.node {
1713+
let is_range_inner = match inner.kind {
17141714
PatKind::Range(..) => true,
17151715
_ => false,
17161716
};
@@ -1724,7 +1724,7 @@ impl<'a> State<'a> {
17241724
}
17251725
}
17261726
PatKind::Ref(ref inner, mutbl) => {
1727-
let is_range_inner = match inner.node {
1727+
let is_range_inner = match inner.kind {
17281728
PatKind::Range(..) => true,
17291729
_ => false,
17301730
};
@@ -1757,7 +1757,7 @@ impl<'a> State<'a> {
17571757
if !before.is_empty() {
17581758
self.word_space(",");
17591759
}
1760-
if let PatKind::Wild = p.node {
1760+
if let PatKind::Wild = p.kind {
17611761
// Print nothing.
17621762
} else {
17631763
self.print_pat(&p);

src/librustc/hir/upvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Visitor<'tcx> for LocalCollector {
4747
}
4848

4949
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
50-
if let hir::PatKind::Binding(_, hir_id, ..) = pat.node {
50+
if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind {
5151
self.locals.insert(hir_id);
5252
}
5353
intravisit::walk_pat(self, pat);

src/librustc/middle/dead.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
133133
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
134134
};
135135
for pat in pats {
136-
if let PatKind::Wild = pat.pat.node {
136+
if let PatKind::Wild = pat.pat.kind {
137137
continue;
138138
}
139139
let index = self.tcx.field_index(pat.hir_id, self.tables);
@@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
269269
}
270270

271271
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
272-
match pat.node {
272+
match pat.kind {
273273
PatKind::Struct(ref path, ref fields, _) => {
274274
let res = self.tables.qpath_res(path, pat.hir_id);
275275
self.handle_field_pattern_match(pat, res, fields);

src/librustc/middle/expr_use_visitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
812812
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat);
813813

814814
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
815-
if let PatKind::Binding(..) = pat.node {
815+
if let PatKind::Binding(..) = pat.kind {
816816
let bm = *self.mc.tables.pat_binding_modes()
817817
.get(pat.hir_id)
818818
.expect("missing binding mode");
@@ -839,7 +839,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
839839
let tcx = self.tcx();
840840
let ExprUseVisitor { ref mc, ref mut delegate, param_env } = *self;
841841
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |cmt_pat, pat| {
842-
if let PatKind::Binding(_, canonical_id, ..) = pat.node {
842+
if let PatKind::Binding(_, canonical_id, ..) = pat.kind {
843843
debug!(
844844
"walk_pat: binding cmt_pat={:?} pat={:?} match_mode={:?}",
845845
cmt_pat,
@@ -885,7 +885,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
885885
// to the above loop's visit of than the bindings that form
886886
// the leaves of the pattern tree structure.
887887
return_if_err!(mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
888-
let qpath = match pat.node {
888+
let qpath = match pat.kind {
889889
PatKind::Path(ref qpath) |
890890
PatKind::TupleStruct(ref qpath, ..) |
891891
PatKind::Struct(ref qpath, ..) => qpath,

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ fn visit_fn<'tcx>(
372372
let body = ir.tcx.hir().body(body_id);
373373

374374
for param in &body.params {
375-
let is_shorthand = match param.pat.node {
375+
let is_shorthand = match param.pat.kind {
376376
crate::hir::PatKind::Struct(..) => true,
377377
_ => false,
378378
};
@@ -412,7 +412,7 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P<hir::Pat>) {
412412
pats.push_back(pat);
413413
while let Some(pat) = pats.pop_front() {
414414
use crate::hir::PatKind::*;
415-
match &pat.node {
415+
match &pat.kind {
416416
Binding(.., inner_pat) => {
417417
pats.extend(inner_pat.iter());
418418
}

src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl MutabilityCategory {
271271
id: hir::HirId,
272272
) -> MutabilityCategory {
273273
let ret = match tcx.hir().get(id) {
274-
Node::Binding(p) => match p.node {
274+
Node::Binding(p) => match p.kind {
275275
PatKind::Binding(..) => {
276276
let bm = *tables.pat_binding_modes()
277277
.get(p.hir_id)
@@ -486,7 +486,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
486486

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

1215-
match pat.node {
1215+
match pat.kind {
12161216
PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => {
12171217
let res = self.tables.qpath_res(qpath, pat.hir_id);
12181218
let (cmt, expected_len) = match res {

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
850850
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });
851851

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

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

0 commit comments

Comments
 (0)