From 3f796fea9fab0222913f9f895af78b80c4c7660b Mon Sep 17 00:00:00 2001 From: Lukas Tobias Wirth Date: Wed, 5 May 2021 22:55:12 +0200 Subject: simplify --- crates/ide_completion/src/completions/unqualified_path.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/ide_completion/src/completions/unqualified_path.rs') diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 1b8b063e7..7875500c1 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -17,8 +17,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC return; } - if let Some(ty) = &ctx.expected_type { - super::complete_enum_variants(acc, ctx, ty, |acc, ctx, variant, path| { + if let Some(hir::Adt::Enum(e)) = + ctx.expected_type.as_ref().and_then(|ty| ty.strip_references().as_adt()) + { + super::complete_enum_variants(acc, ctx, e, |acc, ctx, variant, path| { acc.add_qualified_enum_variant(ctx, variant, path) }); } -- cgit v1.2.3