@@ -104,19 +104,21 @@ fn render(
104
104
. filter ( |_| !has_call_parens)
105
105
. and_then ( |cap| Some ( ( cap, params ( ctx. completion , func, & func_kind, has_dot_receiver) ?) ) ) ;
106
106
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,
116
114
} ) ;
117
115
118
116
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
+ } ,
120
122
exact_name_match : compute_exact_name_match ( completion, & call) ,
121
123
function,
122
124
is_op_method,
@@ -169,17 +171,13 @@ fn render(
169
171
item
170
172
}
171
173
172
- fn compute_function_match (
174
+ fn compute_return_type_match (
173
175
db : & dyn HirDatabase ,
174
176
ctx : & RenderContext < ' _ > ,
175
177
self_type : hir:: Type ,
176
- func : hir:: Function ,
177
- has_self_param : bool ,
178
178
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 ( ) {
183
181
// fn([..]) -> Self
184
182
CompletionRelevanceReturnType :: DirectConstructor
185
183
} else if ret_type
@@ -197,9 +195,7 @@ fn compute_function_match(
197
195
CompletionRelevanceReturnType :: Builder
198
196
} else {
199
197
CompletionRelevanceReturnType :: Other
200
- } ;
201
-
202
- Some ( CompletionRelevanceFn { return_type, has_params, has_self_param } )
198
+ }
203
199
}
204
200
205
201
pub ( super ) fn add_call_parens < ' b > (
0 commit comments