From 876f44b3eabf41c6835d8116eda03f8dcaf15f9d Mon Sep 17 00:00:00 2001 From: Jake Heinz Date: Thu, 18 Nov 2021 08:00:22 +0000 Subject: [PATCH] ide: show go to for function hover return type --- crates/ide/src/hover.rs | 1 + crates/ide/src/hover/tests.rs | 59 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index f4fb52647e7..2ebf46b5649 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -314,6 +314,7 @@ fn goto_type_action_for_def(db: &RootDatabase, def: Definition) -> Option it.ty(db), Definition::GenericParam(hir::GenericParam::ConstParam(it)) => it.ty(db), Definition::Field(field) => field.ty(db), + Definition::Function(function) => function.ret_type(db), _ => return None, }; diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 897f8d7b831..2c787a39961 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -1718,40 +1718,43 @@ fn test_hover_test_has_action() { fn foo_$0test() {} "#, expect![[r#" - [ - Reference( - FilePosition { + [ + Reference( + FilePosition { + file_id: FileId( + 0, + ), + offset: 11, + }, + ), + Runnable( + Runnable { + use_name_in_title: false, + nav: NavigationTarget { file_id: FileId( 0, ), - offset: 11, + full_range: 0..24, + focus_range: 11..19, + name: "foo_test", + kind: Function, }, - ), - Runnable( - Runnable { - use_name_in_title: false, - nav: NavigationTarget { - file_id: FileId( - 0, - ), - full_range: 0..24, - focus_range: 11..19, - name: "foo_test", - kind: Function, + kind: Test { + test_id: Path( + "foo_test", + ), + attr: TestAttr { + ignore: false, }, - kind: Test { - test_id: Path( - "foo_test", - ), - attr: TestAttr { - ignore: false, - }, - }, - cfg: None, }, - ), - ] - "#]], + cfg: None, + }, + ), + GoToType( + [], + ), + ] + "#]], ); }