@@ -67,10 +67,10 @@ fn hover_text(
6767 desc : Option < String > ,
6868 mod_path : Option < String > ,
6969) -> 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
7474 }
7575}
7676
@@ -106,7 +106,7 @@ fn determine_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
106106 . flatten ( )
107107 . join ( "::" )
108108 } ) ;
109- mod_path
109+ mod_path // FIXME: replace dashes with underscores in crate display name
110110}
111111
112112fn 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
143143 ModuleDef :: TypeAlias ( it) => from_def_source ( db, it, mod_path) ,
144144 ModuleDef :: BuiltinType ( it) => Some ( it. to_string ( ) ) ,
145145 } ,
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 ) ) ) ,
149147 Definition :: TypeParam ( _) | Definition :: SelfType ( _) => {
150148 // FIXME: Hover for generic param
151149 None
@@ -210,7 +208,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
210208 }
211209 } ?;
212210
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 ) ) ) ) ;
214212 let range = sema. original_range ( & node) . range ;
215213 Some ( RangeInfo :: new ( range, res) )
216214}
0 commit comments