From 37d0c722ef3d6b22fded312474db8520bd48126f Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Tue, 15 Mar 2022 21:14:02 +0800 Subject: [PATCH] Complete associated consts in patterns Signed-off-by: hi-rustin --- .../ide_completion/src/completions/pattern.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs index 6c17da07d6f..7926db8acf4 100644 --- a/crates/ide_completion/src/completions/pattern.rs +++ b/crates/ide_completion/src/completions/pattern.rs @@ -165,12 +165,19 @@ fn pattern_path_completion( ctx.module, None, |item| { - // Note associated consts cannot be referenced in patterns - if let AssocItem::TypeAlias(ta) = item { - // We might iterate candidates of a trait multiple times here, so deduplicate them. - if seen.insert(item) { - acc.add_type_alias(ctx, ta); + match item { + AssocItem::TypeAlias(ta) => { + // We might iterate candidates of a trait multiple times here, so deduplicate them. + if seen.insert(item) { + acc.add_type_alias(ctx, ta); + } } + AssocItem::Const(c) => { + if seen.insert(item) { + acc.add_const(ctx, c); + } + } + _ => {} } None::<()> },