fork/rust

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

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
15.3 KiB381 linesraw
1error: the type `&'static T` does not permit zero-initialization
2  --> $DIR/uninitialized-zeroed.rs:29:32
3   |
4LL |         let _val: &'static T = mem::zeroed();
5   |                                ^^^^^^^^^^^^^
6   |                                |
7   |                                this code causes undefined behavior when executed
8   |                                help: use `MaybeUninit<T>` instead
9   |
10note: lint level defined here
11  --> $DIR/uninitialized-zeroed.rs:7:9
12   |
13LL | #![deny(invalid_value)]
14   |         ^^^^^^^^^^^^^
15   = note: References must be non-null
16
17error: the type `&'static T` does not permit being left uninitialized
18  --> $DIR/uninitialized-zeroed.rs:30:32
19   |
20LL |         let _val: &'static T = mem::uninitialized();
21   |                                ^^^^^^^^^^^^^^^^^^^^
22   |                                |
23   |                                this code causes undefined behavior when executed
24   |                                help: use `MaybeUninit<T>` instead
25   |
26   = note: References must be non-null
27
28error: the type `Wrap<&'static T>` does not permit zero-initialization
29  --> $DIR/uninitialized-zeroed.rs:32:38
30   |
31LL |         let _val: Wrap<&'static T> = mem::zeroed();
32   |                                      ^^^^^^^^^^^^^
33   |                                      |
34   |                                      this code causes undefined behavior when executed
35   |                                      help: use `MaybeUninit<T>` instead
36   |
37note: References must be non-null (in this struct field)
38  --> $DIR/uninitialized-zeroed.rs:18:18
39   |
40LL | struct Wrap<T> { wrapped: T }
41   |                  ^^^^^^^^^^
42
43error: the type `Wrap<&'static T>` does not permit being left uninitialized
44  --> $DIR/uninitialized-zeroed.rs:33:38
45   |
46LL |         let _val: Wrap<&'static T> = mem::uninitialized();
47   |                                      ^^^^^^^^^^^^^^^^^^^^
48   |                                      |
49   |                                      this code causes undefined behavior when executed
50   |                                      help: use `MaybeUninit<T>` instead
51   |
52note: References must be non-null (in this struct field)
53  --> $DIR/uninitialized-zeroed.rs:18:18
54   |
55LL | struct Wrap<T> { wrapped: T }
56   |                  ^^^^^^^^^^
57
58error: the type `!` does not permit zero-initialization
59  --> $DIR/uninitialized-zeroed.rs:40:23
60   |
61LL |         let _val: ! = mem::zeroed();
62   |                       ^^^^^^^^^^^^^
63   |                       |
64   |                       this code causes undefined behavior when executed
65   |                       help: use `MaybeUninit<T>` instead
66   |
67   = note: The never type (`!`) has no valid value
68
69error: the type `!` does not permit being left uninitialized
70  --> $DIR/uninitialized-zeroed.rs:41:23
71   |
72LL |         let _val: ! = mem::uninitialized();
73   |                       ^^^^^^^^^^^^^^^^^^^^
74   |                       |
75   |                       this code causes undefined behavior when executed
76   |                       help: use `MaybeUninit<T>` instead
77   |
78   = note: The never type (`!`) has no valid value
79
80error: the type `(i32, !)` does not permit zero-initialization
81  --> $DIR/uninitialized-zeroed.rs:43:30
82   |
83LL |         let _val: (i32, !) = mem::zeroed();
84   |                              ^^^^^^^^^^^^^
85   |                              |
86   |                              this code causes undefined behavior when executed
87   |                              help: use `MaybeUninit<T>` instead
88   |
89   = note: The never type (`!`) has no valid value
90
91error: the type `(i32, !)` does not permit being left uninitialized
92  --> $DIR/uninitialized-zeroed.rs:44:30
93   |
94LL |         let _val: (i32, !) = mem::uninitialized();
95   |                              ^^^^^^^^^^^^^^^^^^^^
96   |                              |
97   |                              this code causes undefined behavior when executed
98   |                              help: use `MaybeUninit<T>` instead
99   |
100   = note: The never type (`!`) has no valid value
101
102error: the type `Void` does not permit zero-initialization
103  --> $DIR/uninitialized-zeroed.rs:46:26
104   |
105LL |         let _val: Void = mem::zeroed();
106   |                          ^^^^^^^^^^^^^
107   |                          |
108   |                          this code causes undefined behavior when executed
109   |                          help: use `MaybeUninit<T>` instead
110   |
111   = note: 0-variant enums have no valid value
112
113error: the type `Void` does not permit being left uninitialized
114  --> $DIR/uninitialized-zeroed.rs:47:26
115   |
116LL |         let _val: Void = mem::uninitialized();
117   |                          ^^^^^^^^^^^^^^^^^^^^
118   |                          |
119   |                          this code causes undefined behavior when executed
120   |                          help: use `MaybeUninit<T>` instead
121   |
122   = note: 0-variant enums have no valid value
123
124error: the type `&'static i32` does not permit zero-initialization
125  --> $DIR/uninitialized-zeroed.rs:49:34
126   |
127LL |         let _val: &'static i32 = mem::zeroed();
128   |                                  ^^^^^^^^^^^^^
129   |                                  |
130   |                                  this code causes undefined behavior when executed
131   |                                  help: use `MaybeUninit<T>` instead
132   |
133   = note: References must be non-null
134
135error: the type `&'static i32` does not permit being left uninitialized
136  --> $DIR/uninitialized-zeroed.rs:50:34
137   |
138LL |         let _val: &'static i32 = mem::uninitialized();
139   |                                  ^^^^^^^^^^^^^^^^^^^^
140   |                                  |
141   |                                  this code causes undefined behavior when executed
142   |                                  help: use `MaybeUninit<T>` instead
143   |
144   = note: References must be non-null
145
146error: the type `Ref` does not permit zero-initialization
147  --> $DIR/uninitialized-zeroed.rs:52:25
148   |
149LL |         let _val: Ref = mem::zeroed();
150   |                         ^^^^^^^^^^^^^
151   |                         |
152   |                         this code causes undefined behavior when executed
153   |                         help: use `MaybeUninit<T>` instead
154   |
155note: References must be non-null (in this struct field)
156  --> $DIR/uninitialized-zeroed.rs:15:12
157   |
158LL | struct Ref(&'static i32);
159   |            ^^^^^^^^^^^^
160
161error: the type `Ref` does not permit being left uninitialized
162  --> $DIR/uninitialized-zeroed.rs:53:25
163   |
164LL |         let _val: Ref = mem::uninitialized();
165   |                         ^^^^^^^^^^^^^^^^^^^^
166   |                         |
167   |                         this code causes undefined behavior when executed
168   |                         help: use `MaybeUninit<T>` instead
169   |
170note: References must be non-null (in this struct field)
171  --> $DIR/uninitialized-zeroed.rs:15:12
172   |
173LL | struct Ref(&'static i32);
174   |            ^^^^^^^^^^^^
175
176error: the type `fn()` does not permit zero-initialization
177  --> $DIR/uninitialized-zeroed.rs:55:26
178   |
179LL |         let _val: fn() = mem::zeroed();
180   |                          ^^^^^^^^^^^^^
181   |                          |
182   |                          this code causes undefined behavior when executed
183   |                          help: use `MaybeUninit<T>` instead
184   |
185   = note: Function pointers must be non-null
186
187error: the type `fn()` does not permit being left uninitialized
188  --> $DIR/uninitialized-zeroed.rs:56:26
189   |
190LL |         let _val: fn() = mem::uninitialized();
191   |                          ^^^^^^^^^^^^^^^^^^^^
192   |                          |
193   |                          this code causes undefined behavior when executed
194   |                          help: use `MaybeUninit<T>` instead
195   |
196   = note: Function pointers must be non-null
197
198error: the type `Wrap<fn()>` does not permit zero-initialization
199  --> $DIR/uninitialized-zeroed.rs:58:32
200   |
201LL |         let _val: Wrap<fn()> = mem::zeroed();
202   |                                ^^^^^^^^^^^^^
203   |                                |
204   |                                this code causes undefined behavior when executed
205   |                                help: use `MaybeUninit<T>` instead
206   |
207note: Function pointers must be non-null (in this struct field)
208  --> $DIR/uninitialized-zeroed.rs:18:18
209   |
210LL | struct Wrap<T> { wrapped: T }
211   |                  ^^^^^^^^^^
212
213error: the type `Wrap<fn()>` does not permit being left uninitialized
214  --> $DIR/uninitialized-zeroed.rs:59:32
215   |
216LL |         let _val: Wrap<fn()> = mem::uninitialized();
217   |                                ^^^^^^^^^^^^^^^^^^^^
218   |                                |
219   |                                this code causes undefined behavior when executed
220   |                                help: use `MaybeUninit<T>` instead
221   |
222note: Function pointers must be non-null (in this struct field)
223  --> $DIR/uninitialized-zeroed.rs:18:18
224   |
225LL | struct Wrap<T> { wrapped: T }
226   |                  ^^^^^^^^^^
227
228error: the type `WrapEnum<fn()>` does not permit zero-initialization
229  --> $DIR/uninitialized-zeroed.rs:61:36
230   |
231LL |         let _val: WrapEnum<fn()> = mem::zeroed();
232   |                                    ^^^^^^^^^^^^^
233   |                                    |
234   |                                    this code causes undefined behavior when executed
235   |                                    help: use `MaybeUninit<T>` instead
236   |
237note: Function pointers must be non-null (in this enum field)
238  --> $DIR/uninitialized-zeroed.rs:19:28
239   |
240LL | enum WrapEnum<T> { Wrapped(T) }
241   |                            ^
242
243error: the type `WrapEnum<fn()>` does not permit being left uninitialized
244  --> $DIR/uninitialized-zeroed.rs:62:36
245   |
246LL |         let _val: WrapEnum<fn()> = mem::uninitialized();
247   |                                    ^^^^^^^^^^^^^^^^^^^^
248   |                                    |
249   |                                    this code causes undefined behavior when executed
250   |                                    help: use `MaybeUninit<T>` instead
251   |
252note: Function pointers must be non-null (in this enum field)
253  --> $DIR/uninitialized-zeroed.rs:19:28
254   |
255LL | enum WrapEnum<T> { Wrapped(T) }
256   |                            ^
257
258error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization
259  --> $DIR/uninitialized-zeroed.rs:64:42
260   |
261LL |         let _val: Wrap<(RefPair, i32)> = mem::zeroed();
262   |                                          ^^^^^^^^^^^^^
263   |                                          |
264   |                                          this code causes undefined behavior when executed
265   |                                          help: use `MaybeUninit<T>` instead
266   |
267note: References must be non-null (in this struct field)
268  --> $DIR/uninitialized-zeroed.rs:16:16
269   |
270LL | struct RefPair((&'static i32, i32));
271   |                ^^^^^^^^^^^^^^^^^^^
272
273error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized
274  --> $DIR/uninitialized-zeroed.rs:65:42
275   |
276LL |         let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
277   |                                          ^^^^^^^^^^^^^^^^^^^^
278   |                                          |
279   |                                          this code causes undefined behavior when executed
280   |                                          help: use `MaybeUninit<T>` instead
281   |
282note: References must be non-null (in this struct field)
283  --> $DIR/uninitialized-zeroed.rs:16:16
284   |
285LL | struct RefPair((&'static i32, i32));
286   |                ^^^^^^^^^^^^^^^^^^^
287
288error: the type `std::ptr::NonNull<i32>` does not permit zero-initialization
289  --> $DIR/uninitialized-zeroed.rs:67:34
290   |
291LL |         let _val: NonNull<i32> = mem::zeroed();
292   |                                  ^^^^^^^^^^^^^
293   |                                  |
294   |                                  this code causes undefined behavior when executed
295   |                                  help: use `MaybeUninit<T>` instead
296   |
297   = note: std::ptr::NonNull<i32> must be non-null
298
299error: the type `std::ptr::NonNull<i32>` does not permit being left uninitialized
300  --> $DIR/uninitialized-zeroed.rs:68:34
301   |
302LL |         let _val: NonNull<i32> = mem::uninitialized();
303   |                                  ^^^^^^^^^^^^^^^^^^^^
304   |                                  |
305   |                                  this code causes undefined behavior when executed
306   |                                  help: use `MaybeUninit<T>` instead
307   |
308   = note: std::ptr::NonNull<i32> must be non-null
309
310error: the type `bool` does not permit being left uninitialized
311  --> $DIR/uninitialized-zeroed.rs:72:26
312   |
313LL |         let _val: bool = mem::uninitialized();
314   |                          ^^^^^^^^^^^^^^^^^^^^
315   |                          |
316   |                          this code causes undefined behavior when executed
317   |                          help: use `MaybeUninit<T>` instead
318   |
319   = note: Booleans must be `true` or `false`
320
321error: the type `Wrap<char>` does not permit being left uninitialized
322  --> $DIR/uninitialized-zeroed.rs:75:32
323   |
324LL |         let _val: Wrap<char> = mem::uninitialized();
325   |                                ^^^^^^^^^^^^^^^^^^^^
326   |                                |
327   |                                this code causes undefined behavior when executed
328   |                                help: use `MaybeUninit<T>` instead
329   |
330note: Characters must be a valid unicode codepoint (in this struct field)
331  --> $DIR/uninitialized-zeroed.rs:18:18
332   |
333LL | struct Wrap<T> { wrapped: T }
334   |                  ^^^^^^^^^^
335
336error: the type `NonBig` does not permit being left uninitialized
337  --> $DIR/uninitialized-zeroed.rs:78:28
338   |
339LL |         let _val: NonBig = mem::uninitialized();
340   |                            ^^^^^^^^^^^^^^^^^^^^
341   |                            |
342   |                            this code causes undefined behavior when executed
343   |                            help: use `MaybeUninit<T>` instead
344   |
345   = note: NonBig must be initialized inside its custom valid range
346
347error: the type `&'static i32` does not permit zero-initialization
348  --> $DIR/uninitialized-zeroed.rs:81:34
349   |
350LL |         let _val: &'static i32 = mem::transmute(0usize);
351   |                                  ^^^^^^^^^^^^^^^^^^^^^^
352   |                                  |
353   |                                  this code causes undefined behavior when executed
354   |                                  help: use `MaybeUninit<T>` instead
355   |
356   = note: References must be non-null
357
358error: the type `&'static [i32]` does not permit zero-initialization
359  --> $DIR/uninitialized-zeroed.rs:82:36
360   |
361LL |         let _val: &'static [i32] = mem::transmute((0usize, 0usize));
362   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
363   |                                    |
364   |                                    this code causes undefined behavior when executed
365   |                                    help: use `MaybeUninit<T>` instead
366   |
367   = note: References must be non-null
368
369error: the type `std::num::NonZeroU32` does not permit zero-initialization
370  --> $DIR/uninitialized-zeroed.rs:83:32
371   |
372LL |         let _val: NonZeroU32 = mem::transmute(0);
373   |                                ^^^^^^^^^^^^^^^^^
374   |                                |
375   |                                this code causes undefined behavior when executed
376   |                                help: use `MaybeUninit<T>` instead
377   |
378   = note: std::num::NonZeroU32 must be non-null
379
380error: aborting due to 30 previous errors
381