File tree 2 files changed +20
-1
lines changed
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> {
679
679
let lhs_ty = self . infer_expr ( * lhs, & lhs_expectation) ;
680
680
let lhs_ty = self . resolve_ty_shallow ( & lhs_ty) ;
681
681
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) ) ;
683
684
let rhs_ty = self . resolve_ty_shallow ( & rhs_ty) ;
684
685
685
686
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() {
257
257
) ;
258
258
}
259
259
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
+
260
278
#[ test]
261
279
fn coerce_fn_item_to_fn_ptr ( ) {
262
280
check_no_mismatches (
You can’t perform that action at this time.
0 commit comments