Skip to content

Commit c2acc80

Browse files
committed
fmt
1 parent 9cd4004 commit c2acc80

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

+22-15
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,24 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
412412
ImmTy::from_immediate(ptr_imm, ty).into()
413413
} else if matches!(kind, AggregateTy::Array) {
414414
let mut mplace = None;
415-
let alloc_id = self.ecx.intern_with_temp_alloc(ty, |ecx, dest| {
416-
for (field_index, op) in fields.iter().copied().enumerate() {
417-
// ignore nested arrays
418-
if let Either::Left(_) = op.as_mplace_or_imm() {
419-
interpret::throw_inval!(TooGeneric);
415+
let alloc_id = self
416+
.ecx
417+
.intern_with_temp_alloc(ty, |ecx, dest| {
418+
for (field_index, op) in fields.iter().copied().enumerate() {
419+
// ignore nested arrays
420+
if let Either::Left(_) = op.as_mplace_or_imm() {
421+
interpret::throw_inval!(TooGeneric);
422+
}
423+
let field_dest = ecx.project_field(dest, field_index)?;
424+
ecx.copy_op(op, &field_dest)?;
420425
}
421-
let field_dest = ecx.project_field(dest, field_index)?;
422-
ecx.copy_op(op, &field_dest)?;
423-
}
424426

425-
let dest = dest.assert_mem_place().map_provenance(|prov| prov.as_immutable());
426-
mplace.replace(dest);
427-
Ok(())
428-
}).ok()?;
427+
let dest =
428+
dest.assert_mem_place().map_provenance(|prov| prov.as_immutable());
429+
mplace.replace(dest);
430+
Ok(())
431+
})
432+
.ok()?;
429433
let GlobalAlloc::Memory(_alloc) = self.tcx.global_alloc(alloc_id) else {
430434
bug!()
431435
};
@@ -1276,7 +1280,8 @@ fn op_to_prop_const<'tcx>(
12761280
}
12771281

12781282
// Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to avoid.
1279-
if !(op.layout.ty.is_array() || matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))) {
1283+
if !(op.layout.ty.is_array() || matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..)))
1284+
{
12801285
return None;
12811286
}
12821287

@@ -1345,7 +1350,8 @@ impl<'tcx> VnState<'_, 'tcx> {
13451350
Value::Aggregate(AggregateTy::Array, _, fields) => {
13461351
for f in fields {
13471352
if let Value::Constant { value: Const::Val(const_, _), .. } = self.get(*f)
1348-
&& let ConstValue::Indirect { .. } = const_ {
1353+
&& let ConstValue::Indirect { .. } = const_
1354+
{
13491355
return None;
13501356
}
13511357
}
@@ -1356,7 +1362,8 @@ impl<'tcx> VnState<'_, 'tcx> {
13561362
&& let ConstValue::Scalar(Scalar::Ptr(..)) = const_
13571363
&& let ty::Ref(region, ty, _mutability) = ty.kind()
13581364
&& region.is_erased()
1359-
&& ty.is_array() {
1365+
&& ty.is_array()
1366+
{
13601367
return None;
13611368
}
13621369
}

0 commit comments

Comments
 (0)