@@ -228,29 +228,34 @@ fn runnable_action(
228
228
}
229
229
230
230
fn goto_type_action ( db : & RootDatabase , def : Definition ) -> Option < HoverAction > {
231
- let ty = match def {
232
- Definition :: Local ( it) => it. ty ( db) ,
233
- Definition :: ConstParam ( it) => it. ty ( db) ,
234
- _ => return None ,
235
- } ;
236
231
let mut targets: Vec < ModuleDef > = Vec :: new ( ) ;
237
232
let mut push_new_def = |item : ModuleDef | {
238
233
if !targets. contains ( & item) {
239
234
targets. push ( item) ;
240
235
}
241
236
} ;
242
237
243
- ty. walk ( db, |t| {
244
- if let Some ( adt) = t. as_adt ( ) {
245
- push_new_def ( adt. into ( ) ) ;
246
- } else if let Some ( trait_) = t. as_dyn_trait ( ) {
247
- push_new_def ( trait_. into ( ) ) ;
248
- } else if let Some ( traits) = t. as_impl_traits ( db) {
249
- traits. into_iter ( ) . for_each ( |it| push_new_def ( it. into ( ) ) ) ;
250
- } else if let Some ( trait_) = t. as_associated_type_parent_trait ( db) {
251
- push_new_def ( trait_. into ( ) ) ;
252
- }
253
- } ) ;
238
+ if let Definition :: TypeParam ( it) = def {
239
+ it. trait_bounds ( db) . into_iter ( ) . for_each ( |it| push_new_def ( it. into ( ) ) ) ;
240
+ } else {
241
+ let ty = match def {
242
+ Definition :: Local ( it) => it. ty ( db) ,
243
+ Definition :: ConstParam ( it) => it. ty ( db) ,
244
+ _ => return None ,
245
+ } ;
246
+
247
+ ty. walk ( db, |t| {
248
+ if let Some ( adt) = t. as_adt ( ) {
249
+ push_new_def ( adt. into ( ) ) ;
250
+ } else if let Some ( trait_) = t. as_dyn_trait ( ) {
251
+ push_new_def ( trait_. into ( ) ) ;
252
+ } else if let Some ( traits) = t. as_impl_traits ( db) {
253
+ traits. into_iter ( ) . for_each ( |it| push_new_def ( it. into ( ) ) ) ;
254
+ } else if let Some ( trait_) = t. as_associated_type_parent_trait ( db) {
255
+ push_new_def ( trait_. into ( ) ) ;
256
+ }
257
+ } ) ;
258
+ }
254
259
255
260
let targets = targets
256
261
. into_iter ( )
@@ -3086,7 +3091,7 @@ fn main() { let s<|>t = test().get(); }
3086
3091
struct Bar;
3087
3092
struct Foo<const BAR: Bar>;
3088
3093
3089
- impl<const BAR: Bar> Foo<BAR<|>> {}
3094
+ impl<const BAR: Bar> Foo<BAR<|>> {}
3090
3095
"# ,
3091
3096
expect ! [ [ r#"
3092
3097
[
@@ -3112,6 +3117,38 @@ impl<const BAR: Bar> Foo<BAR<|>> {}
3112
3117
) ;
3113
3118
}
3114
3119
3120
+ #[ test]
3121
+ fn test_hover_type_param_has_goto_type_action ( ) {
3122
+ check_actions (
3123
+ r#"
3124
+ trait Foo {}
3125
+
3126
+ fn foo<T: Foo>(t: T<|>){}
3127
+ "# ,
3128
+ expect ! [ [ r#"
3129
+ [
3130
+ GoToType(
3131
+ [
3132
+ HoverGotoTypeData {
3133
+ mod_path: "test::Foo",
3134
+ nav: NavigationTarget {
3135
+ file_id: FileId(
3136
+ 0,
3137
+ ),
3138
+ full_range: 0..12,
3139
+ focus_range: 6..9,
3140
+ name: "Foo",
3141
+ kind: Trait,
3142
+ description: "trait Foo",
3143
+ },
3144
+ },
3145
+ ],
3146
+ ),
3147
+ ]
3148
+ "# ] ] ,
3149
+ ) ;
3150
+ }
3151
+
3115
3152
#[ test]
3116
3153
fn hover_displays_normalized_crate_names ( ) {
3117
3154
check (
0 commit comments