@@ -36,6 +36,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
36
36
) -> Ty < ' tcx > {
37
37
let ( lhs_ty, rhs_ty, return_ty) =
38
38
self . check_overloaded_binop ( expr, lhs, rhs, op, IsAssign :: Yes , expected) ;
39
+ let lhs_ty = self . try_structurally_resolve_type ( lhs. span , lhs_ty) ;
40
+ let rhs_ty = self . try_structurally_resolve_type ( rhs. span , rhs_ty) ;
39
41
40
42
let ty =
41
43
if !lhs_ty. is_ty_var ( ) && !rhs_ty. is_ty_var ( ) && is_builtin_binop ( lhs_ty, rhs_ty, op) {
@@ -232,10 +234,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
232
234
}
233
235
} ;
234
236
235
- // Guide inference on the lhs ty if necessary.
236
- self . select_obligations_where_possible ( |_| { } ) ;
237
- let lhs_ty = self . resolve_vars_if_possible ( lhs_ty) ;
238
-
239
237
// N.B., as we have not yet type-checked the RHS, we don't have the
240
238
// type at hand. Make a variable to represent it. The whole reason
241
239
// for this indirection is so that, below, we can check the expr
@@ -253,7 +251,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
253
251
254
252
// see `NB` above
255
253
let rhs_ty = self . check_expr_coercible_to_type ( rhs_expr, rhs_ty_var, Some ( lhs_expr) ) ;
256
- let rhs_ty = self . resolve_vars_with_obligations ( rhs_ty) ;
257
254
258
255
let return_ty = match result {
259
256
Ok ( method) => {
@@ -299,6 +296,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
299
296
Ty :: new_misc_error ( self . tcx )
300
297
}
301
298
Err ( errors) => {
299
+ let lhs_ty = self . try_structurally_resolve_type ( lhs_expr. span , lhs_ty) ;
300
+ let rhs_ty = self . try_structurally_resolve_type ( rhs_expr. span , rhs_ty) ;
301
+
302
302
let ( _, trait_def_id) =
303
303
lang_item_for_op ( self . tcx , Op :: Binary ( op, is_assign) , op. span ) ;
304
304
let missing_trait = trait_def_id
0 commit comments