@@ -228,45 +228,41 @@ fn runnable_action(
228
228
}
229
229
230
230
fn goto_type_action ( db : & RootDatabase , def : Definition ) -> Option < HoverAction > {
231
- match def {
232
- Definition :: Local ( it) => {
233
- let mut targets: Vec < ModuleDef > = Vec :: new ( ) ;
234
- let mut push_new_def = |item : ModuleDef | {
235
- if !targets. contains ( & item) {
236
- targets. push ( item) ;
237
- }
238
- } ;
231
+ let ty = match def {
232
+ Definition :: Local ( it) => it. ty ( db) ,
233
+ Definition :: ConstParam ( it) => it. ty ( db) ,
234
+ _ => return None ,
235
+ } ;
236
+ let mut targets: Vec < ModuleDef > = Vec :: new ( ) ;
237
+ let mut push_new_def = |item : ModuleDef | {
238
+ if !targets. contains ( & item) {
239
+ targets. push ( item) ;
240
+ }
241
+ } ;
239
242
240
- it. ty ( db) . walk ( db, |t| {
241
- if let Some ( adt) = t. as_adt ( ) {
242
- push_new_def ( adt. into ( ) ) ;
243
- } else if let Some ( trait_) = t. as_dyn_trait ( ) {
244
- push_new_def ( trait_. into ( ) ) ;
245
- } else if let Some ( traits) = t. as_impl_traits ( db) {
246
- traits. into_iter ( ) . for_each ( |it| push_new_def ( it. into ( ) ) ) ;
247
- } else if let Some ( trait_) = t. as_associated_type_parent_trait ( db) {
248
- push_new_def ( trait_. into ( ) ) ;
249
- }
250
- } ) ;
251
-
252
- let targets = targets
253
- . into_iter ( )
254
- . filter_map ( |it| {
255
- Some ( HoverGotoTypeData {
256
- mod_path : render_path (
257
- db,
258
- it. module ( db) ?,
259
- it. name ( db) . map ( |name| name. to_string ( ) ) ,
260
- ) ,
261
- nav : it. try_to_nav ( db) ?,
262
- } )
263
- } )
264
- . collect ( ) ;
265
-
266
- Some ( HoverAction :: GoToType ( targets) )
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 ( ) ) ;
267
252
}
268
- _ => None ,
269
- }
253
+ } ) ;
254
+
255
+ let targets = targets
256
+ . into_iter ( )
257
+ . filter_map ( |it| {
258
+ Some ( HoverGotoTypeData {
259
+ mod_path : render_path ( db, it. module ( db) ?, it. name ( db) . map ( |name| name. to_string ( ) ) ) ,
260
+ nav : it. try_to_nav ( db) ?,
261
+ } )
262
+ } )
263
+ . collect ( ) ;
264
+
265
+ Some ( HoverAction :: GoToType ( targets) )
270
266
}
271
267
272
268
fn hover_markup (
@@ -3083,6 +3079,39 @@ fn main() { let s<|>t = test().get(); }
3083
3079
) ;
3084
3080
}
3085
3081
3082
+ #[ test]
3083
+ fn test_hover_const_param_has_goto_type_action ( ) {
3084
+ check_actions (
3085
+ r#"
3086
+ struct Bar;
3087
+ struct Foo<const BAR: Bar>;
3088
+
3089
+ impl<const BAR: Bar> Foo<BAR<|>> {}
3090
+ "# ,
3091
+ expect ! [ [ r#"
3092
+ [
3093
+ GoToType(
3094
+ [
3095
+ HoverGotoTypeData {
3096
+ mod_path: "test::Bar",
3097
+ nav: NavigationTarget {
3098
+ file_id: FileId(
3099
+ 0,
3100
+ ),
3101
+ full_range: 0..11,
3102
+ focus_range: 7..10,
3103
+ name: "Bar",
3104
+ kind: Struct,
3105
+ description: "struct Bar",
3106
+ },
3107
+ },
3108
+ ],
3109
+ ),
3110
+ ]
3111
+ "# ] ] ,
3112
+ ) ;
3113
+ }
3114
+
3086
3115
#[ test]
3087
3116
fn hover_displays_normalized_crate_names ( ) {
3088
3117
check (
0 commit comments