aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs31
1 files changed, 9 insertions, 22 deletions
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 {
1027 ty: Ty, 1027 ty: Ty,
1028 ) -> Option<Type> { 1028 ) -> Option<Type> {
1029 let krate = resolver.krate()?; 1029 let krate = resolver.krate()?;
1030 Some(Type::new_with_resolver_inner(db, krate, resolver, ty))
1031 }
1032 pub(crate) fn new_with_resolver_inner(
1033 db: &dyn HirDatabase,
1034 krate: CrateId,
1035 resolver: &Resolver,
1036 ty: Ty,
1037 ) -> Type {
1030 let environment = TraitEnvironment::lower(db, &resolver); 1038 let environment = TraitEnvironment::lower(db, &resolver);
1031 Some(Type { krate, ty: InEnvironment { value: ty, environment } }) 1039 Type { krate, ty: InEnvironment { value: ty, environment } }
1032 } 1040 }
1033 1041
1034 fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { 1042 fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type {
@@ -1152,27 +1160,6 @@ impl Type {
1152 res 1160 res
1153 } 1161 }
1154 1162
1155 pub fn variant_fields(
1156 &self,
1157 db: &dyn HirDatabase,
1158 def: VariantDef,
1159 ) -> Vec<(StructField, Type)> {
1160 // FIXME: check that ty and def match
1161 match &self.ty.value {
1162 Ty::Apply(a_ty) => {
1163 let field_types = db.field_types(def.into());
1164 def.fields(db)
1165 .into_iter()
1166 .map(|it| {
1167 let ty = field_types[it.id].clone().subst(&a_ty.parameters);
1168 (it, self.derived(ty))
1169 })
1170 .collect()
1171 }
1172 _ => Vec::new(),
1173 }
1174 }
1175
1176 pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator<Item = Type> + 'a { 1163 pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator<Item = Type> + 'a {
1177 // There should be no inference vars in types passed here 1164 // There should be no inference vars in types passed here
1178 // FIXME check that? 1165 // FIXME check that?