Skip to content

Commit 0a5c91c

Browse files
committed
Generate correct Deref predicate
1 parent cd3ead1 commit 0a5c91c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/librustc_typeck/check/demand.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
551551
// Check for `Deref` implementations by constructing a predicate to
552552
// prove: `<T as Deref>::Output == U`
553553
let deref_trait = self.tcx.lang_items().deref_trait().unwrap();
554-
let item_def_id = self.tcx.associated_items(deref_trait).next().unwrap().def_id;
554+
let item_def_id = self.tcx.associated_items(deref_trait)
555+
.find(|item| item.kind == ty::AssocKind::Type)
556+
.unwrap()
557+
.def_id;
555558
let predicate = ty::Predicate::Projection(ty::Binder::bind(ty::ProjectionPredicate {
556559
// `<T as Deref>::Output`
557560
projection_ty: ty::ProjectionTy {
558561
// `T`
559-
substs: self.tcx.mk_substs_trait(
560-
checked_ty,
561-
self.fresh_substs_for_item(sp, item_def_id),
562-
),
562+
substs: self.tcx.intern_substs(&[checked_ty.into()]),
563563
// `Deref::Output`
564564
item_def_id,
565565
},

0 commit comments

Comments
 (0)