aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-24 17:06:55 +0000
committerAleksey Kladov <[email protected]>2019-11-24 17:06:55 +0000
commit63e3ea38d3ff7ab69b968e8962f33e82a4f978fb (patch)
tree8f4d416bad74f75e43924981b1d2c2099ea50edc /crates/ra_hir/src/ty/infer
parentac9ba5eb32073c16608acaa04324e7dc46d303d6 (diff)
Don't redo field resolution in the IDE
Diffstat (limited to 'crates/ra_hir/src/ty/infer')
-rw-r--r--crates/ra_hir/src/ty/infer/expr.rs28
1 files changed, 15 insertions, 13 deletions
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs
index 20a7e9352..2996920c6 100644
--- a/crates/ra_hir/src/ty/infer/expr.rs
+++ b/crates/ra_hir/src/ty/infer/expr.rs
@@ -215,19 +215,21 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
215 215
216 let substs = ty.substs().unwrap_or_else(Substs::empty); 216 let substs = ty.substs().unwrap_or_else(Substs::empty);
217 for (field_idx, field) in fields.iter().enumerate() { 217 for (field_idx, field) in fields.iter().enumerate() {
218 let field_ty = def_id 218 let field_def = def_id.and_then(|it| match it.field(self.db, &field.name) {
219 .and_then(|it| match it.field(self.db, &field.name) { 219 Some(field) => Some(field),
220 Some(field) => Some(field), 220 None => {
221 None => { 221 self.push_diagnostic(InferenceDiagnostic::NoSuchField {
222 self.push_diagnostic(InferenceDiagnostic::NoSuchField { 222 expr: tgt_expr,
223 expr: tgt_expr, 223 field: field_idx,
224 field: field_idx, 224 });
225 }); 225 None
226 None 226 }
227 } 227 });
228 }) 228 if let Some(field_def) = field_def {
229 .map_or(Ty::Unknown, |field| field.ty(self.db)) 229 self.result.record_field_resolutions.insert(field.expr, field_def);
230 .subst(&substs); 230 }
231 let field_ty =
232 field_def.map_or(Ty::Unknown, |field| field.ty(self.db)).subst(&substs);
231 self.infer_expr_coerce(field.expr, &Expectation::has_type(field_ty)); 233 self.infer_expr_coerce(field.expr, &Expectation::has_type(field_ty));
232 } 234 }
233 if let Some(expr) = spread { 235 if let Some(expr) = spread {