-
Notifications
You must be signed in to change notification settings - Fork 1.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
Special-case suggestions for null pointers constness cast #13369
Conversation
30fa55f
to
bb2b65a
Compare
For the second point, it sounds reasonable to me to lint on that too as part of the same lint (although the description would then need to be adapted a fair bit since it's drifting away from the original intent of linting on |
bb2b65a
to
ca93ebd
Compare
I've added it in a second commit. |
ca93ebd
to
0059d8a
Compare
bb52c83
to
99e497c
Compare
This covers two cases: - `core::ptr::null::<T>().cast_mut()` -> `core::ptr::null_mut::<T>()` - `core::ptr::null_mut::<T>().cast_const()` -> `core::ptr::null::<T>()`
99e497c
to
3060873
Compare
Also, @y21, messages for |
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.
This looks good to me as is. I think having these specific lint messages is fine 👍
Thank you! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This implements the suggestions from #13361. It fits into the existing
ptr_cast_constness
lint, as this is a specialized version. However,null()
andnull_mut()
were already present in Rust 1.0 and there is no reason not to apply this lint. I guess this is only a minor documentation issue that can be ignored.core::ptr::null::<T>().cast_mut()
(could be made intocore::ptr::null_mut::<T>()
) andcotr::ptr::null_mut::<T>().cast_const()
(could be made intocore::ptr::null::<T>()
) cases. Should they be covered? If they should, here or in a separate PR?changelog: [
ptr_cast_constness
]: special-case suggestions for null pointers constness castFix #13361