Skip to content

Commit 0e2e179

Browse files
committed
Make prove_predicates take an Iterator
1 parent 9ec7aa2 commit 0e2e179

File tree

1 file changed

+16
-9
lines changed
  • src/librustc_mir/borrow_check/nll/type_check

1 file changed

+16
-9
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
275275
tcx.predicates_of(def_id).instantiate(tcx, substs);
276276
let predicates =
277277
type_checker.normalize(&instantiated_predicates.predicates, location);
278-
type_checker.prove_predicates(&predicates, location);
278+
type_checker.prove_predicates(predicates.iter().cloned(), location);
279279
}
280280

281281
value.ty
@@ -1511,28 +1511,35 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
15111511

15121512
let predicates = self.normalize(&instantiated_predicates.predicates, location);
15131513
debug!("prove_aggregate_predicates: predicates={:?}", predicates);
1514-
self.prove_predicates(&predicates, location);
1514+
self.prove_predicates(predicates.iter().cloned(), location);
15151515
}
15161516

15171517
fn prove_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>, location: Location) {
15181518
self.prove_predicates(
1519-
&[ty::Predicate::Trait(
1519+
[ty::Predicate::Trait(
15201520
trait_ref.to_poly_trait_ref().to_poly_trait_predicate(),
1521-
)],
1521+
)].iter()
1522+
.cloned(),
15221523
location,
15231524
);
15241525
}
15251526

1526-
fn prove_predicates(&mut self, predicates: &[ty::Predicate<'tcx>], location: Location) {
1527+
fn prove_predicates(
1528+
&mut self,
1529+
predicates: impl IntoIterator<Item = ty::Predicate<'tcx>>,
1530+
location: Location,
1531+
) {
1532+
let mut predicates_iter = predicates.into_iter();
1533+
15271534
debug!(
15281535
"prove_predicates(predicates={:?}, location={:?})",
1529-
predicates, location
1536+
predicates_iter.by_ref().collect::<Vec<_>>(),
1537+
location
15301538
);
15311539
self.fully_perform_op(location.at_self(), |this| {
15321540
let cause = this.misc(this.last_span);
1533-
let obligations = predicates
1534-
.iter()
1535-
.map(|&p| traits::Obligation::new(cause.clone(), this.param_env, p))
1541+
let obligations = predicates_iter
1542+
.map(|p| traits::Obligation::new(cause.clone(), this.param_env, p))
15361543
.collect();
15371544
Ok(InferOk {
15381545
value: (),

0 commit comments

Comments
 (0)