@@ -650,7 +650,8 @@ struct InlayHintLabelBuilder<'a> {
650650 db : & ' a RootDatabase ,
651651 result : InlayHintLabel ,
652652 last_part : String ,
653- location : Option < FileRange > ,
653+ resolve : bool ,
654+ location : Option < LazyProperty < FileRange > > ,
654655}
655656
656657impl fmt:: Write for InlayHintLabelBuilder < ' _ > {
@@ -663,11 +664,16 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
663664 fn start_location_link ( & mut self , def : ModuleDefId ) {
664665 never ! ( self . location. is_some( ) , "location link is already started" ) ;
665666 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+ } ) ;
671677 }
672678
673679 fn end_location_link ( & mut self ) {
@@ -681,7 +687,7 @@ impl InlayHintLabelBuilder<'_> {
681687 if !text. is_empty ( ) {
682688 self . result . parts . push ( InlayHintLabelPart {
683689 text,
684- linked_location : self . location . take ( ) . map ( LazyProperty :: Computed ) ,
690+ linked_location : self . location . take ( ) ,
685691 tooltip : None ,
686692 } ) ;
687693 }
@@ -753,6 +759,7 @@ fn label_of_ty(
753759 last_part : String :: new ( ) ,
754760 location : None ,
755761 result : InlayHintLabel :: default ( ) ,
762+ resolve : config. fields_to_resolve . resolve_label_location ,
756763 } ;
757764 let _ = rec ( sema, famous_defs, config. max_length , ty, & mut label_builder, config, edition) ;
758765 let r = label_builder. finish ( ) ;
0 commit comments