-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Replace pointer castings (as
) by their API equivalent
#11818
Merged
Merged
Conversation
This file contains 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
doonv
reviewed
Feb 11, 2024
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.
I don't think this is worth bumping up the MSRV.
That's a good point. I'll close this until the MSRV is 1.76 or above. |
Bevy's MSRV policy is "latest stable". This is as good a reason as any to bump it. |
alice-i-cecile
added
C-Code-Quality
A section of code that is hard to understand or change
A-Pointers
Relating to Bevy pointer abstractions
labels
Feb 11, 2024
james7132
approved these changes
Feb 11, 2024
hymm
added
the
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
label
Feb 11, 2024
hymm
approved these changes
Feb 11, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Apr 10, 2024
# Objective - [`clippy::ref_as_ptr`](https://rust-lang.github.io/rust-clippy/master/index.html#/ref_as_ptr) prevents you from directly casting references to pointers, requiring you to use `std::ptr::from_ref` instead. This prevents you from accidentally converting an immutable reference into a mutable pointer (`&x as *mut T`). - Follow up to #11818, now that our [`rust-version` is 1.77](https://github.com/bevyengine/bevy/blob/11817f4ba4cca8e956c50f6d919e38f601ecc5cf/Cargo.toml#L14). ## Solution - Enable lint and fix all warnings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-ECS
Entities, components, systems, and events
A-Pointers
Relating to Bevy pointer abstractions
C-Code-Quality
A section of code that is hard to understand or change
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
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.
Objective
Since rust
1.76
,ptr::from_ref
andptr::from_mut
are stable.This PR replaces code that use
as
casting by one ofptr::from_ref
,ptr::from_mut
,cast_mut
,cast_const
, orcast
methods, which are less error-prone.Solution
1.76.0
ptr_as_ptr
ptr_cast_constness
ref_as_ptr
(I fix all warnings for this one, but it requires rust 1.77 to be enabled)