11warning: function pointers are not nullable, so checking them for null will always return false
2- --> $DIR/ptr_null_checks.rs:12 :8
2+ --> $DIR/ptr_null_checks.rs:14 :8
33 |
44LL | if (fn_ptr as *mut ()).is_null() {}
55 | ^------^^^^^^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | if (fn_ptr as *mut ()).is_null() {}
1010 = note: `#[warn(useless_ptr_null_checks)]` on by default
1111
1212warning: function pointers are not nullable, so checking them for null will always return false
13- --> $DIR/ptr_null_checks.rs:14 :8
13+ --> $DIR/ptr_null_checks.rs:16 :8
1414 |
1515LL | if (fn_ptr as *const u8).is_null() {}
1616 | ^------^^^^^^^^^^^^^^^^^^^^^^^^
@@ -20,7 +20,7 @@ LL | if (fn_ptr as *const u8).is_null() {}
2020 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
2121
2222warning: function pointers are not nullable, so checking them for null will always return false
23- --> $DIR/ptr_null_checks.rs:16 :8
23+ --> $DIR/ptr_null_checks.rs:18 :8
2424 |
2525LL | if (fn_ptr as *const ()) == std::ptr::null() {}
2626 | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL | if (fn_ptr as *const ()) == std::ptr::null() {}
3030 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
3131
3232warning: function pointers are not nullable, so checking them for null will always return false
33- --> $DIR/ptr_null_checks.rs:18 :8
33+ --> $DIR/ptr_null_checks.rs:20 :8
3434 |
3535LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
3636 | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -40,7 +40,7 @@ LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
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:20 :8
43+ --> $DIR/ptr_null_checks.rs:22 :8
4444 |
4545LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
4646 | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +50,7 @@ LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
5050 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
5151
5252warning: function pointers are not nullable, so checking them for null will always return false
53- --> $DIR/ptr_null_checks.rs:22 :8
53+ --> $DIR/ptr_null_checks.rs:24 :8
5454 |
5555LL | if <*const _>::is_null(fn_ptr as *const ()) {}
5656 | ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL | if <*const _>::is_null(fn_ptr as *const ()) {}
6060 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
6161
6262warning: function pointers are not nullable, so checking them for null will always return false
63- --> $DIR/ptr_null_checks.rs:24 :8
63+ --> $DIR/ptr_null_checks.rs:26 :8
6464 |
6565LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
6666 | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -70,7 +70,7 @@ LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
7070 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
7171
7272warning: function pointers are not nullable, so checking them for null will always return false
73- --> $DIR/ptr_null_checks.rs:26 :8
73+ --> $DIR/ptr_null_checks.rs:28 :8
7474 |
7575LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
7676 | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +80,7 @@ LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
8080 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
8181
8282warning: function pointers are not nullable, so checking them for null will always return false
83- --> $DIR/ptr_null_checks.rs:28 :8
83+ --> $DIR/ptr_null_checks.rs:30 :8
8484 |
8585LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {}
8686 | ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {
9090 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
9191
9292warning: function pointers are not nullable, so checking them for null will always return false
93- --> $DIR/ptr_null_checks.rs:30 :8
93+ --> $DIR/ptr_null_checks.rs:32 :8
9494 |
9595LL | if (fn_ptr as fn() as *const ()).is_null() {}
9696 | ^--------------^^^^^^^^^^^^^^^^^^^^^^^^
@@ -100,7 +100,7 @@ LL | if (fn_ptr as fn() as *const ()).is_null() {}
100100 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
101101
102102warning: function pointers are not nullable, so checking them for null will always return false
103- --> $DIR/ptr_null_checks.rs:32 :8
103+ --> $DIR/ptr_null_checks.rs:34 :8
104104 |
105105LL | if (c_fn as *const fn()).is_null() {}
106106 | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -110,117 +110,117 @@ LL | if (c_fn as *const fn()).is_null() {}
110110 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
111111
112112warning: references are not nullable, so checking them for null will always return false
113- --> $DIR/ptr_null_checks.rs:36 :8
113+ --> $DIR/ptr_null_checks.rs:38 :8
114114 |
115115LL | if (&mut 8 as *mut i32).is_null() {}
116116 | ^------^^^^^^^^^^^^^^^^^^^^^^^
117117 | |
118118 | expression has type `&mut i32`
119119
120120warning: returned pointer of `from_mut` call is never null, so checking it for null will always return false
121- --> $DIR/ptr_null_checks.rs:38 :8
121+ --> $DIR/ptr_null_checks.rs:40 :8
122122 |
123123LL | if ptr::from_mut(&mut 8).is_null() {}
124124 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125125
126126warning: references are not nullable, so checking them for null will always return false
127- --> $DIR/ptr_null_checks.rs:40 :8
127+ --> $DIR/ptr_null_checks.rs:42 :8
128128 |
129129LL | if (&8 as *const i32).is_null() {}
130130 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^
131131 | |
132132 | expression has type `&i32`
133133
134134warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
135- --> $DIR/ptr_null_checks.rs:42 :8
135+ --> $DIR/ptr_null_checks.rs:44 :8
136136 |
137137LL | if ptr::from_ref(&8).is_null() {}
138138 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
139139
140140warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
141- --> $DIR/ptr_null_checks.rs:44 :8
141+ --> $DIR/ptr_null_checks.rs:46 :8
142142 |
143143LL | if ptr::from_ref(&8).cast_mut().is_null() {}
144144 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
145145
146146warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
147- --> $DIR/ptr_null_checks.rs:46 :8
147+ --> $DIR/ptr_null_checks.rs:48 :8
148148 |
149149LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
150150 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151151
152152warning: references are not nullable, so checking them for null will always return false
153- --> $DIR/ptr_null_checks.rs:48 :8
153+ --> $DIR/ptr_null_checks.rs:50 :8
154154 |
155155LL | if (&8 as *const i32) == std::ptr::null() {}
156156 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157157 | |
158158 | expression has type `&i32`
159159
160160warning: references are not nullable, so checking them for null will always return false
161- --> $DIR/ptr_null_checks.rs:51 :8
161+ --> $DIR/ptr_null_checks.rs:53 :8
162162 |
163163LL | if (ref_num as *const i32) == std::ptr::null() {}
164164 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165165 | |
166166 | expression has type `&i32`
167167
168168warning: references are not nullable, so checking them for null will always return false
169- --> $DIR/ptr_null_checks.rs:53 :8
169+ --> $DIR/ptr_null_checks.rs:55 :8
170170 |
171171LL | if (b"\0" as *const u8).is_null() {}
172172 | ^-----^^^^^^^^^^^^^^^^^^^^^^^^
173173 | |
174174 | expression has type `&[u8; 1]`
175175
176176warning: references are not nullable, so checking them for null will always return false
177- --> $DIR/ptr_null_checks.rs:55 :8
177+ --> $DIR/ptr_null_checks.rs:57 :8
178178 |
179179LL | if ("aa" as *const str).is_null() {}
180180 | ^----^^^^^^^^^^^^^^^^^^^^^^^^^
181181 | |
182182 | expression has type `&str`
183183
184184warning: references are not nullable, so checking them for null will always return false
185- --> $DIR/ptr_null_checks.rs:57 :8
185+ --> $DIR/ptr_null_checks.rs:59 :8
186186 |
187187LL | if (&[1, 2] as *const i32).is_null() {}
188188 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
189189 | |
190190 | expression has type `&[i32; 2]`
191191
192192warning: references are not nullable, so checking them for null will always return false
193- --> $DIR/ptr_null_checks.rs:59 :8
193+ --> $DIR/ptr_null_checks.rs:61 :8
194194 |
195195LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
196196 | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197197 | |
198198 | expression has type `&mut [i32; 2]`
199199
200200warning: references are not nullable, so checking them for null will always return false
201- --> $DIR/ptr_null_checks.rs:61 :8
201+ --> $DIR/ptr_null_checks.rs:63 :8
202202 |
203203LL | if (static_i32() as *const i32).is_null() {}
204204 | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
205205 | |
206206 | expression has type `&i32`
207207
208208warning: references are not nullable, so checking them for null will always return false
209- --> $DIR/ptr_null_checks.rs:63 :8
209+ --> $DIR/ptr_null_checks.rs:65 :8
210210 |
211211LL | if (&*{ static_i32() } as *const i32).is_null() {}
212212 | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
213213 | |
214214 | expression has type `&i32`
215215
216216warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
217- --> $DIR/ptr_null_checks.rs:67 :8
217+ --> $DIR/ptr_null_checks.rs:69 :8
218218 |
219219LL | if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {}
220220 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
221221
222222warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
223- --> $DIR/ptr_null_checks.rs:69 :8
223+ --> $DIR/ptr_null_checks.rs:71 :8
224224 |
225225LL | if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {}
226226 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments