@@ -18,7 +18,7 @@ for the entire lifetime of a program. Creating a boxed value allocates memory on
18
18
the heap at runtime, and therefore cannot be done at compile time. Erroneous
19
19
code example:
20
20
21
- ```compile_fail
21
+ ```compile_fail,E0010
22
22
#![feature(box_syntax)]
23
23
24
24
const CON : Box<i32> = box 0;
@@ -30,7 +30,7 @@ Static and const variables can refer to other const variables. But a const
30
30
variable cannot refer to a static variable. For example, `Y` cannot refer to
31
31
`X` here:
32
32
33
- ```compile_fail
33
+ ```compile_fail,E0013
34
34
static X: i32 = 42;
35
35
const Y: i32 = X;
36
36
```
@@ -66,7 +66,7 @@ E0016: r##"
66
66
Blocks in constants may only contain items (such as constant, function
67
67
definition, etc...) and a tail expression. Erroneous code example:
68
68
69
- ```compile_fail
69
+ ```compile_fail,E0016
70
70
const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
71
71
```
72
72
@@ -81,7 +81,7 @@ E0017: r##"
81
81
References in statics and constants may only refer to immutable values.
82
82
Erroneous code example:
83
83
84
- ```compile_fail
84
+ ```compile_fail,E0017
85
85
static X: i32 = 1;
86
86
const C: i32 = 2;
87
87
@@ -107,7 +107,7 @@ vary.
107
107
108
108
For example, if you write:
109
109
110
- ```compile_fail
110
+ ```compile_fail,E0018
111
111
static MY_STATIC: u32 = 42;
112
112
static MY_STATIC_ADDR: usize = &MY_STATIC as *const _ as usize;
113
113
static WHAT: usize = (MY_STATIC_ADDR^17) + MY_STATIC_ADDR;
@@ -152,7 +152,7 @@ impl Test {
152
152
fn main() {
153
153
const FOO: Test = Test::V1;
154
154
155
- const A: i32 = FOO.test(); // You can't call Test::func() here !
155
+ const A: i32 = FOO.test(); // You can't call Test::func() here!
156
156
}
157
157
```
158
158
@@ -214,14 +214,13 @@ static B: &'static u32 = &A; // ok!
214
214
```
215
215
"## ,
216
216
217
-
218
217
E0395 : r##"
219
218
The value assigned to a constant scalar must be known at compile time,
220
219
which is not the case when comparing raw pointers.
221
220
222
221
Erroneous code example:
223
222
224
- ```compile_fail
223
+ ```compile_fail,E0395
225
224
static FOO: i32 = 42;
226
225
static BAR: i32 = 42;
227
226
@@ -250,7 +249,7 @@ The value behind a raw pointer can't be determined at compile-time
250
249
(or even link-time), which means it can't be used in a constant
251
250
expression. Erroneous code example:
252
251
253
- ```compile_fail
252
+ ```compile_fail,E0396
254
253
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
255
254
256
255
const VALUE: u8 = unsafe { *REG_ADDR };
@@ -272,7 +271,7 @@ E0492: r##"
272
271
A borrow of a constant containing interior mutability was attempted. Erroneous
273
272
code example:
274
273
275
- ```compile_fail
274
+ ```compile_fail,E0492
276
275
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
277
276
278
277
const A: AtomicUsize = ATOMIC_USIZE_INIT;
@@ -299,7 +298,7 @@ static B: &'static AtomicUsize = &A; // ok!
299
298
300
299
You can also have this error while using a cell type:
301
300
302
- ```compile_fail
301
+ ```compile_fail,E0492
303
302
#![feature(const_fn)]
304
303
305
304
use std::cell::Cell;
@@ -351,7 +350,7 @@ E0493: r##"
351
350
A type with a destructor was assigned to an invalid type of variable. Erroneous
352
351
code example:
353
352
354
- ```compile_fail
353
+ ```compile_fail,E0493
355
354
struct Foo {
356
355
a: u32
357
356
}
@@ -374,7 +373,7 @@ E0494: r##"
374
373
A reference of an interior static was assigned to another const/static.
375
374
Erroneous code example:
376
375
377
- ```compile_fail
376
+ ```compile_fail,E0494
378
377
struct Foo {
379
378
a: u32
380
379
}
0 commit comments