aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index fb788736d..3fb419571 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1157,18 +1157,21 @@ impl Type {
1157 1157
1158 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> { 1158 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
1159 if let Ty::Apply(a_ty) = &self.ty.value { 1159 if let Ty::Apply(a_ty) = &self.ty.value {
1160 if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { 1160 let variant_id = match a_ty.ctor {
1161 let var_def = s.into(); 1161 TypeCtor::Adt(AdtId::StructId(s)) => s.into(),
1162 return db 1162 TypeCtor::Adt(AdtId::UnionId(u)) => u.into(),
1163 .field_types(var_def) 1163 _ => return Vec::new(),
1164 .iter() 1164 };
1165 .map(|(local_id, ty)| { 1165
1166 let def = Field { parent: var_def.into(), id: local_id }; 1166 return db
1167 let ty = ty.clone().subst(&a_ty.parameters); 1167 .field_types(variant_id)
1168 (def, self.derived(ty)) 1168 .iter()
1169 }) 1169 .map(|(local_id, ty)| {
1170 .collect(); 1170 let def = Field { parent: variant_id.into(), id: local_id };
1171 } 1171 let ty = ty.clone().subst(&a_ty.parameters);
1172 (def, self.derived(ty))
1173 })
1174 .collect();
1172 }; 1175 };
1173 Vec::new() 1176 Vec::new()
1174 } 1177 }