@@ -484,9 +484,9 @@ fn highlight_element(
484
484
match name_kind {
485
485
Some ( NameClass :: ExternCrate ( _) ) => HighlightTag :: Module . into ( ) ,
486
486
Some ( NameClass :: Definition ( def) ) => {
487
- highlight_def ( sema, db, def, None , false ) | HighlightModifier :: Definition
487
+ highlight_def ( sema, db, def, None ) | HighlightModifier :: Definition
488
488
}
489
- Some ( NameClass :: ConstReference ( def) ) => highlight_def ( sema, db, def, None , false ) ,
489
+ Some ( NameClass :: ConstReference ( def) ) => highlight_def ( sema, db, def, None ) ,
490
490
Some ( NameClass :: FieldShorthand { field, .. } ) => {
491
491
let mut h = HighlightTag :: Field . into ( ) ;
492
492
if let Definition :: Field ( field) = field {
@@ -519,13 +519,20 @@ fn highlight_element(
519
519
binding_hash = Some ( calc_binding_hash ( & name, * shadow_count) )
520
520
}
521
521
} ;
522
- let possibly_unsafe = match name_ref. syntax ( ) . parent ( ) {
523
- Some ( parent) => {
524
- matches ! ( parent. kind( ) , FIELD_EXPR | RECORD_PAT_FIELD )
522
+
523
+ let mut h = highlight_def ( sema, db, def, Some ( name_ref. clone ( ) ) ) ;
524
+
525
+ if let Some ( parent) = name_ref. syntax ( ) . parent ( ) {
526
+ if matches ! ( parent. kind( ) , FIELD_EXPR | RECORD_PAT_FIELD ) {
527
+ if let Definition :: Field ( field) = def {
528
+ if let VariantDef :: Union ( _) = field. parent_def ( db) {
529
+ h |= HighlightModifier :: Unsafe ;
530
+ }
531
+ }
525
532
}
526
- None => false ,
527
- } ;
528
- highlight_def ( sema , db , def , Some ( name_ref ) , possibly_unsafe )
533
+ }
534
+
535
+ h
529
536
}
530
537
NameRefClass :: FieldShorthand { .. } => HighlightTag :: Field . into ( ) ,
531
538
} ,
@@ -734,20 +741,10 @@ fn highlight_def(
734
741
db : & RootDatabase ,
735
742
def : Definition ,
736
743
name_ref : Option < ast:: NameRef > ,
737
- possibly_unsafe : bool ,
738
744
) -> Highlight {
739
745
match def {
740
746
Definition :: Macro ( _) => HighlightTag :: Macro ,
741
- Definition :: Field ( field) => {
742
- let mut h = HighlightTag :: Field . into ( ) ;
743
- if possibly_unsafe {
744
- if let VariantDef :: Union ( _) = field. parent_def ( db) {
745
- h |= HighlightModifier :: Unsafe ;
746
- }
747
- }
748
-
749
- return h;
750
- }
747
+ Definition :: Field ( _) => HighlightTag :: Field ,
751
748
Definition :: ModuleDef ( def) => match def {
752
749
hir:: ModuleDef :: Module ( _) => HighlightTag :: Module ,
753
750
hir:: ModuleDef :: Function ( func) => {
0 commit comments