fn binders<T>(
&mut self,
- a: ty::Binder<T>,
- b: ty::Binder<T>,
- ) -> RelateResult<'tcx, ty::Binder<T>>
+ a: ty::Binder<'tcx, T>,
+ b: ty::Binder<'tcx, T>,
+ ) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
where
T: Relate<'tcx>;
}
) -> RelateResult<'tcx, SubstsRef<'tcx>> {
let tcx = relation.tcx();
- let params = a_subst.iter().zip(b_subst).enumerate().map(|(i, (a, b))| {
+ let params = iter::zip(a_subst, b_subst).enumerate().map(|(i, (a, b))| {
let variance = variances.map_or(ty::Invariant, |v| v[i]);
relation.relate_with_variance(variance, a, b)
});
return Err(TypeError::ArgCount);
}
- let inputs_and_output = a
- .inputs()
- .iter()
- .cloned()
- .zip(b.inputs().iter().cloned())
- .map(|x| (x, false))
+ let inputs_and_output = iter::zip(a.inputs(), b.inputs())
+ .map(|(&a, &b)| ((a, b), false))
.chain(iter::once(((a.output(), b.output()), true)))
.map(|((a, b), is_output)| {
if is_output {
} else {
relation.relate_with_variance(ty::Contravariant, a, b)
}
+ })
+ .enumerate()
+ .map(|(i, r)| match r {
+ Err(TypeError::Sorts(exp_found)) => Err(TypeError::ArgumentSorts(exp_found, i)),
+ Err(TypeError::Mutability) => Err(TypeError::ArgumentMutability(i)),
+ r => r,
});
Ok(ty::FnSig {
inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
assert_eq!(a.0.len(), b.0.len());
let tcx = relation.tcx();
- let types = tcx.mk_type_list(a.0.iter().zip(b.0).map(|(a, b)| relation.relate(a, b)))?;
+ let types = tcx.mk_type_list(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?;
Ok(GeneratorWitness(types))
}
}
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
if as_.len() == bs.len() {
Ok(tcx.mk_tup(
- as_.iter().zip(bs).map(|(a, b)| relation.relate(a.expect_ty(), b.expect_ty())),
+ iter::zip(as_, bs).map(|(a, b)| relation.relate(a.expect_ty(), b.expect_ty())),
)?)
} else if !(as_.is_empty() || bs.is_empty()) {
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
// Both the variant and each field have to be equal.
if a_destructured.variant == b_destructured.variant {
- for (a_field, b_field) in
- a_destructured.fields.iter().zip(b_destructured.fields.iter())
- {
+ for (a_field, b_field) in iter::zip(a_destructured.fields, b_destructured.fields) {
relation.consts(a_field, b_field)?;
}
})
}
-impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
+impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>> {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: Self,
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
}
- let v = a_v.into_iter().zip(b_v.into_iter()).map(|(ep_a, ep_b)| {
+ let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| {
use crate::ty::ExistentialPredicate::*;
match (ep_a.skip_binder(), ep_b.skip_binder()) {
- (Trait(a), Trait(b)) => Ok(ty::Binder::bind(Trait(
- relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
- ))),
- (Projection(a), Projection(b)) => Ok(ty::Binder::bind(Projection(
+ (Trait(a), Trait(b)) => Ok(ep_a
+ .rebind(Trait(relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder()))),
+ (Projection(a), Projection(b)) => Ok(ep_a.rebind(Projection(
relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
))),
(AutoTrait(a), AutoTrait(b)) if a == b => Ok(ep_a.rebind(AutoTrait(a))),
}
}
-impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<T> {
+impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<'tcx, T> {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
- a: ty::Binder<T>,
- b: ty::Binder<T>,
- ) -> RelateResult<'tcx, ty::Binder<T>> {
+ a: ty::Binder<'tcx, T>,
+ b: ty::Binder<'tcx, T>,
+ ) -> RelateResult<'tcx, ty::Binder<'tcx, T>> {
relation.binders(a, b)
}
}