use List<Ty<'tcx>> for tuples

This commit is contained in:
lcnr 2022-02-07 16:06:31 +01:00
parent a9c1ab82f5
commit 1245131a11
53 changed files with 128 additions and 170 deletions

View file

@ -843,12 +843,10 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// FIXME: enable the general case stated above ^.
let ty = value.layout.ty;
// Only do it for tuples
if let ty::Tuple(substs) = ty.kind() {
if let ty::Tuple(types) = ty.kind() {
// Only do it if tuple is also a pair with two scalars
if substs.len() == 2 {
if let [ty1, ty2] = types[..] {
let alloc = self.use_ecx(|this| {
let ty1 = substs[0].expect_ty();
let ty2 = substs[1].expect_ty();
let ty_is_scalar = |ty| {
this.ecx.layout_of(ty).ok().map(|layout| layout.abi.is_scalar())
== Some(true)

View file

@ -692,8 +692,7 @@ impl<'tcx> Inliner<'tcx> {
// The `tmp0`, `tmp1`, and `tmp2` in our example abonve.
let tuple_tmp_args = tuple_tys.iter().enumerate().map(|(i, ty)| {
// This is e.g., `tuple_tmp.0` in our example above.
let tuple_field =
Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty.expect_ty()));
let tuple_field = Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty));
// Spill to a local to make e.g., `tmp0`.
self.create_temp_if_necessary(tuple_field, callsite, caller_body)

View file

@ -148,8 +148,8 @@ fn is_needs_drop_and_init<'tcx>(
})
}
ty::Tuple(_) => ty
.tuple_fields()
ty::Tuple(fields) => fields
.iter()
.enumerate()
.map(|(f, f_ty)| (Field::from_usize(f), f_ty, mpi))
.any(field_needs_drop_and_init),

View file

@ -461,10 +461,10 @@ impl<'tcx> CloneShimBuilder<'tcx> {
fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I)
where
I: Iterator<Item = Ty<'tcx>>,
I: IntoIterator<Item = Ty<'tcx>>,
{
let mut previous_field = None;
for (i, ity) in tys.enumerate() {
for (i, ity) in tys.into_iter().enumerate() {
let field = Field::new(i);
let src_field = self.tcx.mk_place_field(src, field, ity);