@@ -320,7 +320,9 @@ fn detail(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
320
320
format_to ! ( detail, "unsafe " ) ;
321
321
}
322
322
323
- format_to ! ( detail, "fn({})" , params_display( ctx, func) ) ;
323
+ detail. push_str ( "fn(" ) ;
324
+ params_display ( ctx, & mut detail, func) ;
325
+ detail. push ( ')' ) ;
324
326
if !ret_ty. is_unit ( ) {
325
327
format_to ! ( detail, " -> {}" , ret_ty. display( ctx. db, ctx. display_target) ) ;
326
328
}
@@ -342,31 +344,29 @@ fn detail_full(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
342
344
detail
343
345
}
344
346
345
- fn params_display ( ctx : & CompletionContext < ' _ > , func : hir:: Function ) -> String {
346
- let mut params = if let Some ( self_param) = func. self_param ( ctx. db ) {
347
+ fn params_display ( ctx : & CompletionContext < ' _ > , detail : & mut String , func : hir:: Function ) {
348
+ if let Some ( self_param) = func. self_param ( ctx. db ) {
349
+ format_to ! ( detail, "{}" , self_param. display( ctx. db, ctx. display_target) ) ;
347
350
let assoc_fn_params = func. assoc_fn_params ( ctx. db ) ;
348
351
let params = assoc_fn_params
349
352
. iter ( )
350
353
. skip ( 1 ) // skip the self param because we are manually handling that
351
354
. map ( |p| p. ty ( ) . display ( ctx. db , ctx. display_target ) ) ;
352
- format ! (
353
- "{}{}" ,
354
- self_param. display( ctx. db, ctx. display_target) ,
355
- params. format_with( "" , |display, f| {
356
- f( & ", " ) ?;
357
- f( & display)
358
- } )
359
- )
355
+ for param in params {
356
+ format_to ! ( detail, ", {}" , param) ;
357
+ }
360
358
} else {
361
359
let assoc_fn_params = func. assoc_fn_params ( ctx. db ) ;
362
- assoc_fn_params. iter ( ) . map ( |p| p. ty ( ) . display ( ctx. db , ctx. display_target ) ) . join ( ", " )
363
- } ;
360
+ format_to ! (
361
+ detail,
362
+ "{}" ,
363
+ assoc_fn_params. iter( ) . map( |p| p. ty( ) . display( ctx. db, ctx. display_target) ) . format( ", " )
364
+ ) ;
365
+ }
364
366
365
367
if func. is_varargs ( ctx. db ) {
366
- params . push_str ( ", ..." ) ;
368
+ detail . push_str ( ", ..." ) ;
367
369
}
368
-
369
- params
370
370
}
371
371
372
372
fn params (
0 commit comments