Rollup merge of #102348 - nnethercote:tweak-FulfillProcessor, r=jackh726
Tweak `FulfillProcessor`. Avoids some unnecessary references and lifetimes. r? `@jackh726`
This commit is contained in:
commit
bf54cfe2b2
1 changed files with 12 additions and 12 deletions
|
@ -102,7 +102,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to select obligations using `selcx`.
|
/// Attempts to select obligations using `selcx`.
|
||||||
fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
fn select(&mut self, selcx: SelectionContext<'a, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
||||||
let span = debug_span!("select", obligation_forest_size = ?self.predicates.len());
|
let span = debug_span!("select", obligation_forest_size = ?self.predicates.len());
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'_, 'tcx>,
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
) -> Vec<FulfillmentError<'tcx>> {
|
||||||
let mut selcx = SelectionContext::new(infcx);
|
let selcx = SelectionContext::new(infcx);
|
||||||
self.select(&mut selcx)
|
self.select(selcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>> {
|
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>> {
|
||||||
|
@ -210,8 +210,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FulfillProcessor<'a, 'b, 'tcx> {
|
struct FulfillProcessor<'a, 'tcx> {
|
||||||
selcx: &'a mut SelectionContext<'b, 'tcx>,
|
selcx: SelectionContext<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_pending(os: Vec<PredicateObligation<'_>>) -> Vec<PendingPredicateObligation<'_>> {
|
fn mk_pending(os: Vec<PredicateObligation<'_>>) -> Vec<PendingPredicateObligation<'_>> {
|
||||||
|
@ -220,7 +220,7 @@ fn mk_pending(os: Vec<PredicateObligation<'_>>) -> Vec<PendingPredicateObligatio
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
type Obligation = PendingPredicateObligation<'tcx>;
|
type Obligation = PendingPredicateObligation<'tcx>;
|
||||||
type Error = FulfillmentErrorCode<'tcx>;
|
type Error = FulfillmentErrorCode<'tcx>;
|
||||||
type OUT = Outcome<Self::Obligation, Self::Error>;
|
type OUT = Outcome<Self::Obligation, Self::Error>;
|
||||||
|
@ -291,7 +291,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
if obligation.predicate.has_projections() {
|
if obligation.predicate.has_projections() {
|
||||||
let mut obligations = Vec::new();
|
let mut obligations = Vec::new();
|
||||||
let predicate = crate::traits::project::try_normalize_with_depth_to(
|
let predicate = crate::traits::project::try_normalize_with_depth_to(
|
||||||
self.selcx,
|
&mut self.selcx,
|
||||||
obligation.param_env,
|
obligation.param_env,
|
||||||
obligation.cause.clone(),
|
obligation.cause.clone(),
|
||||||
obligation.recursion_depth + 1,
|
obligation.recursion_depth + 1,
|
||||||
|
@ -608,7 +608,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
|
||||||
#[instrument(level = "debug", skip(self, obligation, stalled_on))]
|
#[instrument(level = "debug", skip(self, obligation, stalled_on))]
|
||||||
fn process_trait_obligation(
|
fn process_trait_obligation(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -643,7 +643,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
// information about the types in the trait.
|
// information about the types in the trait.
|
||||||
stalled_on.clear();
|
stalled_on.clear();
|
||||||
stalled_on.extend(substs_infer_vars(
|
stalled_on.extend(substs_infer_vars(
|
||||||
self.selcx,
|
&self.selcx,
|
||||||
trait_obligation.predicate.map_bound(|pred| pred.trait_ref.substs),
|
trait_obligation.predicate.map_bound(|pred| pred.trait_ref.substs),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -695,12 +695,12 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match project::poly_project_and_unify_type(self.selcx, &project_obligation) {
|
match project::poly_project_and_unify_type(&mut self.selcx, &project_obligation) {
|
||||||
ProjectAndUnifyResult::Holds(os) => ProcessResult::Changed(mk_pending(os)),
|
ProjectAndUnifyResult::Holds(os) => ProcessResult::Changed(mk_pending(os)),
|
||||||
ProjectAndUnifyResult::FailedNormalization => {
|
ProjectAndUnifyResult::FailedNormalization => {
|
||||||
stalled_on.clear();
|
stalled_on.clear();
|
||||||
stalled_on.extend(substs_infer_vars(
|
stalled_on.extend(substs_infer_vars(
|
||||||
self.selcx,
|
&self.selcx,
|
||||||
project_obligation.predicate.map_bound(|pred| pred.projection_ty.substs),
|
project_obligation.predicate.map_bound(|pred| pred.projection_ty.substs),
|
||||||
));
|
));
|
||||||
ProcessResult::Unchanged
|
ProcessResult::Unchanged
|
||||||
|
@ -718,7 +718,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
|
|
||||||
/// Returns the set of inference variables contained in `substs`.
|
/// Returns the set of inference variables contained in `substs`.
|
||||||
fn substs_infer_vars<'a, 'tcx>(
|
fn substs_infer_vars<'a, 'tcx>(
|
||||||
selcx: &mut SelectionContext<'a, 'tcx>,
|
selcx: &SelectionContext<'a, 'tcx>,
|
||||||
substs: ty::Binder<'tcx, SubstsRef<'tcx>>,
|
substs: ty::Binder<'tcx, SubstsRef<'tcx>>,
|
||||||
) -> impl Iterator<Item = TyOrConstInferVar<'tcx>> {
|
) -> impl Iterator<Item = TyOrConstInferVar<'tcx>> {
|
||||||
selcx
|
selcx
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue