@@ -307,12 +307,13 @@ impl<'a> Render<'a> {
307
307
}
308
308
309
309
fn compute_exact_type_match ( ctx : & CompletionContext , completion_ty : & hir:: Type ) -> bool {
310
- if let Some ( expected_type) = ctx. expected_type . as_ref ( ) {
311
- // We don't ever consider unit type to be an exact type match, since
312
- // nearly always this is not meaningful to the user.
313
- completion_ty == expected_type && !expected_type. is_unit ( )
314
- } else {
315
- false
310
+ match ctx. expected_type . as_ref ( ) {
311
+ Some ( expected_type) => {
312
+ // We don't ever consider unit type to be an exact type match, since
313
+ // nearly always this is not meaningful to the user.
314
+ completion_ty == expected_type && !expected_type. is_unit ( )
315
+ }
316
+ None => false ,
316
317
}
317
318
}
318
319
@@ -323,27 +324,20 @@ fn compute_exact_name_match(ctx: &CompletionContext, completion_name: impl Into<
323
324
}
324
325
325
326
fn compute_ref_match ( ctx : & CompletionContext , completion_ty : & hir:: Type ) -> Option < Mutability > {
326
- let mut ref_match = None ;
327
- if let Some ( expected_type) = & ctx. expected_type {
328
- if completion_ty != expected_type {
329
- if let Some ( expected_type_without_ref) = expected_type. remove_ref ( ) {
330
- if completion_ty == & expected_type_without_ref
331
- || completion_ty
332
- . autoderef ( ctx. db )
333
- . any ( |deref_ty| deref_ty == expected_type_without_ref)
334
- {
335
- cov_mark:: hit!( suggest_ref) ;
336
- let mutability = if expected_type. is_mutable_reference ( ) {
337
- Mutability :: Mut
338
- } else {
339
- Mutability :: Shared
340
- } ;
341
- ref_match = Some ( mutability) ;
342
- }
343
- }
344
- }
345
- } ;
346
- ref_match
327
+ let expected_type = ctx. expected_type . as_ref ( ) ?;
328
+ if completion_ty != expected_type {
329
+ let expected_type_without_ref = expected_type. remove_ref ( ) ?;
330
+ if completion_ty. autoderef ( ctx. db ) . any ( |deref_ty| deref_ty == expected_type_without_ref) {
331
+ cov_mark:: hit!( suggest_ref) ;
332
+ let mutability = if expected_type. is_mutable_reference ( ) {
333
+ Mutability :: Mut
334
+ } else {
335
+ Mutability :: Shared
336
+ } ;
337
+ return Some ( mutability) ;
338
+ } ;
339
+ }
340
+ None
347
341
}
348
342
349
343
#[ cfg( test) ]
0 commit comments