1
1
warning: function pointers are not nullable, so checking them for null will always return false
2
- --> $DIR/ptr_null_checks.rs:14 :8
2
+ --> $DIR/ptr_null_checks.rs:12 :8
3
3
|
4
4
LL | if (fn_ptr as *mut ()).is_null() {}
5
5
| ^------^^^^^^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | if (fn_ptr as *mut ()).is_null() {}
10
10
= note: `#[warn(useless_ptr_null_checks)]` on by default
11
11
12
12
warning: function pointers are not nullable, so checking them for null will always return false
13
- --> $DIR/ptr_null_checks.rs:16 :8
13
+ --> $DIR/ptr_null_checks.rs:14 :8
14
14
|
15
15
LL | if (fn_ptr as *const u8).is_null() {}
16
16
| ^------^^^^^^^^^^^^^^^^^^^^^^^^
@@ -20,7 +20,7 @@ LL | if (fn_ptr as *const u8).is_null() {}
20
20
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
21
21
22
22
warning: function pointers are not nullable, so checking them for null will always return false
23
- --> $DIR/ptr_null_checks.rs:18 :8
23
+ --> $DIR/ptr_null_checks.rs:16 :8
24
24
|
25
25
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
26
26
| ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL | if (fn_ptr as *const ()) == std::ptr::null() {}
30
30
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
31
31
32
32
warning: function pointers are not nullable, so checking them for null will always return false
33
- --> $DIR/ptr_null_checks.rs:20 :8
33
+ --> $DIR/ptr_null_checks.rs:18 :8
34
34
|
35
35
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
36
36
| ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -40,7 +40,7 @@ LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
40
40
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
41
41
42
42
warning: function pointers are not nullable, so checking them for null will always return false
43
- --> $DIR/ptr_null_checks.rs:22 :8
43
+ --> $DIR/ptr_null_checks.rs:20 :8
44
44
|
45
45
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
46
46
| ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +50,7 @@ LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
50
50
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
51
51
52
52
warning: function pointers are not nullable, so checking them for null will always return false
53
- --> $DIR/ptr_null_checks.rs:24 :8
53
+ --> $DIR/ptr_null_checks.rs:22 :8
54
54
|
55
55
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
56
56
| ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL | if <*const _>::is_null(fn_ptr as *const ()) {}
60
60
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
61
61
62
62
warning: function pointers are not nullable, so checking them for null will always return false
63
- --> $DIR/ptr_null_checks.rs:26 :8
63
+ --> $DIR/ptr_null_checks.rs:24 :8
64
64
|
65
65
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
66
66
| ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -70,7 +70,7 @@ LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
70
70
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
71
71
72
72
warning: function pointers are not nullable, so checking them for null will always return false
73
- --> $DIR/ptr_null_checks.rs:28 :8
73
+ --> $DIR/ptr_null_checks.rs:26 :8
74
74
|
75
75
LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
76
76
| ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +80,7 @@ LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
80
80
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
81
81
82
82
warning: function pointers are not nullable, so checking them for null will always return false
83
- --> $DIR/ptr_null_checks.rs:30 :8
83
+ --> $DIR/ptr_null_checks.rs:28 :8
84
84
|
85
85
LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {}
86
86
| ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {
90
90
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
91
91
92
92
warning: function pointers are not nullable, so checking them for null will always return false
93
- --> $DIR/ptr_null_checks.rs:32 :8
93
+ --> $DIR/ptr_null_checks.rs:30 :8
94
94
|
95
95
LL | if (fn_ptr as fn() as *const ()).is_null() {}
96
96
| ^--------------^^^^^^^^^^^^^^^^^^^^^^^^
@@ -100,7 +100,7 @@ LL | if (fn_ptr as fn() as *const ()).is_null() {}
100
100
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
101
101
102
102
warning: function pointers are not nullable, so checking them for null will always return false
103
- --> $DIR/ptr_null_checks.rs:34 :8
103
+ --> $DIR/ptr_null_checks.rs:32 :8
104
104
|
105
105
LL | if (c_fn as *const fn()).is_null() {}
106
106
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -110,117 +110,117 @@ LL | if (c_fn as *const fn()).is_null() {}
110
110
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
111
111
112
112
warning: references are not nullable, so checking them for null will always return false
113
- --> $DIR/ptr_null_checks.rs:38 :8
113
+ --> $DIR/ptr_null_checks.rs:36 :8
114
114
|
115
115
LL | if (&mut 8 as *mut i32).is_null() {}
116
116
| ^------^^^^^^^^^^^^^^^^^^^^^^^
117
117
| |
118
118
| expression has type `&mut i32`
119
119
120
120
warning: returned pointer of `from_mut` call is never null, so checking it for null will always return false
121
- --> $DIR/ptr_null_checks.rs:40 :8
121
+ --> $DIR/ptr_null_checks.rs:38 :8
122
122
|
123
123
LL | if ptr::from_mut(&mut 8).is_null() {}
124
124
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125
125
126
126
warning: references are not nullable, so checking them for null will always return false
127
- --> $DIR/ptr_null_checks.rs:42 :8
127
+ --> $DIR/ptr_null_checks.rs:40 :8
128
128
|
129
129
LL | if (&8 as *const i32).is_null() {}
130
130
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^
131
131
| |
132
132
| expression has type `&i32`
133
133
134
134
warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
135
- --> $DIR/ptr_null_checks.rs:44 :8
135
+ --> $DIR/ptr_null_checks.rs:42 :8
136
136
|
137
137
LL | if ptr::from_ref(&8).is_null() {}
138
138
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
139
139
140
140
warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
141
- --> $DIR/ptr_null_checks.rs:46 :8
141
+ --> $DIR/ptr_null_checks.rs:44 :8
142
142
|
143
143
LL | if ptr::from_ref(&8).cast_mut().is_null() {}
144
144
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
145
145
146
146
warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
147
- --> $DIR/ptr_null_checks.rs:48 :8
147
+ --> $DIR/ptr_null_checks.rs:46 :8
148
148
|
149
149
LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
150
150
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151
151
152
152
warning: references are not nullable, so checking them for null will always return false
153
- --> $DIR/ptr_null_checks.rs:50 :8
153
+ --> $DIR/ptr_null_checks.rs:48 :8
154
154
|
155
155
LL | if (&8 as *const i32) == std::ptr::null() {}
156
156
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157
157
| |
158
158
| expression has type `&i32`
159
159
160
160
warning: references are not nullable, so checking them for null will always return false
161
- --> $DIR/ptr_null_checks.rs:53 :8
161
+ --> $DIR/ptr_null_checks.rs:51 :8
162
162
|
163
163
LL | if (ref_num as *const i32) == std::ptr::null() {}
164
164
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165
165
| |
166
166
| expression has type `&i32`
167
167
168
168
warning: references are not nullable, so checking them for null will always return false
169
- --> $DIR/ptr_null_checks.rs:55 :8
169
+ --> $DIR/ptr_null_checks.rs:53 :8
170
170
|
171
171
LL | if (b"\0" as *const u8).is_null() {}
172
172
| ^-----^^^^^^^^^^^^^^^^^^^^^^^^
173
173
| |
174
174
| expression has type `&[u8; 1]`
175
175
176
176
warning: references are not nullable, so checking them for null will always return false
177
- --> $DIR/ptr_null_checks.rs:57 :8
177
+ --> $DIR/ptr_null_checks.rs:55 :8
178
178
|
179
179
LL | if ("aa" as *const str).is_null() {}
180
180
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^
181
181
| |
182
182
| expression has type `&str`
183
183
184
184
warning: references are not nullable, so checking them for null will always return false
185
- --> $DIR/ptr_null_checks.rs:59 :8
185
+ --> $DIR/ptr_null_checks.rs:57 :8
186
186
|
187
187
LL | if (&[1, 2] as *const i32).is_null() {}
188
188
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
189
189
| |
190
190
| expression has type `&[i32; 2]`
191
191
192
192
warning: references are not nullable, so checking them for null will always return false
193
- --> $DIR/ptr_null_checks.rs:61 :8
193
+ --> $DIR/ptr_null_checks.rs:59 :8
194
194
|
195
195
LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
196
196
| ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197
197
| |
198
198
| expression has type `&mut [i32; 2]`
199
199
200
200
warning: references are not nullable, so checking them for null will always return false
201
- --> $DIR/ptr_null_checks.rs:63 :8
201
+ --> $DIR/ptr_null_checks.rs:61 :8
202
202
|
203
203
LL | if (static_i32() as *const i32).is_null() {}
204
204
| ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
205
205
| |
206
206
| expression has type `&i32`
207
207
208
208
warning: references are not nullable, so checking them for null will always return false
209
- --> $DIR/ptr_null_checks.rs:65 :8
209
+ --> $DIR/ptr_null_checks.rs:63 :8
210
210
|
211
211
LL | if (&*{ static_i32() } as *const i32).is_null() {}
212
212
| ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
213
213
| |
214
214
| expression has type `&i32`
215
215
216
216
warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
217
- --> $DIR/ptr_null_checks.rs:69 :8
217
+ --> $DIR/ptr_null_checks.rs:67 :8
218
218
|
219
219
LL | if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {}
220
220
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
221
221
222
222
warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
223
- --> $DIR/ptr_null_checks.rs:71 :8
223
+ --> $DIR/ptr_null_checks.rs:69 :8
224
224
|
225
225
LL | if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {}
226
226
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments