]> git.lizzy.rs Git - rust.git/blob - src/librustc_passes/diagnostics.rs
Add Alexis thesis to bibliography
[rust.git] / src / librustc_passes / diagnostics.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_snake_case)]
12
13 register_long_diagnostics! {
14 E0016: r##"
15 Blocks in constants may only contain items (such as constant, function
16 definition, etc...) and a tail expression. Example:
17
18 ```
19 const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
20 ```
21
22 To avoid it, you have to replace the non-item object:
23
24 ```
25 const FOO: i32 = { const X : i32 = 0; X };
26 ```
27 "##,
28
29 E0022: r##"
30 Constant functions are not allowed to mutate anything. Thus, binding to an
31 argument with a mutable pattern is not allowed. For example,
32
33 ```
34 const fn foo(mut x: u8) {
35     // do stuff
36 }
37 ```
38
39 is bad because the function body may not mutate `x`.
40
41 Remove any mutable bindings from the argument list to fix this error. In case
42 you need to mutate the argument, try lazily initializing a global variable
43 instead of using a `const fn`, or refactoring the code to a functional style to
44 avoid mutation if possible.
45 "##,
46 }
47
48 register_diagnostics! {
49     E0472, // asm! is unsupported on this target
50 }