Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Oct 12, 2023

try_cast_into attempts to cast a Ptr<[u8]> into a Ptr<U> where U: ?Sized + KnownLayout, and will be built upon in future commits as a building block of TryFromBytes.

Because try_cast_into performs a runtime check to validate alignment, this requires disabling Miri's "symbolic alignment check" feature. While it would be possible to run both with and without that feature in order to still test other code using symbolic alignment checking, I don't think that the benefit is worth a) the complexity of passing the information necessary for certain tests to not run under symbolic alignment checking and, b) the extra CI time to run Miri tests twice.

Makes progress on #29

joshlf and others added 2 commits October 12, 2023 21:41
`Ptr` is like `NonNull`, but has many restrictions which make it so that
using a `Ptr` in unsafe code requires much simpler soundness proofs. In
particular, in a future commit, we will add support for a
`try_cast_into<U>` method where `U: ?Sized + KnownLayout`, which is a
building block of `TryFromBytes`.

Makes progress on #29
`try_cast_into` attempts to cast a `Ptr<[u8]>` into a `Ptr<U>` where `U:
?Sized + KnownLayout`, and will be built upon in future commits as a
building block of `TryFromBytes`.

Because `try_cast_into` performs a runtime check to validate alignment,
this requires disabling Miri's "symbolic alignment check" feature. While
it would be possible to run both with and without that feature in order
to still test other code using symbolic alignment checking, I don't
think that the benefit is worth a) the complexity of passing the
information necessary for certain tests to not run under symbolic
alignment checking and, b) the extra CI time to run Miri tests twice.

Makes progress on #29
@joshlf joshlf force-pushed the try-cast-from-method branch from b407a56 to e382bc2 Compare October 12, 2023 21:41
@joshlf joshlf mentioned this pull request Oct 16, 2023
@joshlf joshlf force-pushed the try-cast-from branch 3 times, most recently from 2528a71 to b8254af Compare October 17, 2023 11:43
Base automatically changed from try-cast-from to main October 23, 2023 16:42
@joshlf
Copy link
Member Author

joshlf commented Oct 24, 2023

Implemented in #406

@joshlf joshlf closed this Oct 24, 2023
@joshlf joshlf deleted the try-cast-from-method branch October 24, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant