-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use cast instead of transmute #47
Conversation
Thanks for the PR. I'm fine with the change, that said I'd like to understand the motivation for the change a bit better. For example one thing I like about |
src/unsafe_self_cell.rs
Outdated
ptr: unsafe { | ||
transmute::<*mut JoinedCell<Owner, Dependent>, *mut u8>(self.joined_ptr.as_ptr()) | ||
}, | ||
ptr: self.joined_ptr.as_ptr().cast(), |
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.
Please specify the cast result type here.
Completely unrelated, I just realized you are the creator of gifski a project I've used quite a bit, thank you for the great project <3 |
The idea behind this is that
In your case I think all transmutes are correct. However in general there are cases where transmute of exotically sized pointers is not well-defined (they don't have guaranteed layouts), but cast (which can change pointer layout) is allowed. |
Sounds good. I'm looking into the miri failure that seems unrelated to this change. Please update the PR to be compatible with rustc 1.36 as tested by |
You should be able to rebase on |
The CI for this project is a bit dated, and the triggers were wonky. I took the liberty of fixing it on main and rebasing your branch. Change looks good otherwise. |
|
Sure, I've replaced that with a regular pointer cast. BTW, I expect 1.36, and all rust versions below 1.56, to be completely dead and unusable: https://lib.rs/stats#rustc |
I'd be careful about such assumptions, also I have an upstream dependency that specifically asked for this feature #30. As long as it seems reasonably possible to keep the minimum required rustc version the same, I plan on doing so. |
I've merged the change, thanks for the PR. I'm not sure if this change has any immediate impact on users, do you think a new release is required? |
Thanks. No need to rush with a release. |
NonNull
supportscast()
, so there's no need fortransmute
.