Skip to content

Commit

Permalink
Store a Symbol instead of an Ident in VariantDef/FieldDef
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
Aaron1011 committed Jan 11, 2022
1 parent c8ea042 commit dda2aef
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/default.rs
Expand Up @@ -198,7 +198,7 @@ impl LateLintPass<'_> for Default {
let ext_with_default = !variant
.fields
.iter()
.all(|field| assigned_fields.iter().any(|(a, _)| a == &field.ident.name));
.all(|field| assigned_fields.iter().any(|(a, _)| a == &field.name));

let field_list = assigned_fields
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_numeric_fallback.rs
Expand Up @@ -161,7 +161,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
fields_def
.iter()
.find_map(|f_def| {
if f_def.ident == field.ident
if f_def.ident(self.cx.tcx) == field.ident
{ Some(self.cx.tcx.type_of(f_def.did)) }
else { None }
});
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inconsistent_struct_constructor.rs
Expand Up @@ -76,7 +76,7 @@ impl LateLintPass<'_> for InconsistentStructConstructor {
then {
let mut def_order_map = FxHashMap::default();
for (idx, field) in variant.fields.iter().enumerate() {
def_order_map.insert(field.ident.name, idx);
def_order_map.insert(field.name, idx);
}

if is_consistent_order(fields, &def_order_map) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches.rs
Expand Up @@ -1136,7 +1136,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
s.push_str("::");
s
},
variant.ident.name,
variant.name,
match variant.ctor_kind {
CtorKind::Fn if variant.fields.len() == 1 => "(_)",
CtorKind::Fn => "(..)",
Expand Down

0 comments on commit dda2aef

Please sign in to comment.