Skip to content

Commit 2369746

Browse files
committed
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.
1 parent 3902643 commit 2369746

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,22 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
469469

470470
debug!("check_method_receiver: sig={:?}", sig);
471471

472+
let self_ty = fcx.normalize_associated_types_in(span, &self_ty);
473+
let self_ty = fcx.liberate_late_bound_regions(
474+
method.def_id,
475+
&ty::Binder(self_ty)
476+
);
477+
472478
let self_arg_ty = sig.inputs()[0];
473479

474480
let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver);
475481
let eq = |expected, actual| fcx.at(&cause, fcx.param_env).eq(expected, actual);
482+
let self_arg_ty = fcx.normalize_associated_types_in(span, &self_arg_ty);
483+
let self_arg_ty = fcx.liberate_late_bound_regions(
484+
method.def_id,
485+
&ty::Binder(self_arg_ty)
486+
);
487+
476488
let mut autoderef = fcx.autoderef(span, self_arg_ty);
477489

478490
loop {
@@ -484,7 +496,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
484496
autoderef.finalize();
485497
break
486498
}
487-
488499
} else {
489500
fcx.tcx.sess.diagnostic().mut_span_err(span, &format!("invalid `self` type: {:?}", self_arg_ty))
490501
.note(&format!("type must be `{:?}` or a type that dereferences to it`", self_ty))

0 commit comments

Comments
 (0)