@@ -39,11 +39,11 @@ pub(crate) fn render_struct_pat(
39
39
40
40
let db = ctx. db ( ) ;
41
41
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 ) )
43
43
}
44
44
45
45
pub ( crate ) fn render_variant_pat (
46
- mut ctx : RenderContext < ' _ > ,
46
+ ctx : RenderContext < ' _ > ,
47
47
pattern_ctx : & PatternContext ,
48
48
path_ctx : Option < & PathCompletionCtx > ,
49
49
variant : hir:: Variant ,
@@ -56,11 +56,6 @@ pub(crate) fn render_variant_pat(
56
56
let ( visible_fields, fields_omitted) = visible_fields ( ctx. completion , & fields, variant) ?;
57
57
let enum_ty = variant. parent_enum ( ctx. db ( ) ) . ty ( ctx. db ( ) ) ;
58
58
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
-
64
59
let ( name, escaped_name) = match path {
65
60
Some ( path) => ( path. unescaped ( ) . to_string ( ) . into ( ) , path. to_string ( ) . into ( ) ) ,
66
61
None => {
@@ -89,7 +84,15 @@ pub(crate) fn render_variant_pat(
89
84
}
90
85
} ;
91
86
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
+ ) )
93
96
}
94
97
95
98
fn build_completion (
@@ -99,10 +102,12 @@ fn build_completion(
99
102
pat : String ,
100
103
def : impl HasAttrs + Copy ,
101
104
adt_ty : hir:: Type ,
105
+ // Missing in context of match statement completions
106
+ is_variant_missing : bool ,
102
107
) -> CompletionItem {
103
108
let mut relevance = ctx. completion_relevance ( ) ;
104
109
105
- if let Some ( true ) = ctx . is_variant_missing {
110
+ if is_variant_missing {
106
111
relevance. type_match = super :: compute_type_match ( ctx. completion , & adt_ty) ;
107
112
}
108
113
0 commit comments