aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-28 22:17:03 +0100
committerGitHub <[email protected]>2020-04-28 22:17:03 +0100
commit549ce9a9cf25efa3eba6549f96b2e43bc640faa9 (patch)
treed10c38188fa278500dce9041bccd54b8b3006472 /crates/ra_hir
parent0d7c9974b0e48de95b9ed016ef2d42dc11492831 (diff)
parent8cb139090f969c9e8f8eecf9ffe3cd89624526d5 (diff)
Merge #4198
4198: Complete union fields after dot r=matklad a=jonas-schievink Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-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 }