From 0a5c91c1293bcc0ece70c9bde849eb619fd6a64f Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 9 Dec 2019 22:19:40 +0000 Subject: [PATCH] Generate correct `Deref` predicate --- src/librustc_typeck/check/demand.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 16a55d2a4d3..7d845b872ff 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -551,15 +551,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check for `Deref` implementations by constructing a predicate to // prove: `::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 { // `::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, },