CTFE: extra assertions for Aggregate rvalues; remove unnecessarily eager special case
This commit is contained in:
parent
35f74c24a3
commit
268bb46db2
1 changed files with 9 additions and 7 deletions
|
@ -197,12 +197,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Aggregate(ref kind, ref operands) => {
|
Aggregate(ref kind, ref operands) => {
|
||||||
|
// active_field_index is for union initialization.
|
||||||
let (dest, active_field_index) = match **kind {
|
let (dest, active_field_index) = match **kind {
|
||||||
mir::AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
|
mir::AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
|
||||||
self.write_discriminant(variant_index, &dest)?;
|
self.write_discriminant(variant_index, &dest)?;
|
||||||
if adt_def.is_enum() {
|
if adt_def.is_enum() {
|
||||||
(self.place_downcast(&dest, variant_index)?, active_field_index)
|
assert!(active_field_index.is_none());
|
||||||
|
(self.place_downcast(&dest, variant_index)?, None)
|
||||||
} else {
|
} else {
|
||||||
|
if active_field_index.is_some() {
|
||||||
|
assert_eq!(operands.len(), 1);
|
||||||
|
}
|
||||||
(dest, active_field_index)
|
(dest, active_field_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,14 +216,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
|
|
||||||
for (i, operand) in operands.iter().enumerate() {
|
for (i, operand) in operands.iter().enumerate() {
|
||||||
let op = self.eval_operand(operand, None)?;
|
let op = self.eval_operand(operand, None)?;
|
||||||
// Ignore zero-sized fields.
|
|
||||||
if !op.layout.is_zst() {
|
|
||||||
let field_index = active_field_index.unwrap_or(i);
|
let field_index = active_field_index.unwrap_or(i);
|
||||||
let field_dest = self.place_field(&dest, field_index)?;
|
let field_dest = self.place_field(&dest, field_index)?;
|
||||||
self.copy_op(&op, &field_dest)?;
|
self.copy_op(&op, &field_dest)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Repeat(ref operand, _) => {
|
Repeat(ref operand, _) => {
|
||||||
let src = self.eval_operand(operand, None)?;
|
let src = self.eval_operand(operand, None)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue