@@ -650,7 +650,8 @@ struct InlayHintLabelBuilder<'a> {
650
650
db : & ' a RootDatabase ,
651
651
result : InlayHintLabel ,
652
652
last_part : String ,
653
- location : Option < FileRange > ,
653
+ resolve : bool ,
654
+ location : Option < LazyProperty < FileRange > > ,
654
655
}
655
656
656
657
impl fmt:: Write for InlayHintLabelBuilder < ' _ > {
@@ -663,11 +664,16 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
663
664
fn start_location_link ( & mut self , def : ModuleDefId ) {
664
665
never ! ( self . location. is_some( ) , "location link is already started" ) ;
665
666
self . make_new_part ( ) ;
666
- let Some ( location) = ModuleDef :: from ( def) . try_to_nav ( self . db ) else { return } ;
667
- let location = location. call_site ( ) ;
668
- let location =
669
- FileRange { file_id : location. file_id , range : location. focus_or_full_range ( ) } ;
670
- self . location = Some ( location) ;
667
+
668
+ self . location = Some ( if self . resolve {
669
+ LazyProperty :: Lazy
670
+ } else {
671
+ LazyProperty :: Computed ( {
672
+ let Some ( location) = ModuleDef :: from ( def) . try_to_nav ( self . db ) else { return } ;
673
+ let location = location. call_site ( ) ;
674
+ FileRange { file_id : location. file_id , range : location. focus_or_full_range ( ) }
675
+ } )
676
+ } ) ;
671
677
}
672
678
673
679
fn end_location_link ( & mut self ) {
@@ -681,7 +687,7 @@ impl InlayHintLabelBuilder<'_> {
681
687
if !text. is_empty ( ) {
682
688
self . result . parts . push ( InlayHintLabelPart {
683
689
text,
684
- linked_location : self . location . take ( ) . map ( LazyProperty :: Computed ) ,
690
+ linked_location : self . location . take ( ) ,
685
691
tooltip : None ,
686
692
} ) ;
687
693
}
@@ -753,6 +759,7 @@ fn label_of_ty(
753
759
last_part : String :: new ( ) ,
754
760
location : None ,
755
761
result : InlayHintLabel :: default ( ) ,
762
+ resolve : config. fields_to_resolve . resolve_label_location ,
756
763
} ;
757
764
let _ = rec ( sema, famous_defs, config. max_length , ty, & mut label_builder, config, edition) ;
758
765
let r = label_builder. finish ( ) ;
0 commit comments