@@ -39,11 +39,11 @@ pub(crate) fn render_struct_pat(
3939
4040 let db = ctx. db ( ) ;
4141
42- Some ( build_completion ( ctx, label, lookup, pat, strukt, strukt. ty ( db) ) )
42+ Some ( build_completion ( ctx, label, lookup, pat, strukt, strukt. ty ( db) , false ) )
4343}
4444
4545pub ( crate ) fn render_variant_pat (
46- mut ctx : RenderContext < ' _ > ,
46+ ctx : RenderContext < ' _ > ,
4747 pattern_ctx : & PatternContext ,
4848 path_ctx : Option < & PathCompletionCtx > ,
4949 variant : hir:: Variant ,
@@ -56,11 +56,6 @@ pub(crate) fn render_variant_pat(
5656 let ( visible_fields, fields_omitted) = visible_fields ( ctx. completion , & fields, variant) ?;
5757 let enum_ty = variant. parent_enum ( ctx. db ( ) ) . ty ( ctx. db ( ) ) ;
5858
59- // Missing in context of match statement completions
60- if pattern_ctx. missing_variants . contains ( & variant) {
61- ctx. is_variant_missing = Some ( true ) ;
62- }
63-
6459 let ( name, escaped_name) = match path {
6560 Some ( path) => ( path. unescaped ( ) . to_string ( ) . into ( ) , path. to_string ( ) . into ( ) ) ,
6661 None => {
@@ -89,7 +84,15 @@ pub(crate) fn render_variant_pat(
8984 }
9085 } ;
9186
92- Some ( build_completion ( ctx, label, lookup, pat, variant, enum_ty) )
87+ Some ( build_completion (
88+ ctx,
89+ label,
90+ lookup,
91+ pat,
92+ variant,
93+ enum_ty,
94+ pattern_ctx. missing_variants . contains ( & variant) ,
95+ ) )
9396}
9497
9598fn build_completion (
@@ -99,10 +102,12 @@ fn build_completion(
99102 pat : String ,
100103 def : impl HasAttrs + Copy ,
101104 adt_ty : hir:: Type ,
105+ // Missing in context of match statement completions
106+ is_variant_missing : bool ,
102107) -> CompletionItem {
103108 let mut relevance = ctx. completion_relevance ( ) ;
104109
105- if let Some ( true ) = ctx . is_variant_missing {
110+ if is_variant_missing {
106111 relevance. type_match = super :: compute_type_match ( ctx. completion , & adt_ty) ;
107112 }
108113
0 commit comments