@@ -85,10 +85,11 @@ pub enum HoverAction {
85
85
86
86
impl HoverAction {
87
87
fn goto_type_from_targets (
88
- db : & RootDatabase ,
88
+ sema : & Semantics < ' _ , RootDatabase > ,
89
89
targets : Vec < hir:: ModuleDef > ,
90
90
edition : Edition ,
91
91
) -> Option < Self > {
92
+ let db = sema. db ;
92
93
let targets = targets
93
94
. into_iter ( )
94
95
. filter_map ( |it| {
@@ -99,7 +100,7 @@ impl HoverAction {
99
100
it. name ( db) . map ( |name| name. display ( db, edition) . to_string ( ) ) ,
100
101
edition,
101
102
) ,
102
- nav : it. try_to_nav ( db ) ?. call_site ( ) ,
103
+ nav : it. try_to_nav ( sema ) ?. call_site ( ) ,
103
104
} )
104
105
} )
105
106
. collect :: < Vec < _ > > ( ) ;
@@ -467,10 +468,10 @@ pub(crate) fn hover_for_definition(
467
468
HoverResult {
468
469
markup : render:: process_markup ( sema. db , def, & markup, range_map, config) ,
469
470
actions : [
470
- show_fn_references_action ( sema. db , def) ,
471
- show_implementations_action ( sema. db , def) ,
471
+ show_fn_references_action ( sema, def) ,
472
+ show_implementations_action ( sema, def) ,
472
473
runnable_action ( sema, def, file_id) ,
473
- goto_type_action_for_def ( sema. db , def, & notable_traits, subst_types, edition) ,
474
+ goto_type_action_for_def ( sema, def, & notable_traits, subst_types, edition) ,
474
475
]
475
476
. into_iter ( )
476
477
. flatten ( )
@@ -505,7 +506,10 @@ fn notable_traits<'db>(
505
506
. collect :: < Vec < _ > > ( )
506
507
}
507
508
508
- fn show_implementations_action ( db : & RootDatabase , def : Definition ) -> Option < HoverAction > {
509
+ fn show_implementations_action (
510
+ sema : & Semantics < ' _ , RootDatabase > ,
511
+ def : Definition ,
512
+ ) -> Option < HoverAction > {
509
513
fn to_action ( nav_target : NavigationTarget ) -> HoverAction {
510
514
HoverAction :: Implementation ( FilePosition {
511
515
file_id : nav_target. file_id ,
@@ -515,19 +519,22 @@ fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<Hov
515
519
516
520
let adt = match def {
517
521
Definition :: Trait ( it) => {
518
- return it. try_to_nav ( db ) . map ( UpmappingResult :: call_site) . map ( to_action) ;
522
+ return it. try_to_nav ( sema ) . map ( UpmappingResult :: call_site) . map ( to_action) ;
519
523
}
520
524
Definition :: Adt ( it) => Some ( it) ,
521
- Definition :: SelfType ( it) => it. self_ty ( db) . as_adt ( ) ,
525
+ Definition :: SelfType ( it) => it. self_ty ( sema . db ) . as_adt ( ) ,
522
526
_ => None ,
523
527
} ?;
524
- adt. try_to_nav ( db ) . map ( UpmappingResult :: call_site) . map ( to_action)
528
+ adt. try_to_nav ( sema ) . map ( UpmappingResult :: call_site) . map ( to_action)
525
529
}
526
530
527
- fn show_fn_references_action ( db : & RootDatabase , def : Definition ) -> Option < HoverAction > {
531
+ fn show_fn_references_action (
532
+ sema : & Semantics < ' _ , RootDatabase > ,
533
+ def : Definition ,
534
+ ) -> Option < HoverAction > {
528
535
match def {
529
536
Definition :: Function ( it) => {
530
- it. try_to_nav ( db ) . map ( UpmappingResult :: call_site) . map ( |nav_target| {
537
+ it. try_to_nav ( sema ) . map ( UpmappingResult :: call_site) . map ( |nav_target| {
531
538
HoverAction :: Reference ( FilePosition {
532
539
file_id : nav_target. file_id ,
533
540
offset : nav_target. focus_or_full_range ( ) . start ( ) ,
@@ -560,12 +567,13 @@ fn runnable_action(
560
567
}
561
568
562
569
fn goto_type_action_for_def (
563
- db : & RootDatabase ,
570
+ sema : & Semantics < ' _ , RootDatabase > ,
564
571
def : Definition ,
565
572
notable_traits : & [ ( hir:: Trait , Vec < ( Option < hir:: Type < ' _ > > , hir:: Name ) > ) ] ,
566
573
subst_types : Option < Vec < ( hir:: Symbol , hir:: Type < ' _ > ) > > ,
567
574
edition : Edition ,
568
575
) -> Option < HoverAction > {
576
+ let db = sema. db ;
569
577
let mut targets: Vec < hir:: ModuleDef > = Vec :: new ( ) ;
570
578
let mut push_new_def = |item : hir:: ModuleDef | {
571
579
if !targets. contains ( & item) {
@@ -612,7 +620,7 @@ fn goto_type_action_for_def(
612
620
}
613
621
}
614
622
615
- HoverAction :: goto_type_from_targets ( db , targets, edition)
623
+ HoverAction :: goto_type_from_targets ( sema , targets, edition)
616
624
}
617
625
618
626
fn walk_and_push_ty (
0 commit comments