@@ -67,10 +67,10 @@ fn hover_text(
67
67
desc : Option < String > ,
68
68
mod_path : Option < String > ,
69
69
) -> Option < String > {
70
- match ( desc, docs , mod_path ) {
71
- ( Some ( desc ) , docs , mod_path ) => Some ( rust_code_markup_with_doc ( desc, docs, mod_path) ) ,
72
- ( None , Some ( docs ) , _ ) => Some ( docs ) ,
73
- _ => None ,
70
+ if let Some ( desc) = desc {
71
+ Some ( rust_code_markup_with_doc ( & desc, docs. as_deref ( ) , mod_path. as_deref ( ) ) )
72
+ } else {
73
+ docs
74
74
}
75
75
}
76
76
@@ -106,7 +106,7 @@ fn determine_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
106
106
. flatten ( )
107
107
. join ( "::" )
108
108
} ) ;
109
- mod_path
109
+ mod_path // FIXME: replace dashes with underscores in crate display name
110
110
}
111
111
112
112
fn hover_text_from_name_kind ( db : & RootDatabase , def : Definition ) -> Option < String > {
@@ -143,9 +143,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, def: Definition) -> Option<Strin
143
143
ModuleDef :: TypeAlias ( it) => from_def_source ( db, it, mod_path) ,
144
144
ModuleDef :: BuiltinType ( it) => Some ( it. to_string ( ) ) ,
145
145
} ,
146
- Definition :: Local ( it) => {
147
- Some ( rust_code_markup ( it. ty ( db) . display_truncated ( db, None ) . to_string ( ) ) )
148
- }
146
+ Definition :: Local ( it) => Some ( rust_code_markup ( & it. ty ( db) . display_truncated ( db, None ) ) ) ,
149
147
Definition :: TypeParam ( _) | Definition :: SelfType ( _) => {
150
148
// FIXME: Hover for generic param
151
149
None
@@ -210,7 +208,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
210
208
}
211
209
} ?;
212
210
213
- res. extend ( Some ( rust_code_markup ( ty. display_truncated ( db, None ) . to_string ( ) ) ) ) ;
211
+ res. extend ( Some ( rust_code_markup ( & ty. display_truncated ( db, None ) ) ) ) ;
214
212
let range = sema. original_range ( & node) . range ;
215
213
Some ( RangeInfo :: new ( range, res) )
216
214
}
0 commit comments