diff --git a/src/librustc_infer/infer/outlives/mod.rs b/src/librustc_infer/infer/outlives/mod.rs index 6009d4e65793b..a1e7f1fa3e5e7 100644 --- a/src/librustc_infer/infer/outlives/mod.rs +++ b/src/librustc_infer/infer/outlives/mod.rs @@ -16,7 +16,7 @@ pub fn explicit_outlives_bounds<'tcx>( .caller_bounds() .into_iter() .map(ty::Predicate::skip_binders) - .filter(TypeFoldable::has_escaping_bound_vars) + .filter(|atom| !atom.has_escaping_bound_vars()) .filter_map(move |atom| match atom { ty::PredicateAtom::Projection(..) | ty::PredicateAtom::Trait(..) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d67be44e4f0c5..a45817beea164 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1208,8 +1208,6 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { let def_id = cx.tcx.hir().local_def_id(item.hir_id); let predicates = cx.tcx.predicates_of(def_id); for &(predicate, span) in predicates.predicates { - // We don't actually look inside of the predicate, - // so it is safe to skip this binder here. let predicate_kind_name = match predicate.skip_binders() { Trait(..) => "Trait", TypeOutlives(..) | diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 15210c5b21bc2..3bae1c1314325 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -1377,14 +1377,14 @@ impl ToPredicate<'tcx> for PredicateKind<'tcx> { impl ToPredicate<'tcx> for PredicateAtom<'tcx> { #[inline(always)] - fn to_predicate(&self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { + fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { debug_assert!(!self.has_escaping_bound_vars(), "excaping bound vars for {:?}", self); - tcx.mk_predicate(ty::PredicateKind::Atom(*self)) + tcx.mk_predicate(ty::PredicateKind::Atom(self)) } } impl<'tcx> ToPredicate<'tcx> for ConstnessAnd> { - fn to_predicate(&self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { + fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { ty::PredicateAtom::Trait(ty::TraitPredicate { trait_ref: self.value }, self.constness) .to_predicate(tcx) } diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs index c73ed986317c9..25564d03e8373 100644 --- a/src/librustc_trait_selection/traits/fulfill.rs +++ b/src/librustc_trait_selection/traits/fulfill.rs @@ -471,29 +471,31 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { } } - ty::PredicateAtom::ConstEquate(c1, c2) => { - debug!("equating consts: c1={:?} c2={:?}", c1, c2); - - let stalled_on = &mut pending_obligation.stalled_on; - - let mut evaluate = |c: &'tcx Const<'tcx>| { - if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val { - match self.selcx.infcx().const_eval_resolve( - obligation.param_env, - def, - substs, - promoted, - Some(obligation.cause.span), - ) { - Ok(val) => Ok(Const::from_value(self.selcx.tcx(), val, c.ty)), - Err(ErrorHandled::TooGeneric) => { - stalled_on.append( - &mut substs - .types() - .filter_map(|ty| TyOrConstInferVar::maybe_from_ty(ty)) - .collect(), - ); - Err(ErrorHandled::TooGeneric) + ty::PredicateAtom::ConstEquate(c1, c2) => { + debug!("equating consts: c1={:?} c2={:?}", c1, c2); + + let stalled_on = &mut pending_obligation.stalled_on; + + let mut evaluate = |c: &'tcx Const<'tcx>| { + if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val { + match self.selcx.infcx().const_eval_resolve( + obligation.param_env, + def, + substs, + promoted, + Some(obligation.cause.span), + ) { + Ok(val) => Ok(Const::from_value(self.selcx.tcx(), val, c.ty)), + Err(ErrorHandled::TooGeneric) => { + stalled_on.append( + &mut substs + .types() + .filter_map(|ty| TyOrConstInferVar::maybe_from_ty(ty)) + .collect(), + ); + Err(ErrorHandled::TooGeneric) + } + Err(err) => Err(err), } } else { Ok(c)