Explicitly check for reference locals or fields in Name classification

This commit is contained in:
Lukas Wirth 2021-07-11 14:03:35 +02:00
parent 87621de2b9
commit c65bb7f8b9
11 changed files with 67 additions and 50 deletions

View file

@ -58,10 +58,8 @@ pub(super) fn element(
Some(NameClass::ConstReference(def)) => highlight_def(db, krate, def),
Some(NameClass::PatFieldShorthand { field_ref, .. }) => {
let mut h = HlTag::Symbol(SymbolKind::Field).into();
if let Definition::Field(field) = field_ref {
if let hir::VariantDef::Union(_) = field.parent_def(db) {
h |= HlMod::Unsafe;
}
if let hir::VariantDef::Union(_) = field_ref.parent_def(db) {
h |= HlMod::Unsafe;
}
h
}