From 4c29214bba65d23e18875bd060325c489be5a8e4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 17:09:02 +0200 Subject: Move computation of missing fields into hir --- crates/ra_hir/src/code_model.rs | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'crates/ra_hir/src/code_model.rs') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index c6f3bdb8e..9baebf643 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1027,8 +1027,16 @@ impl Type { ty: Ty, ) -> Option { let krate = resolver.krate()?; + Some(Type::new_with_resolver_inner(db, krate, resolver, ty)) + } + pub(crate) fn new_with_resolver_inner( + db: &dyn HirDatabase, + krate: CrateId, + resolver: &Resolver, + ty: Ty, + ) -> Type { let environment = TraitEnvironment::lower(db, &resolver); - Some(Type { krate, ty: InEnvironment { value: ty, environment } }) + Type { krate, ty: InEnvironment { value: ty, environment } } } fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { @@ -1152,27 +1160,6 @@ impl Type { res } - pub fn variant_fields( - &self, - db: &dyn HirDatabase, - def: VariantDef, - ) -> Vec<(StructField, Type)> { - // FIXME: check that ty and def match - match &self.ty.value { - Ty::Apply(a_ty) => { - let field_types = db.field_types(def.into()); - def.fields(db) - .into_iter() - .map(|it| { - let ty = field_types[it.id].clone().subst(&a_ty.parameters); - (it, self.derived(ty)) - }) - .collect() - } - _ => Vec::new(), - } - } - pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator + 'a { // There should be no inference vars in types passed here // FIXME check that? -- cgit v1.2.3