Skip to content

Commit b31b0f9

Browse files
committed
create receiver_substs using the method's DefId
instead of the trait’s DefId. Apparently, when there are where clauses, the method has Substs that the trait doesn’t have.
1 parent 478763b commit b31b0f9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/librustc/traits/object_safety.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
323323
// maybe instead we should also check for
324324
// for (U) { if (Self: Unsize<U>) { Receiver: Unsize<Receiver<Self=Self>>}}
325325
if receiver_ty != self.mk_self_type() {
326-
if !self.receiver_is_coercible(trait_def_id, method, receiver_ty) {
326+
if !self.receiver_is_coercible(method, receiver_ty) {
327327
return Some(MethodViolationCode::UncoercibleReceiver);
328328
}
329329
}
@@ -341,7 +341,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
341341
#[allow(dead_code)]
342342
fn receiver_is_coercible(
343343
self,
344-
trait_def_id: DefId,
345344
method: &ty::AssociatedItem,
346345
receiver_ty: Ty<'tcx>,
347346
) -> bool
@@ -385,7 +384,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
385384
param_env
386385
};
387386

388-
let receiver_substs = Substs::for_item(self, trait_def_id, |param, _| {
387+
let receiver_substs = Substs::for_item(self, method.def_id, |param, _| {
389388
if param.index == 0 {
390389
target_self_ty.into()
391390
} else {

0 commit comments

Comments
 (0)