@@ -59,7 +59,11 @@ pub(crate) fn complete_record_expr_fields(
5959 }
6060 _ => {
6161 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+ }
6367 if dot_prefix {
6468 cov_mark:: hit!( functional_update_one_dot) ;
6569 let mut item =
@@ -78,14 +82,14 @@ pub(crate) fn add_default_update(
7882 acc : & mut Completions ,
7983 ctx : & CompletionContext < ' _ > ,
8084 ty : Option < hir:: TypeInfo > ,
81- missing_fields : & [ ( hir:: Field , hir:: Type ) ] ,
8285) {
8386 let default_trait = ctx. famous_defs ( ) . core_default_Default ( ) ;
84- let impl_default_trait = default_trait
87+ let impls_default_trait = default_trait
8588 . zip ( ty. as_ref ( ) )
8689 . 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 {
8891 // 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
8993 let completion_text = "..Default::default()" ;
9094 let mut item = CompletionItem :: new ( SymbolKind :: Field , ctx. source_range ( ) , completion_text) ;
9195 let completion_text =
0 commit comments