Skip to content

Commit bbe755c

Browse files
committed
Switch from using At::eq to InferCtxt::can_eq and demand_eqtype_with_origin
I doubt this changes anything, I was just trying to fix an issue with error messages and ended up doing this along with other things. Committing it separately so I can undo it easily.
1 parent 2369746 commit bbe755c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use check::{Inherited, FnCtxt};
1212
use constrained_type_params::{identify_constrained_type_params, Parameter};
1313

1414
use hir::def_id::DefId;
15-
use rustc::infer::InferOk;
1615
use rustc::traits::{self, ObligationCauseCode};
1716
use rustc::ty::{self, Ty, TyCtxt};
1817
use rustc::ty::util::ExplicitSelf;
@@ -478,7 +477,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
478477
let self_arg_ty = sig.inputs()[0];
479478

480479
let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver);
481-
let eq = |expected, actual| fcx.at(&cause, fcx.param_env).eq(expected, actual);
482480
let self_arg_ty = fcx.normalize_associated_types_in(span, &self_arg_ty);
483481
let self_arg_ty = fcx.liberate_late_bound_regions(
484482
method.def_id,
@@ -491,9 +489,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
491489
if let Some((potential_self_ty, _)) = autoderef.next() {
492490
debug!("check_method_receiver: potential self type `{:?}` to match `{:?}`", potential_self_ty, self_ty);
493491

494-
if let Ok(InferOk { obligations, value: () }) = eq(self_ty, potential_self_ty) {
495-
fcx.register_predicates(obligations);
492+
if fcx.infcx.can_eq(fcx.param_env, self_ty, potential_self_ty).is_ok() {
496493
autoderef.finalize();
494+
if let Some(mut err) = fcx.demand_eqtype_with_origin(&cause, self_ty, potential_self_ty) {
495+
err.emit();
496+
}
497497
break
498498
}
499499
} else {

0 commit comments

Comments
 (0)