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.
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
Specify bit validity and padding of some types #1392
Specify bit validity and padding of some types #1392
Changes from all commits
510e75c
e2385f9
d1850ea
2e43046
2f82b7f
61c6349
bbc8063
d3a66eb
5795f3a
80ec146
8f92a7d
746a359
ea1110b
13b5af8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@RalfJung For my own edification, how does this interact with pointer-to-integer
as
casts? I can imagine a few possibilities (not mutually exclusive):as
casts are sound, but transmutations are not necessarily sound (even though you can emulate a transmutation by doing anas
cast followed by a transmutation fromusize
)as
casts probably shouldn't have been allowed in safe Rust, but it's too lateThere 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.
The current working model is that
as
casts are special:ptr as usize
is like https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.expose_addrusize as ptr
is like https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.htmlIn contrast:
Here, "transmute" refers to
transmute
but also any other way to re-interpret bytes at a different type, such as type punning through union field accesses and raw pointer casts.All of these operations are safe and sound, but as their docs show, they behave quite differently and that can affect the soundness of later code that uses the values they produce.
Note that this is a prototype model, which has some unresolved problems and which is very much not stabilized.
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.
Okay that all makes sense, thanks!
I always assume that of everything in this space unless documented otherwise :)