Skip to content

Commit df710e3

Browse files
authored
Rollup merge of rust-lang#113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillot
Expand, rename and improve `incorrect_fn_null_checks` lint This PR, - firstly, expand the lint by now linting on references - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks` - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut` Fixes rust-lang#113601 cc ```@est31```
2 parents 1674473 + 6e92e8c commit df710e3

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

core/src/ptr/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ pub const fn from_ref<T: ?Sized>(r: &T) -> *const T {
710710
#[inline(always)]
711711
#[must_use]
712712
#[unstable(feature = "ptr_from_ref", issue = "106116")]
713+
#[rustc_diagnostic_item = "ptr_from_mut"]
713714
pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
714715
r
715716
}

core/src/ptr/mut_ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl<T: ?Sized> *mut T {
5454
/// Casts to a pointer of another type.
5555
#[stable(feature = "ptr_cast", since = "1.38.0")]
5656
#[rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0")]
57+
#[rustc_diagnostic_item = "ptr_cast"]
5758
#[inline(always)]
5859
pub const fn cast<U>(self) -> *mut U {
5960
self as _

0 commit comments

Comments
 (0)