@@ -295,7 +295,6 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
295295 ModuleDef :: EnumVariant ( e) => Some ( e. parent_enum ( db) . name ( db) ) ,
296296 _ => None ,
297297 } ,
298- Definition :: SelfType ( i) => i. target_ty ( db) . as_adt ( ) . map ( |adt| adt. name ( db) ) ,
299298 _ => None ,
300299 }
301300 . map ( |name| name. to_string ( ) )
@@ -357,7 +356,14 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
357356 ModuleDef :: BuiltinType ( it) => return Some ( it. to_string ( ) . into ( ) ) ,
358357 } ,
359358 Definition :: Local ( it) => return Some ( Markup :: fenced_block ( & it. ty ( db) . display ( db) ) ) ,
360- Definition :: TypeParam ( _) | Definition :: SelfType ( _) => {
359+ Definition :: SelfType ( impl_def) => {
360+ impl_def. target_ty ( db) . as_adt ( ) . and_then ( |adt| match adt {
361+ Adt :: Struct ( it) => from_def_source ( db, it, mod_path) ,
362+ Adt :: Union ( it) => from_def_source ( db, it, mod_path) ,
363+ Adt :: Enum ( it) => from_def_source ( db, it, mod_path) ,
364+ } )
365+ }
366+ Definition :: TypeParam ( _) => {
361367 // FIXME: Hover for generic param
362368 None
363369 }
@@ -1025,52 +1031,75 @@ impl Thing {
10251031}
10261032"# ,
10271033 expect ! [ [ r#"
1028- *Self { x: 0 }*
1034+ *Self*
1035+
10291036 ```rust
1030- Thing
1037+ test
1038+ ```
1039+
1040+ ```rust
1041+ struct Thing
10311042 ```
10321043 "# ] ] ,
1033- )
1034- } /* FIXME: revive these tests
1035- let (analysis, position) = fixture::position(
1036- "
1037- struct Thing { x: u32 }
1038- impl Thing {
1039- fn new() -> Self<|> {
1040- Self { x: 0 }
1041- }
1042- }
1043- ",
1044- );
1045-
1046- let hover = analysis.hover(position).unwrap().unwrap();
1047- assert_eq!(trim_markup(&hover.info.markup.as_str()), ("Thing"));
1048-
1049- let (analysis, position) = fixture::position(
1050- "
1051- enum Thing { A }
1052- impl Thing {
1053- pub fn new() -> Self<|> {
1054- Thing::A
1055- }
1056- }
1057- ",
1058- );
1059- let hover = analysis.hover(position).unwrap().unwrap();
1060- assert_eq!(trim_markup(&hover.info.markup.as_str()), ("enum Thing"));
1061-
1062- let (analysis, position) = fixture::position(
1063- "
1064- enum Thing { A }
1065- impl Thing {
1066- pub fn thing(a: Self<|>) {
1067- }
1068- }
1069- ",
1070- );
1071- let hover = analysis.hover(position).unwrap().unwrap();
1072- assert_eq!(trim_markup(&hover.info.markup.as_str()), ("enum Thing"));
1073- */
1044+ ) ;
1045+ check (
1046+ r#"
1047+ struct Thing { x: u32 }
1048+ impl Thing {
1049+ fn new() -> Self<|> { Self { x: 0 } }
1050+ }
1051+ "# ,
1052+ expect ! [ [ r#"
1053+ *Self*
1054+
1055+ ```rust
1056+ test
1057+ ```
1058+
1059+ ```rust
1060+ struct Thing
1061+ ```
1062+ "# ] ] ,
1063+ ) ;
1064+ check (
1065+ r#"
1066+ enum Thing { A }
1067+ impl Thing {
1068+ pub fn new() -> Self<|> { Thing::A }
1069+ }
1070+ "# ,
1071+ expect ! [ [ r#"
1072+ *Self*
1073+
1074+ ```rust
1075+ test
1076+ ```
1077+
1078+ ```rust
1079+ enum Thing
1080+ ```
1081+ "# ] ] ,
1082+ ) ;
1083+ check (
1084+ r#"
1085+ enum Thing { A }
1086+ impl Thing {
1087+ pub fn thing(a: Self<|>) {}
1088+ }
1089+ "# ,
1090+ expect ! [ [ r#"
1091+ *Self*
1092+
1093+ ```rust
1094+ test
1095+ ```
1096+
1097+ ```rust
1098+ enum Thing
1099+ ```
1100+ "# ] ] ,
1101+ ) ;
1102+ }
10741103
10751104 #[ test]
10761105 fn test_hover_shadowing_pat ( ) {
0 commit comments