@@ -48,7 +48,7 @@ pub enum ReborrowHints {
4848pub enum InlayKind {
4949 BindingModeHint ,
5050 ChainingHint ,
51- ClosingBraceHint ( Option < TextSize > ) ,
51+ ClosingBraceHint ,
5252 ClosureReturnTypeHint ,
5353 GenericParamListHint ,
5454 ImplicitReborrowHint ,
@@ -57,11 +57,19 @@ pub enum InlayKind {
5757 TypeHint ,
5858}
5959
60+ // FIXME: This should live somewhere more general
61+ #[ derive( Debug ) ]
62+ pub enum RangeOrOffset {
63+ Range ( TextRange ) ,
64+ Offset ( TextSize ) ,
65+ }
66+
6067#[ derive( Debug ) ]
6168pub struct InlayHint {
6269 pub range : TextRange ,
6370 pub kind : InlayKind ,
6471 pub label : String ,
72+ pub hover_trigger : Option < RangeOrOffset > ,
6573}
6674
6775// Feature: Inlay Hints
@@ -253,8 +261,9 @@ fn closing_brace_hints(
253261
254262 acc. push ( InlayHint {
255263 range : closing_token. text_range ( ) ,
256- kind : InlayKind :: ClosingBraceHint ( name_offset ) ,
264+ kind : InlayKind :: ClosingBraceHint ,
257265 label,
266+ hover_trigger : name_offset. map ( RangeOrOffset :: Offset ) ,
258267 } ) ;
259268
260269 None
@@ -273,6 +282,7 @@ fn lifetime_fn_hints(
273282 range : t. text_range ( ) ,
274283 kind : InlayKind :: LifetimeHint ,
275284 label,
285+ hover_trigger : None ,
276286 } ;
277287
278288 let param_list = func. param_list ( ) ?;
@@ -431,6 +441,7 @@ fn lifetime_fn_hints(
431441 range : func. name ( ) ?. syntax ( ) . text_range ( ) ,
432442 kind : InlayKind :: GenericParamListHint ,
433443 label : format ! ( "<{}>" , allocated_lifetimes. iter( ) . format( ", " ) , ) . into ( ) ,
444+ hover_trigger : None ,
434445 } ) ,
435446 }
436447 Some ( ( ) )
@@ -464,6 +475,7 @@ fn closure_ret_hints(
464475 kind : InlayKind :: ClosureReturnTypeHint ,
465476 label : hint_iterator ( sema, & famous_defs, config, & ty)
466477 . unwrap_or_else ( || ty. display_truncated ( sema. db , config. max_length ) . to_string ( ) ) ,
478+ hover_trigger : None ,
467479 } ) ;
468480 Some ( ( ) )
469481}
@@ -490,6 +502,7 @@ fn reborrow_hints(
490502 range : expr. syntax ( ) . text_range ( ) ,
491503 kind : InlayKind :: ImplicitReborrowHint ,
492504 label : label. to_string ( ) ,
505+ hover_trigger : None ,
493506 } ) ;
494507 Some ( ( ) )
495508}
@@ -548,6 +561,7 @@ fn chaining_hints(
548561 label : hint_iterator ( sema, & famous_defs, config, & ty) . unwrap_or_else ( || {
549562 ty. display_truncated ( sema. db , config. max_length ) . to_string ( )
550563 } ) ,
564+ hover_trigger : Some ( RangeOrOffset :: Range ( expr. syntax ( ) . text_range ( ) ) ) ,
551565 } ) ;
552566 }
553567 }
@@ -588,6 +602,8 @@ fn param_name_hints(
588602 range,
589603 kind : InlayKind :: ParameterHint ,
590604 label : param_name. into ( ) ,
605+ // FIXME: Show hover for parameter
606+ hover_trigger : None ,
591607 } ) ;
592608
593609 acc. extend ( hints) ;
@@ -613,7 +629,12 @@ fn binding_mode_hints(
613629 ( true , false ) => "&" ,
614630 _ => return ,
615631 } ;
616- acc. push ( InlayHint { range, kind : InlayKind :: BindingModeHint , label : r. to_string ( ) } ) ;
632+ acc. push ( InlayHint {
633+ range,
634+ kind : InlayKind :: BindingModeHint ,
635+ label : r. to_string ( ) ,
636+ hover_trigger : None ,
637+ } ) ;
617638 } ) ;
618639 match pat {
619640 ast:: Pat :: IdentPat ( pat) if pat. ref_token ( ) . is_none ( ) && pat. mut_token ( ) . is_none ( ) => {
@@ -623,7 +644,12 @@ fn binding_mode_hints(
623644 hir:: BindingMode :: Ref ( Mutability :: Mut ) => "ref mut" ,
624645 hir:: BindingMode :: Ref ( Mutability :: Shared ) => "ref" ,
625646 } ;
626- acc. push ( InlayHint { range, kind : InlayKind :: BindingModeHint , label : bm. to_string ( ) } ) ;
647+ acc. push ( InlayHint {
648+ range,
649+ kind : InlayKind :: BindingModeHint ,
650+ label : bm. to_string ( ) ,
651+ hover_trigger : None ,
652+ } ) ;
627653 }
628654 _ => ( ) ,
629655 }
@@ -673,6 +699,7 @@ fn bind_pat_hints(
673699 } ,
674700 kind : InlayKind :: TypeHint ,
675701 label,
702+ hover_trigger : pat. name ( ) . map ( |it| it. syntax ( ) . text_range ( ) ) . map ( RangeOrOffset :: Range ) ,
676703 } ) ;
677704
678705 Some ( ( ) )
0 commit comments