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

Commit fa65e0f

Browse files
committed
fmt
1 parent beec32d commit fa65e0f

File tree

1 file changed

+22
-15
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+22
-15
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,24 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
408408
ImmTy::from_immediate(ptr_imm, ty).into()
409409
} else if matches!(kind, AggregateTy::Array) {
410410
let mut mplace = None;
411-
let alloc_id = self.ecx.intern_with_temp_alloc(ty, |ecx, dest| {
412-
for (field_index, op) in fields.iter().copied().enumerate() {
413-
// ignore nested arrays
414-
if let Either::Left(_) = op.as_mplace_or_imm() {
415-
interpret::throw_inval!(TooGeneric);
411+
let alloc_id = self
412+
.ecx
413+
.intern_with_temp_alloc(ty, |ecx, dest| {
414+
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+
}
419+
let field_dest = ecx.project_field(dest, field_index)?;
420+
ecx.copy_op(op, &field_dest)?;
416421
}
417-
let field_dest = ecx.project_field(dest, field_index)?;
418-
ecx.copy_op(op, &field_dest)?;
419-
}
420422

421-
let dest = dest.assert_mem_place().map_provenance(|prov| prov.as_immutable());
422-
mplace.replace(dest);
423-
Ok(())
424-
}).ok()?;
423+
let dest =
424+
dest.assert_mem_place().map_provenance(|prov| prov.as_immutable());
425+
mplace.replace(dest);
426+
Ok(())
427+
})
428+
.ok()?;
425429
let GlobalAlloc::Memory(_alloc) = self.tcx.global_alloc(alloc_id) else {
426430
bug!()
427431
};
@@ -1385,7 +1389,8 @@ fn op_to_prop_const<'tcx>(
13851389
}
13861390

13871391
// Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to avoid.
1388-
if !(op.layout.ty.is_array() || matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))) {
1392+
if !(op.layout.ty.is_array() || matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..)))
1393+
{
13891394
return None;
13901395
}
13911396

@@ -1471,7 +1476,8 @@ impl<'tcx> VnState<'_, 'tcx> {
14711476
Value::Aggregate(AggregateTy::Array, _, fields) => {
14721477
for f in fields {
14731478
if let Value::Constant { value: Const::Val(const_, _), .. } = self.get(*f)
1474-
&& let ConstValue::Indirect { .. } = const_ {
1479+
&& let ConstValue::Indirect { .. } = const_
1480+
{
14751481
return None;
14761482
}
14771483
}
@@ -1482,7 +1488,8 @@ impl<'tcx> VnState<'_, 'tcx> {
14821488
&& let ConstValue::Scalar(Scalar::Ptr(..)) = const_
14831489
&& let ty::Ref(region, ty, _mutability) = ty.kind()
14841490
&& region.is_erased()
1485-
&& ty.is_array() {
1491+
&& ty.is_array()
1492+
{
14861493
return None;
14871494
}
14881495
}

0 commit comments

Comments
 (0)