diff options
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 0a141b9cb..8cc0d56d3 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -531,13 +531,20 @@ impl<'a> InferenceContext<'a> { | |||
531 | _ => Expectation::none(), | 531 | _ => Expectation::none(), |
532 | }; | 532 | }; |
533 | let lhs_ty = self.infer_expr(*lhs, &lhs_expectation); | 533 | let lhs_ty = self.infer_expr(*lhs, &lhs_expectation); |
534 | // FIXME: find implementation of trait corresponding to operation | ||
535 | // symbol and resolve associated `Output` type | ||
536 | let rhs_expectation = op::binary_op_rhs_expectation(*op, lhs_ty.clone()); | 534 | let rhs_expectation = op::binary_op_rhs_expectation(*op, lhs_ty.clone()); |
537 | let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(rhs_expectation)); | 535 | let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(rhs_expectation)); |
538 | 536 | ||
539 | // FIXME: similar as above, return ty is often associated trait type | 537 | let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone()); |
540 | op::binary_op_return_ty(*op, lhs_ty, rhs_ty) | 538 | |
539 | if ret == Ty::Unknown { | ||
540 | self.resolve_associated_type_with_params( | ||
541 | lhs_ty, | ||
542 | self.resolve_binary_op_output(op), | ||
543 | &[rhs_ty], | ||
544 | ) | ||
545 | } else { | ||
546 | ret | ||
547 | } | ||
541 | } | 548 | } |
542 | _ => Ty::Unknown, | 549 | _ => Ty::Unknown, |
543 | }, | 550 | }, |