@@ -59,7 +59,11 @@ pub(crate) fn complete_record_expr_fields(
59
59
}
60
60
_ => {
61
61
let missing_fields = ctx. sema . record_literal_missing_fields ( record_expr) ;
62
- add_default_update ( acc, ctx, ty, & missing_fields) ;
62
+
63
+ if !missing_fields. is_empty ( ) {
64
+ cov_mark:: hit!( functional_update_field) ;
65
+ add_default_update ( acc, ctx, ty) ;
66
+ }
63
67
if dot_prefix {
64
68
cov_mark:: hit!( functional_update_one_dot) ;
65
69
let mut item =
@@ -78,14 +82,14 @@ pub(crate) fn add_default_update(
78
82
acc : & mut Completions ,
79
83
ctx : & CompletionContext < ' _ > ,
80
84
ty : Option < hir:: TypeInfo > ,
81
- missing_fields : & [ ( hir:: Field , hir:: Type ) ] ,
82
85
) {
83
86
let default_trait = ctx. famous_defs ( ) . core_default_Default ( ) ;
84
- let impl_default_trait = default_trait
87
+ let impls_default_trait = default_trait
85
88
. zip ( ty. as_ref ( ) )
86
89
. map_or ( false , |( default_trait, ty) | ty. original . impls_trait ( ctx. db , default_trait, & [ ] ) ) ;
87
- if impl_default_trait && !missing_fields . is_empty ( ) {
90
+ if impls_default_trait {
88
91
// FIXME: This should make use of scope_def like completions so we get all the other goodies
92
+ // that is we should handle this like actually completing the default function
89
93
let completion_text = "..Default::default()" ;
90
94
let mut item = CompletionItem :: new ( SymbolKind :: Field , ctx. source_range ( ) , completion_text) ;
91
95
let completion_text =
0 commit comments