@@ -43,7 +43,7 @@ pub(crate) fn render_struct_pat(
4343}
4444
4545pub ( crate ) fn render_variant_pat (
46- ctx : RenderContext < ' _ > ,
46+ mut ctx : RenderContext < ' _ > ,
4747 pattern_ctx : & PatternContext ,
4848 path_ctx : Option < & PathCompletionCtx > ,
4949 variant : hir:: Variant ,
@@ -56,6 +56,11 @@ 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+
5964 let ( name, escaped_name) = match path {
6065 Some ( path) => ( path. unescaped ( ) . to_string ( ) . into ( ) , path. to_string ( ) . into ( ) ) ,
6166 None => {
@@ -97,7 +102,9 @@ fn build_completion(
97102) -> CompletionItem {
98103 let mut relevance = ctx. completion_relevance ( ) ;
99104
100- relevance. type_match = super :: compute_type_match ( ctx. completion , & adt_ty) ;
105+ if let Some ( true ) = ctx. is_variant_missing {
106+ relevance. type_match = super :: compute_type_match ( ctx. completion , & adt_ty) ;
107+ }
101108
102109 let mut item = CompletionItem :: new ( CompletionItemKind :: Binding , ctx. source_range ( ) , label) ;
103110 item. set_documentation ( ctx. docs ( def) )
0 commit comments