From 7448c24e02c5fea69db7cee8fae8075ee55572a9 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 12 Apr 2024 21:13:47 -0700 Subject: [PATCH] Aggregating arrays can always take the place path --- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 4e7d251a2e9..6be473ffa1f 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -738,7 +738,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bug!("RawPtr operands {data:?} {meta:?}"), } } - mir::Rvalue::Repeat(..) | mir::Rvalue::Aggregate(..) => { + mir::Rvalue::Repeat(..) => bug!("{rvalue:?} in codegen_rvalue_operand"), + mir::Rvalue::Aggregate(..) => { // According to `rvalue_creates_operand`, only ZST // aggregate rvalues are allowed to be operands. let ty = rvalue.ty(self.mir, self.cx.tcx()); @@ -1052,7 +1053,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { true, // This always produces a `ty::RawPtr`, so will be Immediate or Pair mir::Rvalue::Aggregate(box AggregateKind::RawPtr(..), ..) => true, - mir::Rvalue::Repeat(..) | + // Arrays are always aggregates, so it's not worth checking anything here. + // (If it's really `[(); N]` or `[T; 0]` and we use the place path, fine.) + mir::Rvalue::Repeat(..) => false, mir::Rvalue::Aggregate(..) => { let ty = rvalue.ty(self.mir, self.cx.tcx()); let ty = self.monomorphize(ty);