From 5fe19d2fbd2daa05b2cd3b1ebb6fa926e9d86c36 Mon Sep 17 00:00:00 2001 From: Ekaterina Babshukova Date: Sun, 21 Jul 2019 14:11:45 +0300 Subject: provide completion in struct patterns --- .../ra_ide_api/src/completion/complete_struct_literal.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide_api/src/completion/complete_struct_literal.rs') diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index 9410f740f..6aa41f498 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs @@ -1,23 +1,22 @@ -use hir::{Substs, Ty}; +use hir::Substs; use crate::completion::{CompletionContext, Completions}; /// Complete fields in fields literals. pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { let (ty, variant) = match ctx.struct_lit_syntax.as_ref().and_then(|it| { - Some((ctx.analyzer.type_of(ctx.db, &it.clone().into())?, ctx.analyzer.resolve_variant(it)?)) + Some(( + ctx.analyzer.type_of(ctx.db, &it.clone().into())?, + ctx.analyzer.resolve_struct_literal(it)?, + )) }) { Some(it) => it, _ => return, }; - - let ty_substs = match ty { - Ty::Apply(it) => it.parameters, - _ => Substs::empty(), - }; + let substs = &ty.substs().unwrap_or_else(Substs::empty); for field in variant.fields(ctx.db) { - acc.add_field(ctx, field, &ty_substs); + acc.add_field(ctx, field, substs); } } -- cgit v1.2.3