1
1
use std:: { collections:: HashMap , fmt} ;
2
2
3
3
use ra_ap_syntax:: {
4
- ast:: { self , HasDocComments , HasGenericParams , HasName } ,
4
+ ast:: { self , HasDocComments , HasGenericParams , HasName , Fn } ,
5
5
AstNode , SourceFile , SyntaxKind ,
6
6
} ;
7
7
@@ -302,7 +302,7 @@ pub(crate) fn find_function_in_file(
302
302
top : stuff. 1 . 0 ,
303
303
bottom : stuff. 1 . 1 ,
304
304
lines : ( stuff. 0 . 0 , stuff. 0 . 1 ) ,
305
- return_type : function . ret_type ( ) . map ( |ty| ty . to_string ( ) ) ,
305
+ return_type : get_ret_type ( & function ) ,
306
306
arguments : f. param_list ( ) . map_or_else ( HashMap :: new, |args| {
307
307
args. params ( )
308
308
. filter_map ( |arg| {
@@ -341,7 +341,7 @@ pub(crate) fn find_function_in_file(
341
341
body,
342
342
block : parent_block,
343
343
function : parent_fn,
344
- return_type : f . ret_type ( ) . map ( |ty| ty . to_string ( ) ) ,
344
+ return_type : get_ret_type ( & f ) ,
345
345
arguments : f. param_list ( ) . map_or_else ( HashMap :: new, |args| {
346
346
args. params ( )
347
347
. filter_map ( |arg| {
@@ -419,9 +419,11 @@ fn get_genrerics_and_lifetime<T: HasGenericParams>(block: &T) -> (Vec<String>, V
419
419
|| ( vec ! [ ] , vec ! [ ] ) ,
420
420
|gt| {
421
421
(
422
- // gt.
423
- gt. generic_params ( )
424
- . map ( |gt| gt. to_string ( ) )
422
+ gt. type_or_const_params ( )
423
+ . map ( |gt|match gt {
424
+ ast:: TypeOrConstParam :: Type ( ty) => ty. to_string ( ) ,
425
+ ast:: TypeOrConstParam :: Const ( c) => c. to_string ( ) ,
426
+ } )
425
427
. collect :: < Vec < String > > ( ) ,
426
428
gt. lifetime_params ( )
427
429
. map ( |lt| lt. to_string ( ) )
@@ -443,6 +445,16 @@ fn get_doc_comments_and_attrs<T: HasDocComments>(block: &T) -> (Vec<String>, Vec
443
445
. collect :: < Vec < String > > ( ) ,
444
446
)
445
447
}
448
+
449
+ fn get_ret_type ( fns : & Fn ) -> Option < String > {
450
+ match fns. ret_type ( ) {
451
+ Some ( ret) => match ret. ty ( ) {
452
+ Some ( ty) => Some ( ty. to_string ( ) ) ,
453
+ None => None ,
454
+ } ,
455
+ None => None ,
456
+ }
457
+ }
446
458
#[ derive( Debug , Clone , PartialEq , Eq ) ]
447
459
pub enum RustFilter {
448
460
/// when you want to filter by function that are in a specific block (impl, trait, extern)
0 commit comments