11warning: function pointers are not nullable, so checking them for null will always return false
2- --> $DIR/ptr_null_checks.rs:10 :8
2+ --> $DIR/ptr_null_checks.rs:14 :8
33 |
44LL | if (fn_ptr as *mut ()).is_null() {}
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,148 +8,196 @@ 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:12 :8
11+ --> $DIR/ptr_null_checks.rs:16 :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:14 :8
19+ --> $DIR/ptr_null_checks.rs:18 :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:16 :8
27+ --> $DIR/ptr_null_checks.rs:20 :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:18 :8
35+ --> $DIR/ptr_null_checks.rs:22 :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:20 :8
43+ --> $DIR/ptr_null_checks.rs:24 :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:22 :8
51+ --> $DIR/ptr_null_checks.rs:26 :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:24:8
59+ --> $DIR/ptr_null_checks.rs:28:8
60+ |
61+ LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
62+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63+ |
64+ = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
65+
66+ warning: function pointers are not nullable, so checking them for null will always return false
67+ --> $DIR/ptr_null_checks.rs:30:8
68+ |
69+ LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().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+
74+ warning: function pointers are not nullable, so checking them for null will always return false
75+ --> $DIR/ptr_null_checks.rs:32:8
6076 |
6177LL | if (fn_ptr as fn() as *const ()).is_null() {}
6278 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6379 |
6480 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
6581
6682warning: function pointers are not nullable, so checking them for null will always return false
67- --> $DIR/ptr_null_checks.rs:26 :8
83+ --> $DIR/ptr_null_checks.rs:34 :8
6884 |
6985LL | if (c_fn as *const fn()).is_null() {}
7086 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7187 |
7288 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
7389
7490warning: references are not nullable, so checking them for null will always return false
75- --> $DIR/ptr_null_checks.rs:30 :8
91+ --> $DIR/ptr_null_checks.rs:38 :8
7692 |
7793LL | if (&mut 8 as *mut i32).is_null() {}
7894 | ^------^^^^^^^^^^^^^^^^^^^^^^^
7995 | |
8096 | expression has type `&mut i32`
8197
8298warning: references are not nullable, so checking them for null will always return false
83- --> $DIR/ptr_null_checks.rs:32:8
99+ --> $DIR/ptr_null_checks.rs:40:8
100+ |
101+ LL | if ptr::from_mut(&mut 8).is_null() {}
102+ | ^^^^^^^^^^^^^^------^^^^^^^^^^^
103+ | |
104+ | expression has type `&mut i32`
105+
106+ warning: references are not nullable, so checking them for null will always return false
107+ --> $DIR/ptr_null_checks.rs:42:8
84108 |
85109LL | if (&8 as *const i32).is_null() {}
86110 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^
87111 | |
88112 | expression has type `&i32`
89113
90114warning: references are not nullable, so checking them for null will always return false
91- --> $DIR/ptr_null_checks.rs:34:8
115+ --> $DIR/ptr_null_checks.rs:44:8
116+ |
117+ LL | if ptr::from_ref(&8).is_null() {}
118+ | ^^^^^^^^^^^^^^--^^^^^^^^^^^
119+ | |
120+ | expression has type `&i32`
121+
122+ warning: references are not nullable, so checking them for null will always return false
123+ --> $DIR/ptr_null_checks.rs:46:8
124+ |
125+ LL | if ptr::from_ref(&8).cast_mut().is_null() {}
126+ | ^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^
127+ | |
128+ | expression has type `&i32`
129+
130+ warning: references are not nullable, so checking them for null will always return false
131+ --> $DIR/ptr_null_checks.rs:48:8
132+ |
133+ LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
134+ | ^^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135+ | |
136+ | expression has type `&i32`
137+
138+ warning: references are not nullable, so checking them for null will always return false
139+ --> $DIR/ptr_null_checks.rs:50:8
92140 |
93141LL | if (&8 as *const i32) == std::ptr::null() {}
94142 | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95143 | |
96144 | expression has type `&i32`
97145
98146warning: references are not nullable, so checking them for null will always return false
99- --> $DIR/ptr_null_checks.rs:37 :8
147+ --> $DIR/ptr_null_checks.rs:53 :8
100148 |
101149LL | if (ref_num as *const i32) == std::ptr::null() {}
102150 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103151 | |
104152 | expression has type `&i32`
105153
106154warning: references are not nullable, so checking them for null will always return false
107- --> $DIR/ptr_null_checks.rs:39 :8
155+ --> $DIR/ptr_null_checks.rs:55 :8
108156 |
109157LL | if (b"\0" as *const u8).is_null() {}
110158 | ^-----^^^^^^^^^^^^^^^^^^^^^^^^
111159 | |
112160 | expression has type `&[u8; 1]`
113161
114162warning: references are not nullable, so checking them for null will always return false
115- --> $DIR/ptr_null_checks.rs:41 :8
163+ --> $DIR/ptr_null_checks.rs:57 :8
116164 |
117165LL | if ("aa" as *const str).is_null() {}
118166 | ^----^^^^^^^^^^^^^^^^^^^^^^^^^
119167 | |
120168 | expression has type `&str`
121169
122170warning: references are not nullable, so checking them for null will always return false
123- --> $DIR/ptr_null_checks.rs:43 :8
171+ --> $DIR/ptr_null_checks.rs:59 :8
124172 |
125173LL | if (&[1, 2] as *const i32).is_null() {}
126174 | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
127175 | |
128176 | expression has type `&[i32; 2]`
129177
130178warning: references are not nullable, so checking them for null will always return false
131- --> $DIR/ptr_null_checks.rs:45 :8
179+ --> $DIR/ptr_null_checks.rs:61 :8
132180 |
133181LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
134182 | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135183 | |
136184 | expression has type `&mut [i32; 2]`
137185
138186warning: references are not nullable, so checking them for null will always return false
139- --> $DIR/ptr_null_checks.rs:47 :8
187+ --> $DIR/ptr_null_checks.rs:63 :8
140188 |
141189LL | if (static_i32() as *const i32).is_null() {}
142190 | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
143191 | |
144192 | expression has type `&i32`
145193
146194warning: references are not nullable, so checking them for null will always return false
147- --> $DIR/ptr_null_checks.rs:49 :8
195+ --> $DIR/ptr_null_checks.rs:65 :8
148196 |
149197LL | if (&*{ static_i32() } as *const i32).is_null() {}
150198 | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
151199 | |
152200 | expression has type `&i32`
153201
154- warning: 19 warnings emitted
202+ warning: 25 warnings emitted
155203
0 commit comments