diff options
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 0a141b9cb..8ac4cf89a 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -12,6 +12,7 @@ use hir_def::{ | |||
12 | }; | 12 | }; |
13 | use hir_expand::name::{name, Name}; | 13 | use hir_expand::name::{name, Name}; |
14 | use syntax::ast::RangeOp; | 14 | use syntax::ast::RangeOp; |
15 | use test_utils::mark; | ||
15 | 16 | ||
16 | use crate::{ | 17 | use crate::{ |
17 | autoderef, method_resolution, op, | 18 | autoderef, method_resolution, op, |
@@ -531,13 +532,22 @@ impl<'a> InferenceContext<'a> { | |||
531 | _ => Expectation::none(), | 532 | _ => Expectation::none(), |
532 | }; | 533 | }; |
533 | let lhs_ty = self.infer_expr(*lhs, &lhs_expectation); | 534 | 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()); | 535 | 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)); | 536 | let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(rhs_expectation)); |
538 | 537 | ||
539 | // FIXME: similar as above, return ty is often associated trait type | 538 | 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) | 539 | |
540 | if ret == Ty::Unknown { | ||
541 | mark::hit!(infer_expr_inner_binary_operator_overload); | ||
542 | |||
543 | self.resolve_associated_type_with_params( | ||
544 | lhs_ty, | ||
545 | self.resolve_binary_op_output(op), | ||
546 | &[rhs_ty], | ||
547 | ) | ||
548 | } else { | ||
549 | ret | ||
550 | } | ||
541 | } | 551 | } |
542 | _ => Ty::Unknown, | 552 | _ => Ty::Unknown, |
543 | }, | 553 | }, |