Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer.rs')
| -rw-r--r-- | crates/hir-ty/src/infer.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 3c258e3c4c..1b2ef2aef3 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -134,6 +134,9 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer .unwrap() .0; } + DefWithBodyId::FieldId(f) => { + ctx.collect_field(f); + } } ctx.infer_body(); @@ -910,6 +913,19 @@ impl<'a> InferenceContext<'a> { self.return_ty = return_ty; } + fn collect_field(&mut self, field: FieldId) { + let variant_data = field.parent.variant_data(self.db.upcast()); + let field_data = &variant_data.fields()[field.local_id]; + let types_map = variant_data.types_map(); + let return_ty = + self.make_ty(field_data.type_ref, types_map, InferenceTyDiagnosticSource::Signature); + + // Field default value exprs might be defining usage sites of TAITs. + self.make_tait_coercion_table(iter::once(&return_ty)); + + self.return_ty = return_ty; + } + fn collect_fn(&mut self, func: FunctionId) { let data = self.db.function_data(func); let mut param_tys = |