Commit 3b19f8d
committed
Implement Structural for Result<T, E>
Option<T> was already marked Structural (added incidentally in #1695),
but Result<T, E>, the other pervasive std type raised in #178, was not.
This meant generic code with a `T: Structural` bound (needed to connect
exec-mode == to spec-mode ==) could not be instantiated with Result,
even though Result's PartialEq is already fieldwise/structural.
Fix: add `unsafe impl<T: Structural, E: Structural> Structural for
core::result::Result<T, E> {}` in builtin/src/lib.rs, mirroring the
existing Option impl. Result is a core (not alloc/std) type, so this
needs no extra dependency and sidesteps the no_std/orphan-rule concern
raised in the issue for alloc-backed types like Vec/String.
Verified:
- vstd still verifies fully (2044/0) after the change
- New regression test in rust_verify_test/tests/structural.rs fails
without the fix (E0277: Result<u32,u32> does not implement
Structural) and passes with it
- 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 test suites all pass with no
regressions
Assisted-by: Claude Code:claude-sonnet-51 parent 74e001a commit 3b19f8d
2 files changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
| 859 | + | |
| 860 | + | |
859 | 861 | | |
860 | 862 | | |
861 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
83 | 101 | | |
84 | 102 | | |
85 | 103 | | |
| |||
0 commit comments