fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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