1
1
warning: 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
3
3
|
4
4
LL | if (fn_ptr as *mut ()).is_null() {}
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,148 +8,196 @@ LL | if (fn_ptr as *mut ()).is_null() {}
8
8
= note: `#[warn(useless_ptr_null_checks)]` on by default
9
9
10
10
warning: 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
12
12
|
13
13
LL | if (fn_ptr as *const u8).is_null() {}
14
14
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15
15
|
16
16
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
17
17
18
18
warning: 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
20
20
|
21
21
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
22
22
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23
23
|
24
24
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
25
25
26
26
warning: 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
28
28
|
29
29
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
30
30
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31
31
|
32
32
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
33
33
34
34
warning: 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
36
36
|
37
37
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
38
38
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39
39
|
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:20 :8
43
+ --> $DIR/ptr_null_checks.rs:24 :8
44
44
|
45
45
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
46
46
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
47
|
48
48
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
49
49
50
50
warning: 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
52
52
|
53
53
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
54
54
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55
55
|
56
56
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
57
57
58
58
warning: 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
60
76
|
61
77
LL | if (fn_ptr as fn() as *const ()).is_null() {}
62
78
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
79
|
64
80
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
65
81
66
82
warning: 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
68
84
|
69
85
LL | if (c_fn as *const fn()).is_null() {}
70
86
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71
87
|
72
88
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
73
89
74
90
warning: 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
76
92
|
77
93
LL | if (&mut 8 as *mut i32).is_null() {}
78
94
| ^------^^^^^^^^^^^^^^^^^^^^^^^
79
95
| |
80
96
| expression has type `&mut i32`
81
97
82
98
warning: 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
84
108
|
85
109
LL | if (&8 as *const i32).is_null() {}
86
110
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^
87
111
| |
88
112
| expression has type `&i32`
89
113
90
114
warning: 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
92
140
|
93
141
LL | if (&8 as *const i32) == std::ptr::null() {}
94
142
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
143
| |
96
144
| expression has type `&i32`
97
145
98
146
warning: 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
100
148
|
101
149
LL | if (ref_num as *const i32) == std::ptr::null() {}
102
150
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
151
| |
104
152
| expression has type `&i32`
105
153
106
154
warning: 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
108
156
|
109
157
LL | if (b"\0" as *const u8).is_null() {}
110
158
| ^-----^^^^^^^^^^^^^^^^^^^^^^^^
111
159
| |
112
160
| expression has type `&[u8; 1]`
113
161
114
162
warning: 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
116
164
|
117
165
LL | if ("aa" as *const str).is_null() {}
118
166
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^
119
167
| |
120
168
| expression has type `&str`
121
169
122
170
warning: 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
124
172
|
125
173
LL | if (&[1, 2] as *const i32).is_null() {}
126
174
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
127
175
| |
128
176
| expression has type `&[i32; 2]`
129
177
130
178
warning: 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
132
180
|
133
181
LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
134
182
| ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135
183
| |
136
184
| expression has type `&mut [i32; 2]`
137
185
138
186
warning: 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
140
188
|
141
189
LL | if (static_i32() as *const i32).is_null() {}
142
190
| ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
143
191
| |
144
192
| expression has type `&i32`
145
193
146
194
warning: 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
148
196
|
149
197
LL | if (&*{ static_i32() } as *const i32).is_null() {}
150
198
| ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
151
199
| |
152
200
| expression has type `&i32`
153
201
154
- warning: 19 warnings emitted
202
+ warning: 25 warnings emitted
155
203
0 commit comments