diff options
author | Jonas Schievink <[email protected]> | 2020-04-28 21:45:46 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-04-28 21:45:46 +0100 |
commit | 8cb139090f969c9e8f8eecf9ffe3cd89624526d5 (patch) | |
tree | d7d5af5bc5b7f0194c798c76e6d8e5f9043a4050 /crates/ra_hir | |
parent | 07f690ddf601eeff639ac83e0c9f5db1a895a47b (diff) |
Complete union fields after dot
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 27 |
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 | } |