11warning: function pointers are not nullable, so checking them for null will always return false
2- --> $DIR/ptr_null_checks.rs:7 :8
2+ --> $DIR/ptr_null_checks.rs:10 :8
33 |
44LL | if (fn_ptr as *mut ()).is_null() {}
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,124 +8,148 @@ LL | if (fn_ptr as *mut ()).is_null() {}
88 = note: `#[warn(useless_ptr_null_checks)]` on by default
99
1010warning: function pointers are not nullable, so checking them for null will always return false
11- --> $DIR/ptr_null_checks.rs:9 :8
11+ --> $DIR/ptr_null_checks.rs:12 :8
1212 |
1313LL | if (fn_ptr as *const u8).is_null() {}
1414 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515 |
1616 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
1717
1818warning: function pointers are not nullable, so checking them for null will always return false
19- --> $DIR/ptr_null_checks.rs:11 :8
19+ --> $DIR/ptr_null_checks.rs:14 :8
2020 |
2121LL | if (fn_ptr as *const ()) == std::ptr::null() {}
2222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323 |
2424 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
2525
2626warning: function pointers are not nullable, so checking them for null will always return false
27- --> $DIR/ptr_null_checks.rs:13 :8
27+ --> $DIR/ptr_null_checks.rs:16 :8
2828 |
2929LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
3030 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3131 |
3232 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
3333
3434warning: function pointers are not nullable, so checking them for null will always return false
35- --> $DIR/ptr_null_checks.rs:15 :8
35+ --> $DIR/ptr_null_checks.rs:18 :8
3636 |
3737LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939 |
4040 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
4141
4242warning: function pointers are not nullable, so checking them for null will always return false
43- --> $DIR/ptr_null_checks.rs:17 :8
43+ --> $DIR/ptr_null_checks.rs:20 :8
4444 |
4545LL | if <*const _>::is_null(fn_ptr as *const ()) {}
4646 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747 |
4848 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
4949
5050warning: function pointers are not nullable, so checking them for null will always return false
51- --> $DIR/ptr_null_checks.rs:19 :8
51+ --> $DIR/ptr_null_checks.rs:22 :8
5252 |
5353LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
5454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5555 |
5656 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
5757
5858warning: function pointers are not nullable, so checking them for null will always return false
59- --> $DIR/ptr_null_checks.rs:21 :8
59+ --> $DIR/ptr_null_checks.rs:24 :8
6060 |
6161LL | if (fn_ptr as fn() as *const ()).is_null() {}
6262 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6363 |
6464 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
6565
66+ warning: function pointers are not nullable, so checking them for null will always return false
67+ --> $DIR/ptr_null_checks.rs:26:8
68+ |
69+ LL | if (c_fn as *const fn()).is_null() {}
70+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+ |
72+ = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
73+
6674warning: references are not nullable, so checking them for null will always return false
67- --> $DIR/ptr_null_checks.rs:25 :8
75+ --> $DIR/ptr_null_checks.rs:30 :8
6876 |
6977LL | if (&mut 8 as *mut i32).is_null() {}
7078 | ^------^^^^^^^^^^^^^^^^^^^^^^^
7179 | |
7280 | expression has type `&mut i32`
7381
7482warning: references are not nullable, so checking them for null will always return false
75- --> $DIR/ptr_null_checks.rs:27 :8
83+ --> $DIR/ptr_null_checks.rs:32 :8
7684 |
7785LL | if (&8 as *const i32).is_null() {}
7886 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^
7987 | |
8088 | expression has type `&i32`
8189
8290warning: references are not nullable, so checking them for null will always return false
83- --> $DIR/ptr_null_checks.rs:29 :8
91+ --> $DIR/ptr_null_checks.rs:34 :8
8492 |
8593LL | if (&8 as *const i32) == std::ptr::null() {}
8694 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8795 | |
8896 | expression has type `&i32`
8997
9098warning: references are not nullable, so checking them for null will always return false
91- --> $DIR/ptr_null_checks.rs:32 :8
99+ --> $DIR/ptr_null_checks.rs:37 :8
92100 |
93101LL | if (ref_num as *const i32) == std::ptr::null() {}
94102 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95103 | |
96104 | expression has type `&i32`
97105
98106warning: references are not nullable, so checking them for null will always return false
99- --> $DIR/ptr_null_checks.rs:34 :8
107+ --> $DIR/ptr_null_checks.rs:39 :8
100108 |
101109LL | if (b"\0" as *const u8).is_null() {}
102110 | ^-----^^^^^^^^^^^^^^^^^^^^^^^^
103111 | |
104112 | expression has type `&[u8; 1]`
105113
106114warning: references are not nullable, so checking them for null will always return false
107- --> $DIR/ptr_null_checks.rs:36 :8
115+ --> $DIR/ptr_null_checks.rs:41 :8
108116 |
109117LL | if ("aa" as *const str).is_null() {}
110118 | ^----^^^^^^^^^^^^^^^^^^^^^^^^^
111119 | |
112120 | expression has type `&str`
113121
114122warning: references are not nullable, so checking them for null will always return false
115- --> $DIR/ptr_null_checks.rs:38 :8
123+ --> $DIR/ptr_null_checks.rs:43 :8
116124 |
117125LL | if (&[1, 2] as *const i32).is_null() {}
118126 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
119127 | |
120128 | expression has type `&[i32; 2]`
121129
122130warning: references are not nullable, so checking them for null will always return false
123- --> $DIR/ptr_null_checks.rs:40 :8
131+ --> $DIR/ptr_null_checks.rs:45 :8
124132 |
125133LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
126134 | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127135 | |
128136 | expression has type `&mut [i32; 2]`
129137
130- warning: 16 warnings emitted
138+ warning: references are not nullable, so checking them for null will always return false
139+ --> $DIR/ptr_null_checks.rs:47:8
140+ |
141+ LL | if (static_i32() as *const i32).is_null() {}
142+ | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
143+ | |
144+ | expression has type `&i32`
145+
146+ warning: references are not nullable, so checking them for null will always return false
147+ --> $DIR/ptr_null_checks.rs:49:8
148+ |
149+ LL | if (&*{ static_i32() } as *const i32).is_null() {}
150+ | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
151+ | |
152+ | expression has type `&i32`
153+
154+ warning: 19 warnings emitted
131155
0 commit comments