Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/render/pattern.rs')
-rw-r--r--crates/ide-completion/src/render/pattern.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index 37c65abba9..d70f02127d 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -43,7 +43,7 @@ pub(crate) fn render_struct_pat(
}
pub(crate) fn render_variant_pat(
- ctx: RenderContext<'_>,
+ mut ctx: RenderContext<'_>,
pattern_ctx: &PatternContext,
path_ctx: Option<&PathCompletionCtx>,
variant: hir::Variant,
@@ -56,6 +56,11 @@ 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 => {
@@ -97,7 +102,9 @@ fn build_completion(
) -> CompletionItem {
let mut relevance = ctx.completion_relevance();
- relevance.type_match = super::compute_type_match(ctx.completion, &adt_ty);
+ if let Some(true) = ctx.is_variant_missing {
+ relevance.type_match = super::compute_type_match(ctx.completion, &adt_ty);
+ }
let mut item = CompletionItem::new(CompletionItemKind::Binding, ctx.source_range(), label);
item.set_documentation(ctx.docs(def))