about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/ide-completion/src/render.rs13
-rw-r--r--crates/ide-completion/src/render/pattern.rs23
2 files changed, 15 insertions, 21 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index eb2df395c4d..86302cb0678 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -32,22 +32,11 @@ pub(crate) struct RenderContext<'a> {
     completion: &'a CompletionContext<'a>,
     is_private_editable: bool,
     import_to_add: Option<LocatedImport>,
-    // For variants which are missing
-    // in match completion context
-    //
-    // Option -> only applicable for enums
-    // bool -> is enum variant missing or not?
-    is_variant_missing: Option<bool>,
 }
 
 impl<'a> RenderContext<'a> {
     pub(crate) fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> {
-        RenderContext {
-            completion,
-            is_private_editable: false,
-            import_to_add: None,
-            is_variant_missing: None,
-        }
+        RenderContext { completion, is_private_editable: false, import_to_add: None }
     }
 
     pub(crate) fn private_editable(mut self, private_editable: bool) -> Self {
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index d70f02127d5..fcc78998153 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -39,11 +39,11 @@ pub(crate) fn render_struct_pat(
 
     let db = ctx.db();
 
-    Some(build_completion(ctx, label, lookup, pat, strukt, strukt.ty(db)))
+    Some(build_completion(ctx, label, lookup, pat, strukt, strukt.ty(db), false))
 }
 
 pub(crate) fn render_variant_pat(
-    mut ctx: RenderContext<'_>,
+    ctx: RenderContext<'_>,
     pattern_ctx: &PatternContext,
     path_ctx: Option<&PathCompletionCtx>,
     variant: hir::Variant,
@@ -56,11 +56,6 @@ pub(crate) fn render_variant_pat(
     let (visible_fields, fields_omitted) = visible_fields(ctx.completion, &fields, variant)?;
     let enum_ty = variant.parent_enum(ctx.db()).ty(ctx.db());
 
-    // Missing in context of match statement completions
-    if pattern_ctx.missing_variants.contains(&variant) {
-        ctx.is_variant_missing = Some(true);
-    }
-
     let (name, escaped_name) = match path {
         Some(path) => (path.unescaped().to_string().into(), path.to_string().into()),
         None => {
@@ -89,7 +84,15 @@ pub(crate) fn render_variant_pat(
         }
     };
 
-    Some(build_completion(ctx, label, lookup, pat, variant, enum_ty))
+    Some(build_completion(
+        ctx,
+        label,
+        lookup,
+        pat,
+        variant,
+        enum_ty,
+        pattern_ctx.missing_variants.contains(&variant),
+    ))
 }
 
 fn build_completion(
@@ -99,10 +102,12 @@ fn build_completion(
     pat: String,
     def: impl HasAttrs + Copy,
     adt_ty: hir::Type,
+    // Missing in context of match statement completions
+    is_variant_missing: bool,
 ) -> CompletionItem {
     let mut relevance = ctx.completion_relevance();
 
-    if let Some(true) = ctx.is_variant_missing {
+    if is_variant_missing {
         relevance.type_match = super::compute_type_match(ctx.completion, &adt_ty);
     }