@@ -104,19 +104,21 @@ fn render(
104104 . filter ( |_| !has_call_parens)
105105 . and_then ( |cap| Some ( ( cap, params ( ctx. completion , func, & func_kind, has_dot_receiver) ?) ) ) ;
106106
107- let type_match = if has_call_parens || complete_call_parens. is_some ( ) {
108- compute_type_match ( completion, & ret_type)
109- } else {
110- compute_type_match ( completion, & func. ty ( db) )
111- } ;
112-
113- let function =
114- assoc_item. and_then ( |assoc_item| assoc_item. implementing_ty ( db) ) . and_then ( |self_type| {
115- compute_function_match ( db, & ctx, self_type, func, has_self_param, & ret_type)
107+ let function = assoc_item
108+ . and_then ( |assoc_item| assoc_item. implementing_ty ( db) )
109+ . map ( |self_type| compute_return_type_match ( db, & ctx, self_type, & ret_type) )
110+ . map ( |return_type| CompletionRelevanceFn {
111+ has_params : has_self_param || func. num_params ( db) > 0 ,
112+ has_self_param,
113+ return_type,
116114 } ) ;
117115
118116 item. set_relevance ( CompletionRelevance {
119- type_match,
117+ type_match : if has_call_parens || complete_call_parens. is_some ( ) {
118+ compute_type_match ( completion, & ret_type)
119+ } else {
120+ compute_type_match ( completion, & func. ty ( db) )
121+ } ,
120122 exact_name_match : compute_exact_name_match ( completion, & call) ,
121123 function,
122124 is_op_method,
@@ -169,17 +171,13 @@ fn render(
169171 item
170172}
171173
172- fn compute_function_match (
174+ fn compute_return_type_match (
173175 db : & dyn HirDatabase ,
174176 ctx : & RenderContext < ' _ > ,
175177 self_type : hir:: Type ,
176- func : hir:: Function ,
177- has_self_param : bool ,
178178 ret_type : & hir:: Type ,
179- ) -> Option < CompletionRelevanceFn > {
180- let has_params = func. num_params ( db) > 0 ;
181-
182- let return_type = if match_types ( ctx. completion , & self_type, & ret_type) . is_some ( ) {
179+ ) -> CompletionRelevanceReturnType {
180+ if match_types ( ctx. completion , & self_type, & ret_type) . is_some ( ) {
183181 // fn([..]) -> Self
184182 CompletionRelevanceReturnType :: DirectConstructor
185183 } else if ret_type
@@ -197,9 +195,7 @@ fn compute_function_match(
197195 CompletionRelevanceReturnType :: Builder
198196 } else {
199197 CompletionRelevanceReturnType :: Other
200- } ;
201-
202- Some ( CompletionRelevanceFn { return_type, has_params, has_self_param } )
198+ }
203199}
204200
205201pub ( super ) fn add_call_parens < ' b > (
0 commit comments