@@ -295,7 +295,6 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
295
295
ModuleDef :: EnumVariant ( e) => Some ( e. parent_enum ( db) . name ( db) ) ,
296
296
_ => None ,
297
297
} ,
298
- Definition :: SelfType ( i) => i. target_ty ( db) . as_adt ( ) . map ( |adt| adt. name ( db) ) ,
299
298
_ => None ,
300
299
}
301
300
. map ( |name| name. to_string ( ) )
@@ -357,7 +356,14 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
357
356
ModuleDef :: BuiltinType ( it) => return Some ( it. to_string ( ) . into ( ) ) ,
358
357
} ,
359
358
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 ( _) => {
361
367
// FIXME: Hover for generic param
362
368
None
363
369
}
@@ -1025,52 +1031,75 @@ impl Thing {
1025
1031
}
1026
1032
"# ,
1027
1033
expect ! [ [ r#"
1028
- *Self { x: 0 }*
1034
+ *Self*
1035
+
1029
1036
```rust
1030
- Thing
1037
+ test
1038
+ ```
1039
+
1040
+ ```rust
1041
+ struct Thing
1031
1042
```
1032
1043
"# ] ] ,
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
+ }
1074
1103
1075
1104
#[ test]
1076
1105
fn test_hover_shadowing_pat ( ) {
0 commit comments