@@ -129,6 +129,11 @@ impl fmt::Debug for InlayHintLabel {
129129
130130pub struct InlayHintLabelPart {
131131 pub text : String ,
132+ /// Source location represented by this label part. The client will use this to fetch the part's
133+ /// hover tooltip, and Ctrl+Clicking the label part will navigate to the definition the location
134+ /// refers to (not necessarily the location itself).
135+ /// When setting this, no tooltip must be set on the containing hint, or VS Code will display
136+ /// them both.
132137 pub linked_location : Option < FileRange > ,
133138}
134139
@@ -266,10 +271,10 @@ fn closing_brace_hints(
266271) -> Option < ( ) > {
267272 let min_lines = config. closing_brace_hints_min_lines ?;
268273
269- let name = |it : ast:: Name | it. syntax ( ) . text_range ( ) . start ( ) ;
274+ let name = |it : ast:: Name | it. syntax ( ) . text_range ( ) ;
270275
271276 let mut closing_token;
272- let ( label, name_offset ) = if let Some ( item_list) = ast:: AssocItemList :: cast ( node. clone ( ) ) {
277+ let ( label, name_range ) = if let Some ( item_list) = ast:: AssocItemList :: cast ( node. clone ( ) ) {
273278 closing_token = item_list. r_curly_token ( ) ?;
274279
275280 let parent = item_list. syntax ( ) . parent ( ) ?;
@@ -279,11 +284,11 @@ fn closing_brace_hints(
279284 let imp = sema. to_def( & imp) ?;
280285 let ty = imp. self_ty( sema. db) ;
281286 let trait_ = imp. trait_( sema. db) ;
282-
283- ( match trait_ {
287+ let hint_text = match trait_ {
284288 Some ( tr) => format!( "impl {} for {}" , tr. name( sema. db) , ty. display_truncated( sema. db, config. max_length) ) ,
285289 None => format!( "impl {}" , ty. display_truncated( sema. db, config. max_length) ) ,
286- } , None )
290+ } ;
291+ ( hint_text, None )
287292 } ,
288293 ast:: Trait ( tr) => {
289294 ( format!( "trait {}" , tr. name( ) ?) , tr. name( ) . map( name) )
@@ -327,7 +332,7 @@ fn closing_brace_hints(
327332
328333 (
329334 format ! ( "{}!" , mac. path( ) ?) ,
330- mac. path ( ) . and_then ( |it| it. segment ( ) ) . map ( |it| it. syntax ( ) . text_range ( ) . start ( ) ) ,
335+ mac. path ( ) . and_then ( |it| it. segment ( ) ) . map ( |it| it. syntax ( ) . text_range ( ) ) ,
331336 )
332337 } else {
333338 return None ;
@@ -352,11 +357,12 @@ fn closing_brace_hints(
352357 return None ;
353358 }
354359
360+ let linked_location = name_range. map ( |range| FileRange { file_id, range } ) ;
355361 acc. push ( InlayHint {
356362 range : closing_token. text_range ( ) ,
357363 kind : InlayKind :: ClosingBraceHint ,
358- label : label. into ( ) ,
359- tooltip : name_offset . map ( |it| InlayTooltip :: HoverOffset ( file_id , it ) ) ,
364+ label : InlayHintLabel { parts : vec ! [ InlayHintLabelPart { text : label, linked_location } ] } ,
365+ tooltip : None , // provided by label part location
360366 } ) ;
361367
362368 None
0 commit comments