51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||
|
// file at the top-level directory of this distribution and at
|
||
|
// http://rust-lang.org/COPYRIGHT.
|
||
|
//
|
||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||
|
// option. This file may not be copied, modified, or distributed
|
||
|
// except according to those terms.
|
||
|
|
||
|
#![allow(non_snake_case)]
|
||
|
|
||
|
register_long_diagnostics! {
|
||
|
E0016: r##"
|
||
|
Blocks in constants may only contain items (such as constant, function
|
||
|
definition, etc...) and a tail expression. Example:
|
||
|
|
||
|
```
|
||
|
const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
|
||
|
```
|
||
|
|
||
|
To avoid it, you have to replace the non-item object:
|
||
|
|
||
|
```
|
||
|
const FOO: i32 = { const X : i32 = 0; X };
|
||
|
```
|
||
|
"##,
|
||
|
|
||
|
E0022: r##"
|
||
|
Constant functions are not allowed to mutate anything. Thus, binding to an
|
||
|
argument with a mutable pattern is not allowed. For example,
|
||
|
|
||
|
```
|
||
|
const fn foo(mut x: u8) {
|
||
|
// do stuff
|
||
|
}
|
||
|
```
|
||
|
|
||
|
is bad because the function body may not mutate `x`.
|
||
|
|
||
|
Remove any mutable bindings from the argument list to fix this error. In case
|
||
|
you need to mutate the argument, try lazily initializing a global variable
|
||
|
instead of using a `const fn`, or refactoring the code to a functional style to
|
||
|
avoid mutation if possible.
|
||
|
"##,
|
||
|
}
|
||
|
|
||
|
register_diagnostics! {
|
||
|
E0472, // asm! is unsupported on this target
|
||
|
}
|