Skip to content

Commit a85f77c

Browse files
authored
Fix codegen_rvalue_aggregate for tuples (rust-lang#2371)
1 parent 4f710d4 commit a85f77c

File tree

1 file changed

+13
-11
lines changed
  • kani-compiler/src/codegen_cprover_gotoc/codegen

1 file changed

+13
-11
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,19 @@ impl<'tcx> GotocCtx<'tcx> {
304304
)
305305
}
306306
}
307-
AggregateKind::Tuple => Expr::struct_expr_from_values(
308-
self.codegen_ty(res_ty),
309-
operands
310-
.iter()
311-
.filter_map(|o| {
312-
let oty = self.operand_ty(o);
313-
if oty.is_unit() { None } else { Some(self.codegen_operand(o)) }
314-
})
315-
.collect(),
316-
&self.symbol_table,
317-
),
307+
AggregateKind::Tuple => {
308+
let typ = self.codegen_ty(res_ty);
309+
let layout = self.layout_of(res_ty);
310+
Expr::struct_expr_from_values(
311+
typ,
312+
layout
313+
.fields
314+
.index_by_increasing_offset()
315+
.map(|idx| self.codegen_operand(&operands[idx]))
316+
.collect(),
317+
&self.symbol_table,
318+
)
319+
}
318320
AggregateKind::Adt(_, _, _, _, _) => unimplemented!(),
319321
AggregateKind::Closure(_, _) => unimplemented!(),
320322
AggregateKind::Generator(_, _, _) => unimplemented!(),

0 commit comments

Comments
 (0)