Skip to content

Commit 234cb7b

Browse files
More
1 parent a774bd1 commit 234cb7b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1860,8 +1860,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18601860
base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>,
18611861
) {
18621862
let tcx = self.tcx;
1863+
self.select_obligations_where_possible(|_| {});
18631864

1864-
let adt_ty = self.try_structurally_resolve_type(span, adt_ty);
18651865
let adt_ty_hint = expected.only_has_type(self).and_then(|expected| {
18661866
self.fudge_inference_if_ok(|| {
18671867
let ocx = ObligationCtxt::new(self);

compiler/rustc_hir_typeck/src/op.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3636
) -> Ty<'tcx> {
3737
let (lhs_ty, rhs_ty, return_ty) =
3838
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);
3941

4042
let ty =
4143
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> {
232234
}
233235
};
234236

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-
239237
// N.B., as we have not yet type-checked the RHS, we don't have the
240238
// type at hand. Make a variable to represent it. The whole reason
241239
// for this indirection is so that, below, we can check the expr
@@ -253,7 +251,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
253251

254252
// see `NB` above
255253
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);
257254

258255
let return_ty = match result {
259256
Ok(method) => {
@@ -299,6 +296,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
299296
Ty::new_misc_error(self.tcx)
300297
}
301298
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+
302302
let (_, trait_def_id) =
303303
lang_item_for_op(self.tcx, Op::Binary(op, is_assign), op.span);
304304
let missing_trait = trait_def_id

0 commit comments

Comments
 (0)