Skip to content

Commit 9cbce68

Browse files
committed
call liberate_late_bound_regions on receiver_ty
hopefully this will still work, and it might be a bit simpler than keeping the binder around. The point of this was to fix the ICE in substs.rs, but it looks like it’s caused by something else
1 parent 1509275 commit 9cbce68

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/librustc/traits/object_safety.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use super::elaborate_predicates;
2222
use hir::def_id::DefId;
2323
use lint;
2424
use traits::{self, Obligation, ObligationCause};
25-
use ty::{self, Ty, TyCtxt, Binder, TypeFoldable, Predicate, ToPredicate};
26-
use ty::subst::{Subst};
25+
use ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate};
2726
use std::borrow::Cow;
2827
use std::iter::{self};
2928
use syntax::ast::{self, Name};
@@ -313,14 +312,17 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
313312
return Some(MethodViolationCode::WhereClauseReferencesSelf(span));
314313
}
315314

316-
let receiver_ty = sig.map_bound(|sig| sig.inputs()[0]);
315+
let receiver_ty = self.liberate_late_bound_regions(
316+
method.def_id,
317+
&sig.map_bound(|sig| sig.inputs()[0]),
318+
);
317319

318320
// until we get by-value DST, `self: Self` can't be coerced
319321
// but we allow this as a special case.
320322
// maybe instead we should also check for
321323
// for (U) { if (Self: Unsize<U>) { Receiver: Unsize<Receiver<Self=Self>>}}
322-
if *receiver_ty.skip_binder() != self.mk_self_type() {
323-
if !self.receiver_is_coercible(method, receiver_ty) {
324+
if receiver_ty != self.mk_self_type() {
325+
if !self.receiver_is_coercible(trait_def_id, method, receiver_ty) {
324326
return Some(MethodViolationCode::UncoercibleReceiver);
325327
}
326328
}
@@ -339,7 +341,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
339341
fn receiver_is_coercible(
340342
self,
341343
method: &ty::AssociatedItem,
342-
receiver_ty: Binder<Ty<'tcx>>,
344+
receiver_ty: Ty<'tcx>,
343345
) -> bool
344346
{
345347
debug!("receiver_is_coercible: method = {:?}, receiver_ty = {:?}", method, receiver_ty);
@@ -389,12 +391,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
389391

390392
// Receiver: CoerceUnsized<Receiver<Self=U>>
391393
let obligation = {
392-
let predicate = receiver_ty.fuse(target_receiver_ty, |receiver_ty, target_receiver_ty| {
393-
ty::TraitRef {
394-
def_id: coerce_unsized_did,
395-
substs: self.mk_substs_trait(receiver_ty, &[target_receiver_ty.into()]),
396-
}
397-
}).to_predicate();
394+
let predicate = ty::TraitRef {
395+
def_id: coerce_unsized_did,
396+
substs: self.mk_substs_trait(receiver_ty, &[target_receiver_ty.into()]),
397+
}.to_predicate();
398398

399399
Obligation::new(
400400
ObligationCause::dummy(),

0 commit comments

Comments
 (0)