summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/ptr_null_checks.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/lint/ptr_null_checks.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/ptr_null_checks.rs')
-rw-r--r--tests/ui/lint/ptr_null_checks.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/ui/lint/ptr_null_checks.rs b/tests/ui/lint/ptr_null_checks.rs
index e677ea309..3028084e9 100644
--- a/tests/ui/lint/ptr_null_checks.rs
+++ b/tests/ui/lint/ptr_null_checks.rs
@@ -38,15 +38,15 @@ fn main() {
if (&mut 8 as *mut i32).is_null() {}
//~^ WARN references are not nullable
if ptr::from_mut(&mut 8).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (&8 as *const i32).is_null() {}
//~^ WARN references are not nullable
if ptr::from_ref(&8).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if ptr::from_ref(&8).cast_mut().is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (&8 as *const i32) == std::ptr::null() {}
//~^ WARN references are not nullable
let ref_num = &8;
@@ -65,6 +65,12 @@ fn main() {
if (&*{ static_i32() } as *const i32).is_null() {}
//~^ WARN references are not nullable
+ // ---------------- Functions -------------------
+ if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {}
+ //~^ WARN call is never null
+ if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {}
+ //~^ WARN call is never null
+
// ----------------------------------------------
const ZPTR: *const () = 0 as *const _;
const NOT_ZPTR: *const () = 1 as *const _;