Implement safe reference casts#235
Merged
Merged
Conversation
90118e5 to
e676c41
Compare
LaurenzV
approved these changes
May 27, 2026
| "checked_cast_ref requires source and destination to have the same size" | ||
| ); | ||
| assert!( | ||
| align_of::<Src>() >= align_of::<Dst>(), |
Collaborator
There was a problem hiding this comment.
I guess might be obvious to others but it wasn't to me, this works because the alignment is always a power of 2, right? Otherwise, it wouldn't for example work if you could have an alignment of 5 and 4. Could you maybe add a comment linking to that https://doc.rust-lang.org/stable/reference/type-layout.html#size-and-alignment?
Shnatsel
added a commit
to Shnatsel/fearless_simd
that referenced
this pull request
May 27, 2026
Merged origin/main commit 0d13b0a. The merge applied cleanly.
Shnatsel
added a commit
to Shnatsel/fearless_simd
that referenced
this pull request
May 27, 2026
Regenerate the branch-added AVX512 module so reference casts use checked_cast_ref and checked_cast_mut. Also apply the float bit-pattern assertion style from PR linebender#235 to the branch-added f32x16 interleaved-load test. Validation: cargo test
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.
Stacked on top of #234
reimplements bytemuck::cast/cast_mut but more clearly zero-cost and failing at build time rather than at runtime
then uses those functions to expunge the remaining unchecked
transmutecallsand bans unchecked transmute via clippy