about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Hewson <michael@michaelhewson.ca>2017-11-08 08:24:33 -0500
committerMichael Hewson <michael@michaelhewson.ca>2017-11-08 08:24:33 -0500
commit236974619f79661e4f58669c385279f46c6830cf (patch)
tree84cec757327fd70f493ef99ecebaa4c4ae5d1609 /src
parent3902643c27e961baf79240f0d489f354ea880ffb (diff)
downloadrust-236974619f79661e4f58669c385279f46c6830cf.tar.gz
rust-236974619f79661e4f58669c385279f46c6830cf.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/wfcheck.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index b2a085bc21c..45e8d2ffb85 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))