Skip to content

Commit 0373228

Browse files
committed
Remove span from hir::FieldPat.
1 parent 521bc45 commit 0373228

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
10121012
ident: f.ident,
10131013
pat,
10141014
is_shorthand: f.is_shorthand,
1015-
span: f.span,
10161015
}
10171016
}));
10181017
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
@@ -2555,7 +2555,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25552555
ident: Ident::new(sym::integer(0), span),
25562556
is_shorthand: false,
25572557
pat,
2558-
span,
25592558
};
25602559
arena_vec![self; field]
25612560
}

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
@@ -843,7 +843,6 @@ pub struct FieldPat<'hir> {
843843
/// The pattern the field is destructured to.
844844
pub pat: &'hir Pat<'hir>,
845845
pub is_shorthand: bool,
846-
pub span: Span,
847846
}
848847

849848
/// 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
@@ -242,7 +242,8 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
242242
if fieldpat.is_shorthand {
243243
continue;
244244
}
245-
if fieldpat.span.from_expansion() {
245+
let fieldpat_span = cx.tcx.hir().span(fieldpat.hir_id);
246+
if fieldpat_span.from_expansion() {
246247
// Don't lint if this is a macro expansion: macro authors
247248
// shouldn't have to worry about this kind of style issue
248249
// (Issue #49588)
@@ -252,7 +253,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
252253
if cx.tcx.find_field_index(ident, &variant)
253254
== Some(cx.tcx.field_index(fieldpat.hir_id, cx.typeck_results()))
254255
{
255-
cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, |lint| {
256+
cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat_span, |lint| {
256257
let mut err = lint
257258
.build(&format!("the `{}:` in this pattern is redundant", ident));
258259
let binding = match binding_annot {
@@ -267,7 +268,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
267268
ident.to_string()
268269
};
269270
err.span_suggestion(
270-
fieldpat.span,
271+
fieldpat_span,
271272
"use shorthand field pattern",
272273
ident,
273274
Applicability::MachineApplicable,

compiler/rustc_privacy/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,8 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
10491049
for field in fields {
10501050
let use_ctxt = field.ident.span;
10511051
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
1052-
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
1052+
let field_span = self.tcx.hir().span(field.hir_id);
1053+
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
10531054
}
10541055
}
10551056

compiler/rustc_typeck/src/check/pat.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11231123
let mut inexistent_fields = vec![];
11241124
// Typecheck each field.
11251125
for field in fields {
1126-
let span = field.span;
1126+
let span = tcx.hir().span(field.hir_id);
11271127
let ident = tcx.adjust_ident(field.ident, variant.def_id);
11281128
let field_ty = match used_fields.entry(ident) {
11291129
Occupied(occupied) => {
@@ -1412,8 +1412,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14121412
.struct_span_err(pat.span, "pattern requires `..` due to inaccessible fields");
14131413

14141414
if let Some(field) = fields.last() {
1415+
let field_span = self.tcx.hir().span(field.hir_id);
14151416
err.span_suggestion_verbose(
1416-
field.span.shrink_to_hi(),
1417+
field_span.shrink_to_hi(),
14171418
"ignore the inaccessible and unused fields",
14181419
", ..".to_string(),
14191420
Applicability::MachineApplicable,
@@ -1478,14 +1479,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14781479
}
14791480
_ => return err,
14801481
},
1481-
[.., field] => (
1482-
match pat.kind {
1482+
[.., field] => {
1483+
let field_span = self.tcx.hir().span(field.hir_id);
1484+
let prefix = match pat.kind {
14831485
PatKind::Struct(_, [_, ..], _) => ", ",
14841486
_ => "",
1485-
},
1486-
"",
1487-
field.span.shrink_to_hi(),
1488-
),
1487+
};
1488+
(prefix, "", field_span.shrink_to_hi())
1489+
}
14891490
};
14901491
err.span_suggestion(
14911492
sp,

0 commit comments

Comments
 (0)