Skip to content

Commit 1fcff64

Browse files
committed
Remove span from hir::FieldPat.
1 parent 4f527e9 commit 1fcff64

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
11221122
ident: f.ident,
11231123
pat,
11241124
is_shorthand: f.is_shorthand,
1125-
span: f.span,
11261125
}
11271126
}));
11281127
let qpath = self.lower_qpath(

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
26272627
ident: Ident::new(sym::integer(0), span),
26282628
is_shorthand: false,
26292629
pat,
2630-
span,
26312630
};
26322631
arena_vec![self; field]
26332632
}

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6161
ident: f.ident,
6262
pat: self.lower_pat(&f.pat),
6363
is_shorthand: f.is_shorthand,
64-
span: f.span,
6564
}));
6665
break hir::PatKind::Struct(qpath, fs, etc);
6766
}

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ pub struct FieldPat<'hir> {
884884
/// The pattern the field is destructured to.
885885
pub pat: &'hir Pat<'hir>,
886886
pub is_shorthand: bool,
887-
pub span: Span,
888887
}
889888

890889
/// Explicit binding annotations given in the HIR for a binding. Note

compiler/rustc_lint/src/builtin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
248248
if fieldpat.is_shorthand {
249249
continue;
250250
}
251-
if fieldpat.span.from_expansion() {
251+
let fieldpat_span = cx.tcx.hir().span(fieldpat.hir_id);
252+
if fieldpat_span.from_expansion() {
252253
// Don't lint if this is a macro expansion: macro authors
253254
// shouldn't have to worry about this kind of style issue
254255
// (Issue #49588)
@@ -258,7 +259,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
258259
if cx.tcx.find_field_index(ident, &variant)
259260
== Some(cx.tcx.field_index(fieldpat.hir_id, cx.typeck_results()))
260261
{
261-
cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, |lint| {
262+
cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat_span, |lint| {
262263
let mut err = lint
263264
.build(&format!("the `{}:` in this pattern is redundant", ident));
264265
let binding = match binding_annot {
@@ -273,7 +274,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
273274
ident.to_string()
274275
};
275276
err.span_suggestion(
276-
fieldpat.span,
277+
fieldpat_span,
277278
"use shorthand field pattern",
278279
ident,
279280
Applicability::MachineApplicable,

compiler/rustc_privacy/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,8 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
11011101
for field in fields {
11021102
let use_ctxt = field.ident.span;
11031103
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
1104-
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
1104+
let field_span = self.tcx.hir().span(field.hir_id);
1105+
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
11051106
}
11061107
}
11071108

compiler/rustc_typeck/src/check/pat.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11791179
let mut inexistent_fields = vec![];
11801180
// Typecheck each field.
11811181
for field in fields {
1182-
let span = field.span;
1182+
let span = tcx.hir().span(field.hir_id);
11831183
let ident = tcx.adjust_ident(field.ident, variant.def_id);
11841184
let field_ty = match used_fields.entry(ident) {
11851185
Occupied(occupied) => {
@@ -1537,8 +1537,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15371537
.struct_span_err(pat.span, "pattern requires `..` due to inaccessible fields");
15381538

15391539
if let Some(field) = fields.last() {
1540+
let field_span = self.tcx.hir().span(field.hir_id);
15401541
err.span_suggestion_verbose(
1541-
field.span.shrink_to_hi(),
1542+
field_span.shrink_to_hi(),
15421543
"ignore the inaccessible and unused fields",
15431544
", ..".to_string(),
15441545
Applicability::MachineApplicable,
@@ -1606,7 +1607,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16061607
[.., field] => {
16071608
// Account for last field having a trailing comma or parse recovery at the tail of
16081609
// the pattern to avoid invalid suggestion (#78511).
1609-
let tail = field.span.shrink_to_hi().with_hi(pat.span.hi());
1610+
let field_span = self.tcx.hir().span(field.hir_id);
1611+
let pat_span = self.tcx.hir().span(pat.hir_id);
1612+
let tail = field_span.shrink_to_hi().with_hi(pat_span.hi());
16101613
match &pat.kind {
16111614
PatKind::Struct(..) => (", ", " }", tail),
16121615
_ => return err,

0 commit comments

Comments
 (0)