diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-04 18:11:51 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-05 11:23:50 +0200 |
| commit | 771ab35c3d3ee684a0d938fe50b1dc21edbca621 (patch) | |
| tree | 4ddb6fee7d461e3b7040028dafff5fcc3130cd76 | |
| parent | ec4ba272b00c7a7cae537a73d52f692a1a943e1b (diff) | |
| download | rust-771ab35c3d3ee684a0d938fe50b1dc21edbca621.tar.gz rust-771ab35c3d3ee684a0d938fe50b1dc21edbca621.zip | |
Add erroneous code example for E0010
| -rw-r--r-- | src/librustc/diagnostics.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 61cc63fa317..91845e916d4 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -218,7 +218,14 @@ match x { E0010: r##" The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on -the heap at runtime, and therefore cannot be done at compile time. +the heap at runtime, and therefore cannot be done at compile time. Erroneous +code example: + +``` +#![feature(box_syntax)] + +const CON : Box<i32> = box 0; +``` "##, E0011: r##" @@ -335,7 +342,6 @@ is not allowed. If you really want global mutable state, try using `static mut` or a global `UnsafeCell`. - "##, E0018: r##" @@ -399,7 +405,13 @@ fn main() { E0020: r##" This error indicates that an attempt was made to divide by zero (or take the -remainder of a zero divisor) in a static or constant expression. +remainder of a zero divisor) in a static or constant expression. Erroneous +code example: + +``` +const X: i32 = 42 / 0; +// error: attempted to divide by zero in a constant expression +``` "##, E0022: r##" |
