From 236974619f79661e4f58669c385279f46c6830cf Mon Sep 17 00:00:00 2001 From: Michael Hewson Date: Wed, 8 Nov 2017 08:24:33 -0500 Subject: [PATCH] normalize associated types in both self_ty and self_arg_ty I was only doing it for self_arg_ty, and ended up causing run-pass/associated-types-projection-from-known-type-in-impl.rs to fail. --- src/librustc_typeck/check/wfcheck.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b2a085bc21c1..45e8d2ffb851 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -469,10 +469,22 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { debug!("check_method_receiver: sig={:?}", sig); + let self_ty = fcx.normalize_associated_types_in(span, &self_ty); + let self_ty = fcx.liberate_late_bound_regions( + method.def_id, + &ty::Binder(self_ty) + ); + let self_arg_ty = sig.inputs()[0]; let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver); let eq = |expected, actual| fcx.at(&cause, fcx.param_env).eq(expected, actual); + let self_arg_ty = fcx.normalize_associated_types_in(span, &self_arg_ty); + let self_arg_ty = fcx.liberate_late_bound_regions( + method.def_id, + &ty::Binder(self_arg_ty) + ); + let mut autoderef = fcx.autoderef(span, self_arg_ty); loop { @@ -484,7 +496,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { autoderef.finalize(); break } - } else { fcx.tcx.sess.diagnostic().mut_span_err(span, &format!("invalid `self` type: {:?}", self_arg_ty)) .note(&format!("type must be `{:?}` or a type that dereferences to it`", self_ty))