@@ -27,6 +27,7 @@ mod bind_pat;
2727
2828#[ derive( Clone , Debug , PartialEq , Eq ) ]
2929pub struct InlayHintsConfig {
30+ pub location_links : bool ,
3031 pub render_colons : bool ,
3132 pub type_hints : bool ,
3233 pub parameter_hints : bool ,
@@ -182,6 +183,7 @@ struct InlayHintLabelBuilder<'a> {
182183 db : & ' a RootDatabase ,
183184 result : InlayHintLabel ,
184185 last_part : String ,
186+ location_link_enabled : bool ,
185187 location : Option < FileRange > ,
186188}
187189
@@ -193,6 +195,9 @@ impl fmt::Write for InlayHintLabelBuilder<'_> {
193195
194196impl HirWrite for InlayHintLabelBuilder < ' _ > {
195197 fn start_location_link ( & mut self , def : ModuleDefId ) {
198+ if !self . location_link_enabled {
199+ return ;
200+ }
196201 if self . location . is_some ( ) {
197202 never ! ( "location link is already started" ) ;
198203 }
@@ -204,6 +209,9 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
204209 }
205210
206211 fn end_location_link ( & mut self ) {
212+ if !self . location_link_enabled {
213+ return ;
214+ }
207215 self . make_new_part ( ) ;
208216 }
209217}
@@ -260,6 +268,7 @@ fn label_of_ty(
260268 db : sema. db ,
261269 last_part : String :: new ( ) ,
262270 location : None ,
271+ location_link_enabled : config. location_links ,
263272 result : InlayHintLabel :: default ( ) ,
264273 } ;
265274 rec ( sema, & famous_defs, config. max_length , ty, & mut label_builder) ;
@@ -416,6 +425,7 @@ mod tests {
416425 use super :: ClosureReturnTypeHints ;
417426
418427 pub ( super ) const DISABLED_CONFIG : InlayHintsConfig = InlayHintsConfig {
428+ location_links : false ,
419429 render_colons : false ,
420430 type_hints : false ,
421431 parameter_hints : false ,
@@ -430,14 +440,16 @@ mod tests {
430440 max_length : None ,
431441 closing_brace_hints_min_lines : None ,
432442 } ;
443+ pub ( super ) const DISABLED_CONFIG_WITH_LINKS : InlayHintsConfig =
444+ InlayHintsConfig { location_links : true , ..DISABLED_CONFIG } ;
433445 pub ( super ) const TEST_CONFIG : InlayHintsConfig = InlayHintsConfig {
434446 type_hints : true ,
435447 parameter_hints : true ,
436448 chaining_hints : true ,
437449 closure_return_type_hints : ClosureReturnTypeHints :: WithBlock ,
438450 binding_mode_hints : true ,
439451 lifetime_elision_hints : LifetimeElisionHints :: Always ,
440- ..DISABLED_CONFIG
452+ ..DISABLED_CONFIG_WITH_LINKS
441453 } ;
442454
443455 #[ track_caller]
0 commit comments