aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/completion/src/render/pattern.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/completion/src/render/pattern.rs b/crates/completion/src/render/pattern.rs
index cfe2116bd..2d1600105 100644
--- a/crates/completion/src/render/pattern.rs
+++ b/crates/completion/src/render/pattern.rs
@@ -1,6 +1,6 @@
1//! Renderer for patterns. 1//! Renderer for patterns.
2 2
3use hir::{db::HirDatabase, HasVisibility, Name, StructKind}; 3use hir::{db::HirDatabase, HasAttrs, HasVisibility, Name, StructKind};
4use itertools::Itertools; 4use itertools::Itertools;
5 5
6use crate::{ 6use crate::{
@@ -27,7 +27,8 @@ pub(crate) fn render_struct_pat(
27 // Matching a struct without matching its fields is pointless, unlike matching a Variant without its fields 27 // Matching a struct without matching its fields is pointless, unlike matching a Variant without its fields
28 return None; 28 return None;
29 } 29 }
30 let fields_omitted = n_fields - fields.len() > 0; 30 let fields_omitted =
31 n_fields - fields.len() > 0 || strukt.attrs(ctx.db()).by_key("non_exhaustive").exists();
31 32
32 let name = local_name.unwrap_or_else(|| strukt.name(ctx.db())).to_string(); 33 let name = local_name.unwrap_or_else(|| strukt.name(ctx.db())).to_string();
33 let pat = render_pat(&ctx, &name, strukt.kind(ctx.db()), &fields, fields_omitted)?; 34 let pat = render_pat(&ctx, &name, strukt.kind(ctx.db()), &fields, fields_omitted)?;
@@ -60,7 +61,8 @@ pub(crate) fn render_variant_pat(
60 .filter(|field| field.is_visible_from(ctx.db(), module)) 61 .filter(|field| field.is_visible_from(ctx.db(), module))
61 .collect::<Vec<_>>(); 62 .collect::<Vec<_>>();
62 63
63 let fields_omitted = n_fields - fields.len() > 0; 64 let fields_omitted =
65 n_fields - fields.len() > 0 || variant.attrs(ctx.db()).by_key("non_exhaustive").exists();
64 66
65 let name = local_name.unwrap_or_else(|| variant.name(ctx.db())).to_string(); 67 let name = local_name.unwrap_or_else(|| variant.name(ctx.db())).to_string();
66 let pat = render_pat(&ctx, &name, variant.kind(ctx.db()), &fields, fields_omitted)?; 68 let pat = render_pat(&ctx, &name, variant.kind(ctx.db()), &fields, fields_omitted)?;