Skip to content

Commit

Permalink
create receiver_substs using the method's DefId
Browse files Browse the repository at this point in the history
instead of the trait’s DefId. Apparently, when there are where clauses,
the method has Substs that the trait doesn’t have.
  • Loading branch information
mikeyhew committed Sep 4, 2018
1 parent 478763b commit b31b0f9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
// maybe instead we should also check for
// for (U) { if (Self: Unsize<U>) { Receiver: Unsize<Receiver<Self=Self>>}}
if receiver_ty != self.mk_self_type() {
if !self.receiver_is_coercible(trait_def_id, method, receiver_ty) {
if !self.receiver_is_coercible(method, receiver_ty) {
return Some(MethodViolationCode::UncoercibleReceiver);
}
}
Expand All @@ -341,7 +341,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
#[allow(dead_code)]
fn receiver_is_coercible(
self,
trait_def_id: DefId,
method: &ty::AssociatedItem,
receiver_ty: Ty<'tcx>,
) -> bool
Expand Down Expand Up @@ -385,7 +384,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
param_env
};

let receiver_substs = Substs::for_item(self, trait_def_id, |param, _| {
let receiver_substs = Substs::for_item(self, method.def_id, |param, _| {
if param.index == 0 {
target_self_ty.into()
} else {
Expand Down

0 comments on commit b31b0f9

Please sign in to comment.