-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[proofs] Initial commit #652
base: main
Are you sure you want to change the base?
Conversation
2a7f1b4
to
0ccf1e2
Compare
/// field, which is `pub`. Per the reference [2], this means that the | ||
/// `#[repr(transparent)]` attribute is "considered part of the public ABI". | ||
/// `Wrapping<T>` is `#[repr(transparent)]` and has a single `T` field, | ||
/// which is `pub`. [1] Per axiom-repr-transparent-layout-validity, we may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should axiom-repr-transparent-layout-validity
perhaps be a intradoc link? It'd give us a modest defense against proof rot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh good idea. I'll also need to make sure that our safety doc comments are actually being parsed by rustdoc.
//! ## transparent-layout-validity | ||
//! | ||
//! A type, `T`, has the property `transparent-layout-validity(U)` if the | ||
//! following all hold: | ||
//! - `T` and `U` have the same alignment | ||
//! - For all `t: *const T`, `let u = t as *const U` is valid and | ||
//! `size_of_val_raw(t) == size_of_val_raw(u)`. | ||
//! - For all `u: *const U`, `let t = *const T` is valid and `size_of_val_raw(u) | ||
//! == size_of_val_raw(t)`. | ||
//! - For all `(t, u): (*const T, *const U)` where `size_of_val_raw(t) == | ||
//! size_of_val_raw(u)`: | ||
//! - `t` and `u` refer to `UnsafeCell`s at the same byte ranges. | ||
//! - If `*t` contains a valid `T`, that implies that `*u` contains a valid | ||
//! `U`. | ||
//! - If `*u` contains a valid `U`, that implies that `*t` contains a valid | ||
//! `T`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concretely:
/// A type, `T`, has the property `transparent-layout-validity(U)` if the
/// following all hold:
/// - `T` and `U` have the same alignment
/// - For all `t: *const T`, `let u = t as *const U` is valid and
/// `size_of_val_raw(t) == size_of_val_raw(u)`.
/// - For all `u: *const U`, `let t = *const T` is valid and `size_of_val_raw(u)
/// == size_of_val_raw(t)`.
/// - For all `(t, u): (*const T, *const U)` where `size_of_val_raw(t) ==
/// size_of_val_raw(u)`:
/// - `t` and `u` refer to `UnsafeCell`s at the same byte ranges.
/// - If `*t` contains a valid `T`, that implies that `*u` contains a valid
/// `U`.
/// - If `*u` contains a valid `U`, that implies that `*t` contains a valid
/// `T`.
#[allow(unsused)] // This only exists as an anchor for intradoc links.
const TRANSPARENT_LAYOUT_VALIDIDTY: () = ();
0ccf1e2
to
06e53b1
Compare
Add axioms and lemmas which are useful in proving the soundness of some trait impls. Makes progress on #429
06e53b1
to
55cdd4d
Compare
Add axioms and lemmas which are useful in proving the soundness of some trait impls.
Makes progress on #429