diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 6436e75158e..6cda9ea1518 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -23,7 +23,7 @@ pub mod custom; pub mod eq; pub mod normalize; pub mod outlives; -pub mod predicates; +pub mod prove_predicate; pub mod subtype; pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { diff --git a/src/librustc/traits/query/type_op/predicates.rs b/src/librustc/traits/query/type_op/prove_predicate.rs similarity index 57% rename from src/librustc/traits/query/type_op/predicates.rs rename to src/librustc/traits/query/type_op/prove_predicate.rs index d729ce1e0eb..7dacf6a7dea 100644 --- a/src/librustc/traits/query/type_op/predicates.rs +++ b/src/librustc/traits/query/type_op/prove_predicate.rs @@ -9,43 +9,36 @@ // except according to those terms. use infer::{InferCtxt, InferOk, InferResult}; -use traits::{Obligation, ObligationCause, PredicateObligation}; +use traits::{Obligation, ObligationCause}; use ty::{ParamEnv, Predicate, TyCtxt}; #[derive(Debug)] -pub struct ProvePredicates<'tcx> { - obligations: Vec>, +pub struct ProvePredicate<'tcx> { + param_env: ParamEnv<'tcx>, + predicate: Predicate<'tcx>, } -impl<'tcx> ProvePredicates<'tcx> { +impl<'tcx> ProvePredicate<'tcx> { pub fn new( param_env: ParamEnv<'tcx>, - predicates: impl IntoIterator>, + predicate: Predicate<'tcx>, ) -> Self { - ProvePredicates { - obligations: predicates - .into_iter() - .map(|p| Obligation::new(ObligationCause::dummy(), param_env, p)) - .collect(), - } + ProvePredicate { param_env, predicate } } } -impl<'gcx, 'tcx> super::TypeOp<'gcx, 'tcx> for ProvePredicates<'tcx> { +impl<'gcx, 'tcx> super::TypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> { type Output = (); fn trivial_noop(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result { - if self.obligations.is_empty() { - Ok(()) - } else { - Err(self) - } + Err(self) } fn perform(self, _infcx: &InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, Self::Output> { + let obligation = Obligation::new(ObligationCause::dummy(), self.param_env, self.predicate); Ok(InferOk { value: (), - obligations: self.obligations, + obligations: vec![obligation], }) } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 865ee66cccf..1f45a8ba173 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -1545,26 +1545,19 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { predicates: impl IntoIterator> + Clone, location: Location, ) { - // This intermediate vector is mildly unfortunate, in that we - // sometimes create it even when logging is disabled, but only - // if debug-info is enabled, and I doubt it is actually - // expensive. -nmatsakis - let predicates_vec: Vec<_> = if cfg!(debug_assertions) { - predicates.clone().into_iter().collect() - } else { - Vec::new() - }; - debug!( - "prove_predicates(predicates={:?}, location={:?})", - predicates_vec, location, - ); + for predicate in predicates { + debug!( + "prove_predicates(predicate={:?}, location={:?})", + predicate, location, + ); - let param_env = self.param_env; - self.fully_perform_op( - location.at_self(), - type_op::predicates::ProvePredicates::new(param_env, predicates), - ).unwrap() + let param_env = self.param_env; + self.fully_perform_op( + location.at_self(), + type_op::prove_predicate::ProvePredicate::new(param_env, predicate), + ).unwrap() + } } fn typeck_mir(&mut self, mir: &Mir<'tcx>) {