Skip to content

Commit a618271

Browse files
committed
Remove Spanned from {ast,hir}::FieldPat
1 parent 433b1e3 commit a618271

File tree

24 files changed

+72
-92
lines changed

24 files changed

+72
-92
lines changed

src/librustc/cfg/construct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
136136
}
137137

138138
PatKind::Struct(_, ref subpats, _) => {
139-
let pats_exit = self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
139+
let pats_exit = self.pats_all(subpats.iter().map(|f| &f.pat), pred);
140140
self.add_ast_node(pat.hir_id.local_id, &[pats_exit])
141141
}
142142

src/librustc/hir/intravisit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
704704
PatKind::Struct(ref qpath, ref fields, _) => {
705705
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
706706
for field in fields {
707-
visitor.visit_id(field.node.hir_id);
708-
visitor.visit_ident(field.node.ident);
709-
visitor.visit_pat(&field.node.pat)
707+
visitor.visit_id(field.hir_id);
708+
visitor.visit_ident(field.ident);
709+
visitor.visit_pat(&field.pat)
710710
}
711711
}
712712
PatKind::Tuple(ref tuple_elements, _) => {

src/librustc/hir/lowering.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,16 +2691,12 @@ impl<'a> LoweringContext<'a> {
26912691

26922692
let fs = fields
26932693
.iter()
2694-
.map(|f| {
2695-
Spanned {
2696-
span: f.span,
2697-
node: hir::FieldPat {
2698-
hir_id: self.next_id(),
2699-
ident: f.node.ident,
2700-
pat: self.lower_pat(&f.node.pat),
2701-
is_shorthand: f.node.is_shorthand,
2702-
},
2703-
}
2694+
.map(|f| hir::FieldPat {
2695+
hir_id: self.next_id(),
2696+
ident: f.ident,
2697+
pat: self.lower_pat(&f.pat),
2698+
is_shorthand: f.is_shorthand,
2699+
span: f.span,
27042700
})
27052701
.collect();
27062702
hir::PatKind::Struct(qpath, fs, etc)

src/librustc/hir/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ impl Pat {
877877
match self.node {
878878
PatKind::Binding(.., Some(ref p)) => p.walk_(it),
879879
PatKind::Struct(_, ref fields, _) => {
880-
fields.iter().all(|field| field.node.pat.walk_(it))
880+
fields.iter().all(|field| field.pat.walk_(it))
881881
}
882882
PatKind::TupleStruct(_, ref s, _) | PatKind::Tuple(ref s, _) => {
883883
s.iter().all(|p| p.walk_(it))
@@ -923,6 +923,7 @@ pub struct FieldPat {
923923
/// The pattern the field is destructured to.
924924
pub pat: P<Pat>,
925925
pub is_shorthand: bool,
926+
pub span: Span,
926927
}
927928

928929
/// Explicit binding annotations given in the HIR for a binding. Note
@@ -968,7 +969,7 @@ pub enum PatKind {
968969

969970
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
970971
/// The `bool` is `true` in the presence of a `..`.
971-
Struct(QPath, HirVec<Spanned<FieldPat>>, bool),
972+
Struct(QPath, HirVec<FieldPat>, bool),
972973

973974
/// A tuple struct/variant pattern `Variant(x, y, .., z)`.
974975
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.

src/librustc/hir/print.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,14 +1670,14 @@ impl<'a> State<'a> {
16701670
&fields[..],
16711671
|s, f| {
16721672
s.cbox(INDENT_UNIT);
1673-
if !f.node.is_shorthand {
1674-
s.print_ident(f.node.ident);
1673+
if !f.is_shorthand {
1674+
s.print_ident(f.ident);
16751675
s.word_nbsp(":");
16761676
}
1677-
s.print_pat(&f.node.pat);
1677+
s.print_pat(&f.pat);
16781678
s.end()
16791679
},
1680-
|f| f.node.pat.span);
1680+
|f| f.pat.span);
16811681
if etc {
16821682
if !fields.is_empty() {
16831683
self.word_space(",");

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
153153
}
154154
}
155155

156-
impl_stable_hash_for_spanned!(hir::FieldPat);
157-
158156
impl_stable_hash_for_spanned!(hir::BinOpKind);
159157

160158
impl_stable_hash_for!(struct hir::Stmt {
@@ -187,8 +185,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
187185

188186
impl_stable_hash_for_spanned!(usize);
189187

190-
impl_stable_hash_for_spanned!(ast::Ident);
191-
192188
impl_stable_hash_for!(struct ast::Ident {
193189
name,
194190
span,

src/librustc/middle/dead.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ use crate::util::nodemap::FxHashSet;
1717

1818
use rustc_data_structures::fx::FxHashMap;
1919

20-
use syntax::{ast, source_map};
21-
use syntax::attr;
20+
use syntax::{ast, attr};
2221
use syntax::symbol::sym;
2322
use syntax_pos;
2423

@@ -119,17 +118,16 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
119118
}
120119
}
121120

122-
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, res: Res,
123-
pats: &[source_map::Spanned<hir::FieldPat>]) {
121+
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, res: Res, pats: &[hir::FieldPat]) {
124122
let variant = match self.tables.node_type(lhs.hir_id).sty {
125123
ty::Adt(adt, _) => adt.variant_of_res(res),
126124
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
127125
};
128126
for pat in pats {
129-
if let PatKind::Wild = pat.node.pat.node {
127+
if let PatKind::Wild = pat.pat.node {
130128
continue;
131129
}
132-
let index = self.tcx.field_index(pat.node.hir_id, self.tables);
130+
let index = self.tcx.field_index(pat.hir_id, self.tables);
133131
self.insert_def_id(variant.fields[index].did);
134132
}
135133
}

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
418418
}
419419
Struct(_, ref fields, _) => {
420420
for field in fields {
421-
if field.node.is_shorthand {
422-
shorthand_field_ids.insert(field.node.pat.hir_id);
421+
if field.is_shorthand {
422+
shorthand_field_ids.insert(field.pat.hir_id);
423423
}
424424
}
425425
}

src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,11 +1282,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
12821282
};
12831283

12841284
for fp in field_pats {
1285-
let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
1286-
let f_index = self.tcx.field_index(fp.node.hir_id, self.tables);
1285+
let field_ty = self.pat_ty_adjusted(&fp.pat)?; // see (*2)
1286+
let f_index = self.tcx.field_index(fp.hir_id, self.tables);
12871287
let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
1288-
fp.node.ident, field_ty));
1289-
self.cat_pattern_(cmt_field, &fp.node.pat, op)?;
1288+
fp.ident, field_ty));
1289+
self.cat_pattern_(cmt_field, &fp.pat, op)?;
12901290
}
12911291
}
12921292

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ fn resolve_local<'tcx>(
12071207
PatKind::Binding(hir::BindingAnnotation::RefMut, ..) => true,
12081208

12091209
PatKind::Struct(_, ref field_pats, _) => {
1210-
field_pats.iter().any(|fp| is_binding_pat(&fp.node.pat))
1210+
field_pats.iter().any(|fp| is_binding_pat(&fp.pat))
12111211
}
12121212

12131213
PatKind::Slice(ref pats1, ref pats2, ref pats3) => {

0 commit comments

Comments
 (0)