Skip to content

Commit b3cdc4e

Browse files
acl-cqctatiana-s
andauthored
refactor!: Delete ValueArray (#2760)
Joint PR with @tatiana-s closes #2398 Removes ValueArray and conversion to Array. The handlers for linearizing (non-linear code using) Array remain, as these do not actually depend on ValueArray, and we still need the `num_outports==0` case for Guppy's `drop` op, so I'm retaining the code for arbitrary #outports even though this is not used "in production". BREAKING CHANGE: ValueArray is gone, as is LinearizeArrayPass --------- Co-authored-by: Tatiana S <[email protected]>
1 parent 316a720 commit b3cdc4e

File tree

23 files changed

+123
-2597
lines changed

23 files changed

+123
-2597
lines changed

.github/workflows/unsoundness.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ jobs:
7474
--skip "dataflow::partial_value::test::meet_join_self_noop" \
7575
--skip "dataflow::partial_value::test::partial_value_type" \
7676
--skip "dataflow::partial_value::test::partial_value_valid" \
77-
--skip "linearize_array::test::implicit_clone" \
7877
--skip "merge_bbs::test::check_ext_id_wellformed" \
7978
--skip "monomorphize::test::test_recursion_module" \
8079
--skip "normalize_cfgs::test::check_ext_id_wellformed" \
81-
--skip "replace_types::linearize::test::value_array" \
8280
--skip "replace_types::test::dfg_conditional_case" \
8381
--skip "replace_types::test::module_func_cfg_call" \
8482
--skip "replace_types::test::op_to_call" \

hugr-core/src/ops/constant.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ pub(crate) mod test {
555555
};
556556
use crate::std_extensions::arithmetic::int_types::ConstInt;
557557
use crate::std_extensions::collections::array::{ArrayValue, array_type};
558-
use crate::std_extensions::collections::value_array::{VArrayValue, value_array_type};
558+
use crate::std_extensions::collections::borrow_array::{BArrayValue, borrow_array_type};
559559
use crate::{
560560
builder::{BuildError, DFGBuilder, Dataflow, DataflowHugr},
561561
extension::{
@@ -726,10 +726,9 @@ pub(crate) mod test {
726726
}
727727

728728
#[fixture]
729-
fn const_value_array_bool() -> Value {
730-
VArrayValue::new(bool_t(), [Value::true_val(), Value::false_val()]).into()
729+
fn const_borrow_array_bool() -> Value {
730+
BArrayValue::new(bool_t(), [Value::true_val(), Value::false_val()]).into()
731731
}
732-
733732
#[fixture]
734733
fn const_array_options() -> Value {
735734
let some_true = Value::some([Value::true_val()]);
@@ -739,11 +738,11 @@ pub(crate) mod test {
739738
}
740739

741740
#[fixture]
742-
fn const_value_array_options() -> Value {
741+
fn const_borrow_array_options() -> Value {
743742
let some_true = Value::some([Value::true_val()]);
744743
let none = Value::none(vec![bool_t()]);
745744
let elem_ty = SumType::new_option(vec![bool_t()]);
746-
VArrayValue::new(elem_ty.into(), [some_true, none]).into()
745+
BArrayValue::new(elem_ty.into(), [some_true, none]).into()
747746
}
748747

749748
#[rstest]
@@ -753,19 +752,19 @@ pub(crate) mod test {
753752
#[case(const_tuple(), Type::new_tuple(vec![usize_t(), bool_t()]), "const:seq:{")]
754753
#[case(const_array_bool(), array_type(2, bool_t()), "const:custom:array")]
755754
#[case(
756-
const_value_array_bool(),
757-
value_array_type(2, bool_t()),
758-
"const:custom:value_array"
755+
const_borrow_array_bool(),
756+
borrow_array_type(2, bool_t()),
757+
"const:custom:borrow_array"
759758
)]
760759
#[case(
761760
const_array_options(),
762761
array_type(2, SumType::new_option(vec![bool_t()]).into()),
763762
"const:custom:array"
764763
)]
765764
#[case(
766-
const_value_array_options(),
767-
value_array_type(2, SumType::new_option(vec![bool_t()]).into()),
768-
"const:custom:value_array"
765+
const_borrow_array_options(),
766+
borrow_array_type(2, SumType::new_option(vec![bool_t()]).into()),
767+
"const:custom:borrow_array"
769768
)]
770769
fn const_type(
771770
#[case] const_value: Value,
@@ -786,9 +785,9 @@ pub(crate) mod test {
786785
#[case(const_serialized_usize(), const_usize())]
787786
#[case(const_tuple_serialized(), const_tuple())]
788787
#[case(const_array_bool(), const_array_bool())]
789-
#[case(const_value_array_bool(), const_value_array_bool())]
788+
#[case(const_borrow_array_bool(), const_borrow_array_bool())]
790789
#[case(const_array_options(), const_array_options())]
791-
#[case(const_value_array_options(), const_value_array_options())]
790+
#[case(const_borrow_array_options(), const_borrow_array_options())]
792791
// Opaque constants don't get resolved into concrete types when running miri,
793792
// as the `typetag` machinery is not available.
794793
#[cfg_attr(miri, ignore)]

hugr-core/src/std_extensions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub fn std_reg() -> ExtensionRegistry {
2424
collections::list::EXTENSION.to_owned(),
2525
collections::borrow_array::EXTENSION.to_owned(),
2626
collections::static_array::EXTENSION.to_owned(),
27-
collections::value_array::EXTENSION.to_owned(),
2827
logic::EXTENSION.to_owned(),
2928
ptr::EXTENSION.to_owned(),
3029
]);

hugr-core/src/std_extensions/collections.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ pub mod array;
44
pub mod borrow_array;
55
pub mod list;
66
pub mod static_array;
7-
pub mod value_array;

hugr-core/src/std_extensions/collections/array/array_conversion.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,10 @@ mod tests {
247247
use crate::ops::{OpTrait, OpType};
248248
use crate::std_extensions::collections::array::Array;
249249
use crate::std_extensions::collections::borrow_array::BorrowArray;
250-
use crate::std_extensions::collections::value_array::ValueArray;
251250

252251
use super::*;
253252

254253
#[rstest]
255-
#[case(ValueArray, Array)]
256254
#[case(BorrowArray, Array)]
257255
fn test_convert_from_def<AK: ArrayKind, OtherAK: ArrayKind>(
258256
#[case] _kind: AK,
@@ -265,7 +263,6 @@ mod tests {
265263
}
266264

267265
#[rstest]
268-
#[case(ValueArray, Array)]
269266
#[case(BorrowArray, Array)]
270267
fn test_convert_into_def<AK: ArrayKind, OtherAK: ArrayKind>(
271268
#[case] _kind: AK,
@@ -278,7 +275,6 @@ mod tests {
278275
}
279276

280277
#[rstest]
281-
#[case(ValueArray, Array)]
282278
#[case(BorrowArray, Array)]
283279
fn test_convert_from<AK: ArrayKind, OtherAK: ArrayKind>(
284280
#[case] _kind: AK,
@@ -299,7 +295,6 @@ mod tests {
299295
}
300296

301297
#[rstest]
302-
#[case(ValueArray, Array)]
303298
#[case(BorrowArray, Array)]
304299
fn test_convert_into<AK: ArrayKind, OtherAK: ArrayKind>(
305300
#[case] _kind: AK,

hugr-core/src/std_extensions/collections/array/array_kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use crate::{
1616
/// [`GenericArrayOpDef`] or [`GenericArrayValue`]
1717
///
1818
/// Currently the available kinds of array are [`Array`] (the default one) and
19-
/// [`ValueArray`].
19+
/// [`BorrowArray`].
2020
///
2121
/// [`GenericArrayOpDef`]: super::GenericArrayOpDef
2222
/// [`GenericArrayValue`]: super::GenericArrayValue
2323
/// [`Array`]: super::Array
24-
/// [`ValueArray`]: crate::std_extensions::collections::value_array::ValueArray
24+
/// [`BorrowArray`]: crate::std_extensions::collections::borrow_array::BorrowArray
2525
pub trait ArrayKind:
2626
Clone
2727
+ Copy

hugr-core/src/std_extensions/collections/array/array_op.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ mod tests {
340340
use crate::std_extensions::arithmetic::float_types::float64_type;
341341
use crate::std_extensions::collections::array::Array;
342342
use crate::std_extensions::collections::borrow_array::BorrowArray;
343-
use crate::std_extensions::collections::value_array::ValueArray;
344343
use crate::{
345344
builder::{DFGBuilder, Dataflow, DataflowHugr, inout_sig},
346345
extension::prelude::{bool_t, qb_t},
@@ -351,7 +350,6 @@ mod tests {
351350

352351
#[rstest]
353352
#[case(Array)]
354-
#[case(ValueArray)]
355353
#[case(BorrowArray)]
356354
fn test_array_ops<AK: ArrayKind>(#[case] _kind: AK) {
357355
for def in GenericArrayOpDef::<AK>::iter() {
@@ -374,7 +372,6 @@ mod tests {
374372

375373
#[rstest]
376374
#[case(Array)]
377-
#[case(ValueArray)]
378375
#[case(BorrowArray)]
379376
/// Test building a HUGR involving a new_array operation.
380377
fn test_new_array<AK: ArrayKind>(#[case] _kind: AK) {
@@ -391,7 +388,6 @@ mod tests {
391388

392389
#[rstest]
393390
#[case(Array)]
394-
#[case(ValueArray)]
395391
#[case(BorrowArray)]
396392
/// Test building a HUGR involving an unpack operation.
397393
fn test_unpack<AK: ArrayKind>(#[case] _kind: AK) {
@@ -408,7 +404,6 @@ mod tests {
408404

409405
#[rstest]
410406
#[case(Array)]
411-
#[case(ValueArray)]
412407
#[case(BorrowArray)]
413408
fn test_get<AK: ArrayKind>(#[case] _kind: AK) {
414409
let size = 2;
@@ -434,7 +429,6 @@ mod tests {
434429

435430
#[rstest]
436431
#[case(Array)]
437-
#[case(ValueArray)]
438432
#[case(BorrowArray)]
439433
fn test_set<AK: ArrayKind>(#[case] _kind: AK) {
440434
let size = 2;
@@ -457,7 +451,6 @@ mod tests {
457451

458452
#[rstest]
459453
#[case(Array)]
460-
#[case(ValueArray)]
461454
#[case(BorrowArray)]
462455
fn test_swap<AK: ArrayKind>(#[case] _kind: AK) {
463456
let size = 2;
@@ -479,7 +472,6 @@ mod tests {
479472

480473
#[rstest]
481474
#[case(Array)]
482-
#[case(ValueArray)]
483475
#[case(BorrowArray)]
484476
fn test_pops<AK: ArrayKind>(#[case] _kind: AK) {
485477
let size = 2;
@@ -512,7 +504,6 @@ mod tests {
512504

513505
#[rstest]
514506
#[case(Array)]
515-
#[case(ValueArray)]
516507
#[case(BorrowArray)]
517508
fn test_discard_empty<AK: ArrayKind>(#[case] _kind: AK) {
518509
let size = 0;
@@ -531,7 +522,6 @@ mod tests {
531522

532523
#[rstest]
533524
#[case(Array)]
534-
#[case(ValueArray)]
535525
#[case(BorrowArray)]
536526
/// Initialize an array operation where the element type is not from the prelude.
537527
fn test_non_prelude_op<AK: ArrayKind>(#[case] _kind: AK) {

hugr-core/src/std_extensions/collections/array/array_repeat.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ mod tests {
184184

185185
use crate::std_extensions::collections::array::Array;
186186
use crate::std_extensions::collections::borrow_array::BorrowArray;
187-
use crate::std_extensions::collections::value_array::ValueArray;
188187
use crate::{
189188
extension::prelude::qb_t,
190189
ops::{OpTrait, OpType},
@@ -195,7 +194,6 @@ mod tests {
195194

196195
#[rstest]
197196
#[case(Array)]
198-
#[case(ValueArray)]
199197
#[case(BorrowArray)]
200198
fn test_repeat_def<AK: ArrayKind>(#[case] _kind: AK) {
201199
let op = GenericArrayRepeat::<AK>::new(qb_t(), 2);
@@ -206,7 +204,6 @@ mod tests {
206204

207205
#[rstest]
208206
#[case(Array)]
209-
#[case(ValueArray)]
210207
#[case(BorrowArray)]
211208
fn test_repeat<AK: ArrayKind>(#[case] _kind: AK) {
212209
let size = 2;

hugr-core/src/std_extensions/collections/array/array_scan.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ mod tests {
244244
use crate::extension::prelude::usize_t;
245245
use crate::std_extensions::collections::array::Array;
246246
use crate::std_extensions::collections::borrow_array::BorrowArray;
247-
use crate::std_extensions::collections::value_array::ValueArray;
248247
use crate::{
249248
extension::prelude::{bool_t, qb_t},
250249
ops::{OpTrait, OpType},
@@ -255,7 +254,6 @@ mod tests {
255254

256255
#[rstest]
257256
#[case(Array)]
258-
#[case(ValueArray)]
259257
#[case(BorrowArray)]
260258
fn test_scan_def<AK: ArrayKind>(#[case] _kind: AK) {
261259
let op = GenericArrayScan::<AK>::new(bool_t(), qb_t(), vec![usize_t()], 2);
@@ -266,7 +264,6 @@ mod tests {
266264

267265
#[rstest]
268266
#[case(Array)]
269-
#[case(ValueArray)]
270267
#[case(BorrowArray)]
271268
fn test_scan_map<AK: ArrayKind>(#[case] _kind: AK) {
272269
let size = 2;
@@ -292,7 +289,6 @@ mod tests {
292289

293290
#[rstest]
294291
#[case(Array)]
295-
#[case(ValueArray)]
296292
#[case(BorrowArray)]
297293
fn test_scan_accs<AK: ArrayKind>(#[case] _kind: AK) {
298294
let size = 2;

hugr-core/src/std_extensions/collections/array/array_value.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,11 @@ mod test {
147147

148148
use crate::std_extensions::collections::array::Array;
149149
use crate::std_extensions::collections::borrow_array::BorrowArray;
150-
use crate::std_extensions::collections::value_array::ValueArray;
151150

152151
use super::*;
153152

154153
#[rstest]
155154
#[case(Array)]
156-
#[case(ValueArray)]
157155
#[case(BorrowArray)]
158156
fn test_array_value<AK: ArrayKind>(#[case] _kind: AK) {
159157
let array_value = GenericArrayValue::<AK>::new(usize_t(), vec![ConstUsize::new(3).into()]);

0 commit comments

Comments
 (0)