diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index fe9149c9d..1bdcda069 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -988,20 +988,17 @@ impl Type { | |||
988 | 988 | ||
989 | pub fn fields(&self, db: &impl HirDatabase) -> Vec<(StructField, Type)> { | 989 | pub fn fields(&self, db: &impl HirDatabase) -> Vec<(StructField, Type)> { |
990 | if let Ty::Apply(a_ty) = &self.ty.value { | 990 | if let Ty::Apply(a_ty) = &self.ty.value { |
991 | match a_ty.ctor { | 991 | if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { |
992 | TypeCtor::Adt(AdtId::StructId(s)) => { | 992 | let var_def = s.into(); |
993 | let var_def = s.into(); | 993 | return db |
994 | return db | 994 | .field_types(var_def) |
995 | .field_types(var_def) | 995 | .iter() |
996 | .iter() | 996 | .map(|(local_id, ty)| { |
997 | .map(|(local_id, ty)| { | 997 | let def = StructField { parent: var_def.into(), id: local_id }; |
998 | let def = StructField { parent: var_def.into(), id: local_id }; | 998 | let ty = ty.clone().subst(&a_ty.parameters); |
999 | let ty = ty.clone().subst(&a_ty.parameters); | 999 | (def, self.derived(ty)) |
1000 | (def, self.derived(ty)) | 1000 | }) |
1001 | }) | 1001 | .collect(); |
1002 | .collect(); | ||
1003 | } | ||
1004 | _ => {} | ||
1005 | } | 1002 | } |
1006 | }; | 1003 | }; |
1007 | Vec::new() | 1004 | Vec::new() |
@@ -1010,14 +1007,11 @@ impl Type { | |||
1010 | pub fn tuple_fields(&self, _db: &impl HirDatabase) -> Vec<Type> { | 1007 | pub fn tuple_fields(&self, _db: &impl HirDatabase) -> Vec<Type> { |
1011 | let mut res = Vec::new(); | 1008 | let mut res = Vec::new(); |
1012 | if let Ty::Apply(a_ty) = &self.ty.value { | 1009 | if let Ty::Apply(a_ty) = &self.ty.value { |
1013 | match a_ty.ctor { | 1010 | if let TypeCtor::Tuple { .. } = a_ty.ctor { |
1014 | TypeCtor::Tuple { .. } => { | 1011 | for ty in a_ty.parameters.iter() { |
1015 | for ty in a_ty.parameters.iter() { | 1012 | let ty = ty.clone(); |
1016 | let ty = ty.clone(); | 1013 | res.push(self.derived(ty)); |
1017 | res.push(self.derived(ty)); | ||
1018 | } | ||
1019 | } | 1014 | } |
1020 | _ => {} | ||
1021 | } | 1015 | } |
1022 | }; | 1016 | }; |
1023 | res | 1017 | res |