Commit 5106064
committed
Implement Structural for tuples and fixed-size arrays
Same gap as Result<T,E>/Option<T> (issue #178): both are pervasive
core types with compiler-derived fieldwise/elementwise PartialEq, but
had no Structural impl, so a `T: Structural` generic bound couldn't be
instantiated with them.
- Tuples: mirrors core's own tuple_impls! (library/core/src/tuple.rs),
which provides PartialEq up to arity 12.
- Arrays: [T; N] is represented differently in VIR (an SMT function,
not a datatype) from tuples/structs, but Structural's soundness
argument doesn't depend on that representation - Verus compiles
exec == directly to the identical spec-level == for any type where
rustc's own is_structural_eq_shallow query holds (see
rust_to_vir_base.rs::is_smt_equality), which already covers arrays
of Structural elements (the same query that allows array literals in
match patterns). Confirmed via a real generic-bound regression test
requiring no group_array_axioms broadcast.
Verified:
- vstd still verifies fully (2043/0) after the change
- New regression tests in rust_verify_test/tests/structural.rs
(test_tuple_is_structural, test_array_is_structural)
- structural.rs, eq_cmp.rs, partial_eq.rs, operators.rs, option.rs,
results.rs, adts.rs, impl.rs, marker_traits.rs, generics.rs,
external_type_specification.rs, traits.rs, arrays.rs,
mut_refs_slices_arrays.rs test suites all pass with no regressions
Assisted-by: Claude Code:claude-sonnet-51 parent 3b19f8d commit 5106064
2 files changed
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
861 | 883 | | |
862 | 884 | | |
863 | 885 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
101 | 137 | | |
102 | 138 | | |
103 | 139 | | |
| |||
0 commit comments