File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -679,7 +679,8 @@ impl<'a> InferenceContext<'a> {
679679 let lhs_ty = self . infer_expr ( * lhs, & lhs_expectation) ;
680680 let lhs_ty = self . resolve_ty_shallow ( & lhs_ty) ;
681681 let rhs_expectation = op:: binary_op_rhs_expectation ( * op, lhs_ty. clone ( ) ) ;
682- let rhs_ty = self . infer_expr ( * rhs, & Expectation :: has_type ( rhs_expectation) ) ;
682+ let rhs_ty =
683+ self . infer_expr_coerce ( * rhs, & Expectation :: has_type ( rhs_expectation) ) ;
683684 let rhs_ty = self . resolve_ty_shallow ( & rhs_ty) ;
684685
685686 let ret = op:: binary_op_return_ty ( * op, lhs_ty. clone ( ) , rhs_ty. clone ( ) ) ;
Original file line number Diff line number Diff line change @@ -257,6 +257,24 @@ fn foo() {
257257 ) ;
258258}
259259
260+ #[ test]
261+ fn assign_coerce ( ) {
262+ check_no_mismatches (
263+ r"
264+ //- minicore: deref
265+ struct String;
266+ impl core::ops::Deref for String { type Target = str; }
267+ fn g(_text: &str) {}
268+ fn f(text: &str) {
269+ let mut text = text;
270+ let tmp = String;
271+ text = &tmp;
272+ g(text);
273+ }
274+ " ,
275+ ) ;
276+ }
277+
260278#[ test]
261279fn coerce_fn_item_to_fn_ptr ( ) {
262280 check_no_mismatches (
You can’t perform that action at this time.
0 commit comments