Skip to content

Commit f200061

Browse files
Add error code test checkup
1 parent 3ddb468 commit f200061

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/librustc_mir/diagnostics.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ for the entire lifetime of a program. Creating a boxed value allocates memory on
1818
the heap at runtime, and therefore cannot be done at compile time. Erroneous
1919
code example:
2020
21-
```compile_fail
21+
```compile_fail,E0010
2222
#![feature(box_syntax)]
2323
2424
const CON : Box<i32> = box 0;
@@ -30,7 +30,7 @@ Static and const variables can refer to other const variables. But a const
3030
variable cannot refer to a static variable. For example, `Y` cannot refer to
3131
`X` here:
3232
33-
```compile_fail
33+
```compile_fail,E0013
3434
static X: i32 = 42;
3535
const Y: i32 = X;
3636
```
@@ -66,7 +66,7 @@ E0016: r##"
6666
Blocks in constants may only contain items (such as constant, function
6767
definition, etc...) and a tail expression. Erroneous code example:
6868
69-
```compile_fail
69+
```compile_fail,E0016
7070
const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
7171
```
7272
@@ -81,7 +81,7 @@ E0017: r##"
8181
References in statics and constants may only refer to immutable values.
8282
Erroneous code example:
8383
84-
```compile_fail
84+
```compile_fail,E0017
8585
static X: i32 = 1;
8686
const C: i32 = 2;
8787
@@ -107,7 +107,7 @@ vary.
107107
108108
For example, if you write:
109109
110-
```compile_fail
110+
```compile_fail,E0018
111111
static MY_STATIC: u32 = 42;
112112
static MY_STATIC_ADDR: usize = &MY_STATIC as *const _ as usize;
113113
static WHAT: usize = (MY_STATIC_ADDR^17) + MY_STATIC_ADDR;
@@ -152,7 +152,7 @@ impl Test {
152152
fn main() {
153153
const FOO: Test = Test::V1;
154154
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!
156156
}
157157
```
158158
@@ -214,14 +214,13 @@ static B: &'static u32 = &A; // ok!
214214
```
215215
"##,
216216

217-
218217
E0395: r##"
219218
The value assigned to a constant scalar must be known at compile time,
220219
which is not the case when comparing raw pointers.
221220
222221
Erroneous code example:
223222
224-
```compile_fail
223+
```compile_fail,E0395
225224
static FOO: i32 = 42;
226225
static BAR: i32 = 42;
227226
@@ -250,7 +249,7 @@ The value behind a raw pointer can't be determined at compile-time
250249
(or even link-time), which means it can't be used in a constant
251250
expression. Erroneous code example:
252251
253-
```compile_fail
252+
```compile_fail,E0396
254253
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
255254
256255
const VALUE: u8 = unsafe { *REG_ADDR };
@@ -272,7 +271,7 @@ E0492: r##"
272271
A borrow of a constant containing interior mutability was attempted. Erroneous
273272
code example:
274273
275-
```compile_fail
274+
```compile_fail,E0492
276275
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
277276
278277
const A: AtomicUsize = ATOMIC_USIZE_INIT;
@@ -299,7 +298,7 @@ static B: &'static AtomicUsize = &A; // ok!
299298
300299
You can also have this error while using a cell type:
301300
302-
```compile_fail
301+
```compile_fail,E0492
303302
#![feature(const_fn)]
304303
305304
use std::cell::Cell;
@@ -351,7 +350,7 @@ E0493: r##"
351350
A type with a destructor was assigned to an invalid type of variable. Erroneous
352351
code example:
353352
354-
```compile_fail
353+
```compile_fail,E0493
355354
struct Foo {
356355
a: u32
357356
}
@@ -374,7 +373,7 @@ E0494: r##"
374373
A reference of an interior static was assigned to another const/static.
375374
Erroneous code example:
376375
377-
```compile_fail
376+
```compile_fail,E0494
378377
struct Foo {
379378
a: u32
380379
}

0 commit comments

Comments
 (0)