aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 471bdc387..ddc7d262a 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -44,8 +44,7 @@ use crate::{
44 db::HirDatabase, 44 db::HirDatabase,
45 expr::{BindingAnnotation, Body, ExprId, PatId}, 45 expr::{BindingAnnotation, Body, ExprId, PatId},
46 ty::infer::diagnostics::InferenceDiagnostic, 46 ty::infer::diagnostics::InferenceDiagnostic,
47 Adt, AssocItem, DefWithBody, FloatTy, Function, HasBody, IntTy, Path, StructField, Trait, 47 Adt, AssocItem, DefWithBody, FloatTy, Function, IntTy, Path, StructField, Trait, VariantDef,
48 VariantDef,
49}; 48};
50 49
51macro_rules! ty_app { 50macro_rules! ty_app {
@@ -126,6 +125,8 @@ pub struct InferenceResult {
126 method_resolutions: FxHashMap<ExprId, Function>, 125 method_resolutions: FxHashMap<ExprId, Function>,
127 /// For each field access expr, records the field it resolves to. 126 /// For each field access expr, records the field it resolves to.
128 field_resolutions: FxHashMap<ExprId, StructField>, 127 field_resolutions: FxHashMap<ExprId, StructField>,
128 /// For each field in record literal, records the field it resolves to.
129 record_field_resolutions: FxHashMap<ExprId, StructField>,
129 /// For each struct literal, records the variant it resolves to. 130 /// For each struct literal, records the variant it resolves to.
130 variant_resolutions: FxHashMap<ExprOrPatId, VariantDef>, 131 variant_resolutions: FxHashMap<ExprOrPatId, VariantDef>,
131 /// For each associated item record what it resolves to 132 /// For each associated item record what it resolves to
@@ -143,6 +144,9 @@ impl InferenceResult {
143 pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> { 144 pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> {
144 self.field_resolutions.get(&expr).copied() 145 self.field_resolutions.get(&expr).copied()
145 } 146 }
147 pub fn record_field_resolution(&self, expr: ExprId) -> Option<StructField> {
148 self.record_field_resolutions.get(&expr).copied()
149 }
146 pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantDef> { 150 pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantDef> {
147 self.variant_resolutions.get(&id.into()).copied() 151 self.variant_resolutions.get(&id.into()).copied()
148 } 152 }
@@ -216,7 +220,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
216 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver), 220 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver),
217 db, 221 db,
218 owner, 222 owner,
219 body: owner.body(db), 223 body: db.body(owner.into()),
220 resolver, 224 resolver,
221 } 225 }
222 } 226 }
@@ -565,7 +569,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
565 569
566 fn collect_fn(&mut self, data: &FunctionData) { 570 fn collect_fn(&mut self, data: &FunctionData) {
567 let body = Arc::clone(&self.body); // avoid borrow checker problem 571 let body = Arc::clone(&self.body); // avoid borrow checker problem
568 for (type_ref, pat) in data.params.iter().zip(body.params()) { 572 for (type_ref, pat) in data.params.iter().zip(body.params.iter()) {
569 let ty = self.make_ty(type_ref); 573 let ty = self.make_ty(type_ref);
570 574
571 self.infer_pat(*pat, &ty, BindingMode::default()); 575 self.infer_pat(*pat, &ty, BindingMode::default());
@@ -574,7 +578,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
574 } 578 }
575 579
576 fn infer_body(&mut self) { 580 fn infer_body(&mut self) {
577 self.infer_expr(self.body.body_expr(), &Expectation::has_type(self.return_ty.clone())); 581 self.infer_expr(self.body.body_expr, &Expectation::has_type(self.return_ty.clone()));
578 } 582 }
579 583
580 fn resolve_into_iter_item(&self) -> Option<TypeAlias> { 584 fn resolve_into_iter_item(&self) -> Option<TypeAlias> {