Provide Specs for the Standard Library#1249
Open
juliand665 wants to merge 50 commits intoviperproject:masterfrom
Open
Provide Specs for the Standard Library#1249juliand665 wants to merge 50 commits intoviperproject:masterfrom
juliand665 wants to merge 50 commits intoviperproject:masterfrom
Conversation
Contributor
That's exciting stuff! Would this also be possible for |
Contributor
Author
Sure! For the values so far, size and alignment seem to be the same, so that should be really simple. Interestingly, it seems that |
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Nov 24, 2022
Aurel300
reviewed
Jan 16, 2023
Aurel300
reviewed
Jan 16, 2023
Aurel300
reviewed
Jan 16, 2023
This was referenced Feb 2, 2023
includes inheritance of postconditions and auto trait "transitivity"
have to desugar this manually since prusti syntax breaks rust's macro parsing
Contributor
Author
|
Oh yeah, to establish a link: this resolves #941! |
Aurel300
reviewed
Apr 3, 2023
|
is this something that could be partially merged? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of my thesis under @Aurel300, this pull request adds specifications to the most popular types & functions in the Rust Standard Library. I am using data gathered through qrates to inform decisions on what specs to prioritize, along with a sense of logical units, e.g. covering all members of the unconstrained
Option<T>orResult<T, E>impls, rather than only specifying the subset of these methods that sees the most usage.Outline of Planned & Completed Specifications
These specs are very much a work in progress and far from complete at the moment, though what is there should be sound.
core::option::Optioncore::result::Resultcore::clone::Clonecore::default::Defaultspecific default values
(),bool,char, numbers (the types specified here)core::ops::DerefThis is currently blocked due to #1221.
core::ops::Index/core::ops::IndexMutThis is similarly blocked due to #1221.
core::ops::Trycore::option::Optioncore::option::Resultcore::mem::size_ofcore::convert::From/IntoSlices/Arrays
usize(built-in)Indexing is currently blocked due to #1221.
alloc::vec::VecDerefas slice (Error when using pure functions that return a reference #1221)as_slice(Error when using pure functions that return a reference #1221)vec!macro (requires unsizing from above, but very simple given that!)alloc::string::StringDerefasstr(Error when using pure functions that return a reference #1221)as_str(Error when using pure functions that return a reference #1221)&strtoStringconversion usingFrom/IntoI envision Strings and Vecs to work very similarly, mostly powered by a pure
as_str/as_slicethat acts as the source of truth. Unfortunately, that approach (like so much other stuff) is currently blocked, but I think the issue is so fundamental that it's better to just resolve it directly than to find a temporary workaround.core::cmp::PartialEq/core::cmp::PartialOrdThese are currently blocked due to #1311.
Ranges
containson inclusive & half-open ranges, for loops & invariants (Inheritance of Purity from Trait Specs #1311)core::opsBinary Ops for ReferencesThese operations don't have blanket impls for when one or both sides are a reference, but their implementations are unified using macros, which probably makes sense for us to replicate.
Smart Pointers (e.g.
alloc::rc::Rc)This fundamentally relies on
Derefand is thus also blocked by #1221.Once that is resolved, specifying their
Derefimplementation as pure and expressing transfer into and out of a box via e.g.ensures(old(x) === snap(result.deref()))should go a long way towards specifying this type usefully.Note that
Boxalready has builtin support in Prusti, partly because Rust itself already treats it specially (e.g. that*boxcan move out of the box).