Skip to content

Commit dda2aef

Browse files
committed
Store a Symbol instead of an Ident in VariantDef/FieldDef
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
1 parent c8ea042 commit dda2aef

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

clippy_lints/src/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl LateLintPass<'_> for Default {
198198
let ext_with_default = !variant
199199
.fields
200200
.iter()
201-
.all(|field| assigned_fields.iter().any(|(a, _)| a == &field.ident.name));
201+
.all(|field| assigned_fields.iter().any(|(a, _)| a == &field.name));
202202

203203
let field_list = assigned_fields
204204
.into_iter()

clippy_lints/src/default_numeric_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
161161
fields_def
162162
.iter()
163163
.find_map(|f_def| {
164-
if f_def.ident == field.ident
164+
if f_def.ident(self.cx.tcx) == field.ident
165165
{ Some(self.cx.tcx.type_of(f_def.did)) }
166166
else { None }
167167
});

clippy_lints/src/inconsistent_struct_constructor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl LateLintPass<'_> for InconsistentStructConstructor {
7676
then {
7777
let mut def_order_map = FxHashMap::default();
7878
for (idx, field) in variant.fields.iter().enumerate() {
79-
def_order_map.insert(field.ident.name, idx);
79+
def_order_map.insert(field.name, idx);
8080
}
8181

8282
if is_consistent_order(fields, &def_order_map) {

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
11361136
s.push_str("::");
11371137
s
11381138
},
1139-
variant.ident.name,
1139+
variant.name,
11401140
match variant.ctor_kind {
11411141
CtorKind::Fn if variant.fields.len() == 1 => "(_)",
11421142
CtorKind::Fn => "(..)",

0 commit comments

Comments
 (0)