convert predicates
to operate on 1 predicate at a time
This commit is contained in:
parent
4beea9943b
commit
d6136837b7
@ -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 {
|
||||
|
@ -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<PredicateObligation<'tcx>>,
|
||||
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<Item = Predicate<'tcx>>,
|
||||
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<Self::Output, Self> {
|
||||
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],
|
||||
})
|
||||
}
|
||||
}
|
@ -1545,26 +1545,19 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
predicates: impl IntoIterator<Item = ty::Predicate<'tcx>> + 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>) {
|
||||
|
Loading…
Reference in New Issue
Block a user