Skip to content

Commit

Permalink
Generate correct Deref predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Dec 20, 2019
1 parent cd3ead1 commit 0a5c91c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librustc_typeck/check/demand.rs
Expand Up @@ -551,15 +551,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Check for `Deref` implementations by constructing a predicate to
// prove: `<T as Deref>::Output == U`
let deref_trait = self.tcx.lang_items().deref_trait().unwrap();
let item_def_id = self.tcx.associated_items(deref_trait).next().unwrap().def_id;
let item_def_id = self.tcx.associated_items(deref_trait)
.find(|item| item.kind == ty::AssocKind::Type)
.unwrap()
.def_id;
let predicate = ty::Predicate::Projection(ty::Binder::bind(ty::ProjectionPredicate {
// `<T as Deref>::Output`
projection_ty: ty::ProjectionTy {
// `T`
substs: self.tcx.mk_substs_trait(
checked_ty,
self.fresh_substs_for_item(sp, item_def_id),
),
substs: self.tcx.intern_substs(&[checked_ty.into()]),
// `Deref::Output`
item_def_id,
},
Expand Down

0 comments on commit 0a5c91c

Please sign in to comment.