@@ -313,13 +313,13 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
313
313
return Some ( MethodViolationCode :: WhereClauseReferencesSelf ( span) ) ;
314
314
}
315
315
316
- let receiver_ty = sig. skip_binder ( ) . inputs ( ) [ 0 ] ;
316
+ let receiver_ty = sig. map_bound ( |sig| sig . inputs ( ) [ 0 ] ) ;
317
317
318
318
// until we get by-value DST, `self: Self` can't be coerced
319
319
// but we allow this as a special case.
320
320
// maybe instead we should also check for
321
321
// for (U) { if (Self: Unsize<U>) { Receiver: Unsize<Receiver<Self=Self>>}}
322
- if receiver_ty != self . mk_self_type ( ) {
322
+ if * receiver_ty. skip_binder ( ) != self . mk_self_type ( ) {
323
323
if !self . receiver_is_coercible ( method, receiver_ty) {
324
324
return Some ( MethodViolationCode :: UncoercibleReceiver ) ;
325
325
}
@@ -339,7 +339,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
339
339
fn receiver_is_coercible (
340
340
self ,
341
341
method : & ty:: AssociatedItem ,
342
- receiver_ty : Ty < ' tcx >
342
+ receiver_ty : Binder < Ty < ' tcx > > ,
343
343
) -> bool
344
344
{
345
345
debug ! ( "receiver_is_coercible: method = {:?}, receiver_ty = {:?}" , method, receiver_ty) ;
@@ -367,10 +367,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
367
367
let param_env = {
368
368
let mut param_env = self . param_env ( method. def_id ) ;
369
369
370
- let predicate = Binder :: bind ( ty:: TraitRef {
370
+ let predicate = ty:: TraitRef {
371
371
def_id : unsize_did,
372
372
substs : self . mk_substs_trait ( self . mk_self_type ( ) , & [ target_self_ty. into ( ) ] ) ,
373
- } ) . to_predicate ( ) ;
373
+ } . to_predicate ( ) ;
374
374
375
375
let caller_bounds: Vec < Predicate < ' tcx > > = param_env. caller_bounds . iter ( ) . cloned ( )
376
376
. chain ( iter:: once ( predicate) )
@@ -389,9 +389,11 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
389
389
390
390
// Receiver: CoerceUnsized<Receiver<Self=U>>
391
391
let obligation = {
392
- let predicate = Binder :: bind ( ty:: TraitRef {
393
- def_id : coerce_unsized_did,
394
- substs : self . mk_substs_trait ( receiver_ty, & [ target_receiver_ty. into ( ) ] ) ,
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
+ }
395
397
} ) . to_predicate ( ) ;
396
398
397
399
Obligation :: new (
0 commit comments