about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-03 17:29:06 +0200
committerGitHub <noreply@github.com>2023-08-03 17:29:06 +0200
commit8f4f476a54fc12eec0c969ac65086976fcd7d318 (patch)
treeaa2c0e33fff5491bdff7be8aed12f7113781618c
parentff27f9095f5edebdd03e885cb4df74ad32df30dc (diff)
parent7ef1a54ffeefc3f3e8e18afc2dbb9ed21b890d8e (diff)
downloadrust-8f4f476a54fc12eec0c969ac65086976fcd7d318.tar.gz
rust-8f4f476a54fc12eec0c969ac65086976fcd7d318.zip
Rollup merge of #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 https://github.com/rust-lang/rust/issues/113601
cc ```@est31```
-rw-r--r--clippy_lints/src/renamed_lints.rs2
-rw-r--r--tests/ui/rename.fixed4
-rw-r--r--tests/ui/rename.rs2
-rw-r--r--tests/ui/rename.stderr4
4 files changed, 6 insertions, 6 deletions
diff --git a/clippy_lints/src/renamed_lints.rs b/clippy_lints/src/renamed_lints.rs
index 49bdc679604..fc1fabcc0ae 100644
--- a/clippy_lints/src/renamed_lints.rs
+++ b/clippy_lints/src/renamed_lints.rs
@@ -43,7 +43,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
     ("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
     ("clippy::forget_copy", "forgetting_copy_types"),
     ("clippy::forget_ref", "forgetting_references"),
-    ("clippy::fn_null_check", "incorrect_fn_null_checks"),
+    ("clippy::fn_null_check", "useless_ptr_null_checks"),
     ("clippy::into_iter_on_array", "array_into_iter"),
     ("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
     ("clippy::invalid_ref", "invalid_value"),
diff --git a/tests/ui/rename.fixed b/tests/ui/rename.fixed
index 8ec19b120d1..8257bf2947a 100644
--- a/tests/ui/rename.fixed
+++ b/tests/ui/rename.fixed
@@ -38,7 +38,7 @@
 #![allow(for_loops_over_fallibles)]
 #![allow(forgetting_copy_types)]
 #![allow(forgetting_references)]
-#![allow(incorrect_fn_null_checks)]
+#![allow(useless_ptr_null_checks)]
 #![allow(array_into_iter)]
 #![allow(invalid_atomic_ordering)]
 #![allow(invalid_value)]
@@ -92,7 +92,7 @@
 #![warn(for_loops_over_fallibles)]
 #![warn(forgetting_copy_types)]
 #![warn(forgetting_references)]
-#![warn(incorrect_fn_null_checks)]
+#![warn(useless_ptr_null_checks)]
 #![warn(array_into_iter)]
 #![warn(invalid_atomic_ordering)]
 #![warn(invalid_value)]
diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs
index 51a5976eb61..6569dad18d4 100644
--- a/tests/ui/rename.rs
+++ b/tests/ui/rename.rs
@@ -38,7 +38,7 @@
 #![allow(for_loops_over_fallibles)]
 #![allow(forgetting_copy_types)]
 #![allow(forgetting_references)]
-#![allow(incorrect_fn_null_checks)]
+#![allow(useless_ptr_null_checks)]
 #![allow(array_into_iter)]
 #![allow(invalid_atomic_ordering)]
 #![allow(invalid_value)]
diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr
index e420ea1d2ad..57e991e5695 100644
--- a/tests/ui/rename.stderr
+++ b/tests/ui/rename.stderr
@@ -246,11 +246,11 @@ error: lint `clippy::forget_ref` has been renamed to `forgetting_references`
 LL | #![warn(clippy::forget_ref)]
    |         ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references`
 
-error: lint `clippy::fn_null_check` has been renamed to `incorrect_fn_null_checks`
+error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks`
   --> $DIR/rename.rs:95:9
    |
 LL | #![warn(clippy::fn_null_check)]
-   |         ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `incorrect_fn_null_checks`
+   |         ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks`
 
 error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
   --> $DIR/rename.rs:96:9