Repository navigation
Cycle checking for trait specifications #2661
Replies: 3 comments 7 replies
|
Agreed that there're reasonable uses of trait-level recursion that we cannot easily specify and reason about in Verus.
I think it might be more precise to say "without writing any explicit loops or recursive functions"? After Rust's trait resolution (and monomorphization), |
|
There are 2 difficulties with this example:
Let's ignore the first one for now. The second one is the more serious problem. So, ignore exec functions and only look at spec functions. The trait definitions for However, the edge from It's because the "ensures" clause on traits are extendible. The only way to define If we make the ensures-clause for |
|
FWIW we are currently running into the Iter cycle for zip. Would it be hard to implement a „hotfix„? |
Uh oh!
There was an error while loading. Please reload this page.
Ideally, we would like to write specification functions that describe the effects of various Rust trait functions, and the relationships between such traits. However, in executable Rust code, you can write code that goes into an infinite loop based on just the standard Rust Iterator/IntoIterator/FromIterator trait declarations, without writing any loops or recursive functions:
If we apply our usual approach to equipping each trait with a spec fn that mirrors the exec fn, then Verus rejects this as a potential cycle, which as the example above shows, is a real risk. Nonetheless, we do want to be able to specify and reason about "well behaved" implementations of these traits.
All reactions