Skip to content

Commit

Permalink
Add E0394 error explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 15, 2016
1 parent f0bab98 commit 844c6e3
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/librustc_mir/diagnostics.rs
Expand Up @@ -188,12 +188,30 @@ avoid mutation if possible.
"##,

E0394: r##"
From [RFC 246]:
A static was referred to by value by another static.
> It is invalid for a static to reference another static by value. It is
> required that all references be borrowed.
Erroneous code examples:
[RFC 246]: https://github.com/rust-lang/rfcs/pull/246
```compile_fail,E0394
static A: u32 = 0;
static B: u32 = A; // error: cannot refer to other statics by value, use the
// address-of operator or a constant instead
```
A static cannot be referred by value. To fix this issue, either use a
constant:
```
const A: u32 = 0; // `A` is now a constant
static B: u32 = A; // ok!
```
Or refer to `A` by reference:
```
static A: u32 = 0;
static B: &'static u32 = &A; // ok!
```
"##,


Expand Down

0 comments on commit 844c6e3

Please sign in to comment.