Skip to content

Commit bf54cfe

Browse files
authored
Rollup merge of rust-lang#102348 - nnethercote:tweak-FulfillProcessor, r=jackh726
Tweak `FulfillProcessor`. Avoids some unnecessary references and lifetimes. r? `@jackh726`
2 parents f0daff2 + b69c335 commit bf54cfe

File tree

1 file changed

+12
-12
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+12
-12
lines changed

compiler/rustc_trait_selection/src/traits/fulfill.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
102102
}
103103

104104
/// Attempts to select obligations using `selcx`.
105-
fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
105+
fn select(&mut self, selcx: SelectionContext<'a, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
106106
let span = debug_span!("select", obligation_forest_size = ?self.predicates.len());
107107
let _enter = span.enter();
108108

@@ -197,8 +197,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
197197
&mut self,
198198
infcx: &InferCtxt<'_, 'tcx>,
199199
) -> Vec<FulfillmentError<'tcx>> {
200-
let mut selcx = SelectionContext::new(infcx);
201-
self.select(&mut selcx)
200+
let selcx = SelectionContext::new(infcx);
201+
self.select(selcx)
202202
}
203203

204204
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>> {
@@ -210,8 +210,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
210210
}
211211
}
212212

213-
struct FulfillProcessor<'a, 'b, 'tcx> {
214-
selcx: &'a mut SelectionContext<'b, 'tcx>,
213+
struct FulfillProcessor<'a, 'tcx> {
214+
selcx: SelectionContext<'a, 'tcx>,
215215
}
216216

217217
fn mk_pending(os: Vec<PredicateObligation<'_>>) -> Vec<PendingPredicateObligation<'_>> {
@@ -220,7 +220,7 @@ fn mk_pending(os: Vec<PredicateObligation<'_>>) -> Vec<PendingPredicateObligatio
220220
.collect()
221221
}
222222

223-
impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
223+
impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
224224
type Obligation = PendingPredicateObligation<'tcx>;
225225
type Error = FulfillmentErrorCode<'tcx>;
226226
type OUT = Outcome<Self::Obligation, Self::Error>;
@@ -291,7 +291,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
291291
if obligation.predicate.has_projections() {
292292
let mut obligations = Vec::new();
293293
let predicate = crate::traits::project::try_normalize_with_depth_to(
294-
self.selcx,
294+
&mut self.selcx,
295295
obligation.param_env,
296296
obligation.cause.clone(),
297297
obligation.recursion_depth + 1,
@@ -608,7 +608,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
608608
}
609609
}
610610

611-
impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
611+
impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
612612
#[instrument(level = "debug", skip(self, obligation, stalled_on))]
613613
fn process_trait_obligation(
614614
&mut self,
@@ -643,7 +643,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
643643
// information about the types in the trait.
644644
stalled_on.clear();
645645
stalled_on.extend(substs_infer_vars(
646-
self.selcx,
646+
&self.selcx,
647647
trait_obligation.predicate.map_bound(|pred| pred.trait_ref.substs),
648648
));
649649

@@ -695,12 +695,12 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
695695
}
696696
}
697697

698-
match project::poly_project_and_unify_type(self.selcx, &project_obligation) {
698+
match project::poly_project_and_unify_type(&mut self.selcx, &project_obligation) {
699699
ProjectAndUnifyResult::Holds(os) => ProcessResult::Changed(mk_pending(os)),
700700
ProjectAndUnifyResult::FailedNormalization => {
701701
stalled_on.clear();
702702
stalled_on.extend(substs_infer_vars(
703-
self.selcx,
703+
&self.selcx,
704704
project_obligation.predicate.map_bound(|pred| pred.projection_ty.substs),
705705
));
706706
ProcessResult::Unchanged
@@ -718,7 +718,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
718718

719719
/// Returns the set of inference variables contained in `substs`.
720720
fn substs_infer_vars<'a, 'tcx>(
721-
selcx: &mut SelectionContext<'a, 'tcx>,
721+
selcx: &SelectionContext<'a, 'tcx>,
722722
substs: ty::Binder<'tcx, SubstsRef<'tcx>>,
723723
) -> impl Iterator<Item = TyOrConstInferVar<'tcx>> {
724724
selcx

0 commit comments

Comments
 (0)