@@ -27,6 +27,7 @@ mod bind_pat;
27
27
28
28
#[ derive( Clone , Debug , PartialEq , Eq ) ]
29
29
pub struct InlayHintsConfig {
30
+ pub location_links : bool ,
30
31
pub render_colons : bool ,
31
32
pub type_hints : bool ,
32
33
pub parameter_hints : bool ,
@@ -182,6 +183,7 @@ struct InlayHintLabelBuilder<'a> {
182
183
db : & ' a RootDatabase ,
183
184
result : InlayHintLabel ,
184
185
last_part : String ,
186
+ location_link_enabled : bool ,
185
187
location : Option < FileRange > ,
186
188
}
187
189
@@ -193,6 +195,9 @@ impl fmt::Write for InlayHintLabelBuilder<'_> {
193
195
194
196
impl HirWrite for InlayHintLabelBuilder < ' _ > {
195
197
fn start_location_link ( & mut self , def : ModuleDefId ) {
198
+ if !self . location_link_enabled {
199
+ return ;
200
+ }
196
201
if self . location . is_some ( ) {
197
202
never ! ( "location link is already started" ) ;
198
203
}
@@ -204,6 +209,9 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
204
209
}
205
210
206
211
fn end_location_link ( & mut self ) {
212
+ if !self . location_link_enabled {
213
+ return ;
214
+ }
207
215
self . make_new_part ( ) ;
208
216
}
209
217
}
@@ -260,6 +268,7 @@ fn label_of_ty(
260
268
db : sema. db ,
261
269
last_part : String :: new ( ) ,
262
270
location : None ,
271
+ location_link_enabled : config. location_links ,
263
272
result : InlayHintLabel :: default ( ) ,
264
273
} ;
265
274
rec ( sema, & famous_defs, config. max_length , ty, & mut label_builder) ;
@@ -416,6 +425,7 @@ mod tests {
416
425
use super :: ClosureReturnTypeHints ;
417
426
418
427
pub ( super ) const DISABLED_CONFIG : InlayHintsConfig = InlayHintsConfig {
428
+ location_links : false ,
419
429
render_colons : false ,
420
430
type_hints : false ,
421
431
parameter_hints : false ,
@@ -430,14 +440,16 @@ mod tests {
430
440
max_length : None ,
431
441
closing_brace_hints_min_lines : None ,
432
442
} ;
443
+ pub ( super ) const DISABLED_CONFIG_WITH_LINKS : InlayHintsConfig =
444
+ InlayHintsConfig { location_links : true , ..DISABLED_CONFIG } ;
433
445
pub ( super ) const TEST_CONFIG : InlayHintsConfig = InlayHintsConfig {
434
446
type_hints : true ,
435
447
parameter_hints : true ,
436
448
chaining_hints : true ,
437
449
closure_return_type_hints : ClosureReturnTypeHints :: WithBlock ,
438
450
binding_mode_hints : true ,
439
451
lifetime_elision_hints : LifetimeElisionHints :: Always ,
440
- ..DISABLED_CONFIG
452
+ ..DISABLED_CONFIG_WITH_LINKS
441
453
} ;
442
454
443
455
#[ track_caller]
0 commit comments