Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2b4840b

Browse files
committed
move ignoring condition out of loop
1 parent 8e1dedb commit 2b4840b

File tree

1 file changed

+13
-6
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+13
-6
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,19 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
381381
.collect::<Option<Vec<_>>>()?;
382382
let ty = match kind {
383383
AggregateTy::Array => {
384-
assert!(fields.len() > 0);
385-
Ty::new_array(self.tcx, fields[0].layout.ty, fields.len() as u64)
384+
let [field, ..] = fields.as_slice() else {
385+
bug!("fields.len() == 0");
386+
};
387+
let field_ty = field.layout.ty;
388+
// Ignore nested array
389+
if field_ty.is_array() {
390+
trace!(
391+
"ignoring nested array of type: [{field_ty}; {len}]",
392+
len = fields.len(),
393+
);
394+
return None;
395+
}
396+
Ty::new_array(self.tcx, field_ty, fields.len() as u64)
386397
}
387398
AggregateTy::Tuple => {
388399
Ty::new_tup_from_iter(self.tcx, fields.iter().map(|f| f.layout.ty))
@@ -412,10 +423,6 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
412423
.ecx
413424
.intern_with_temp_alloc(ty, |ecx, dest| {
414425
for (field_index, op) in fields.iter().copied().enumerate() {
415-
// ignore nested arrays
416-
if let Either::Left(_) = op.as_mplace_or_imm() {
417-
interpret::throw_inval!(TooGeneric);
418-
}
419426
let field_dest = ecx.project_field(dest, field_index)?;
420427
ecx.copy_op(op, &field_dest)?;
421428
}

0 commit comments

Comments
 (0)