Skip to content

Commit 4543ce6

Browse files
Add back the E0022 error code long explanation
1 parent f829a53 commit 4543ce6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ E0016: include_str!("./error_codes/E0016.md"),
2525
E0017: include_str!("./error_codes/E0017.md"),
2626
E0018: include_str!("./error_codes/E0018.md"),
2727
E0019: include_str!("./error_codes/E0019.md"),
28+
E0022: include_str!("./error_codes/E0022.md"),
2829
E0023: include_str!("./error_codes/E0023.md"),
2930
E0025: include_str!("./error_codes/E0025.md"),
3031
E0026: include_str!("./error_codes/E0026.md"),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
3+
Constant functions are not allowed to mutate anything. Thus, binding to an
4+
argument with a mutable pattern is not allowed. For example,
5+
6+
```
7+
const fn foo(mut x: u8) {
8+
// do stuff
9+
}
10+
```
11+
12+
Is incorrect because the function body may not mutate `x`.
13+
14+
Remove any mutable bindings from the argument list to fix this error. In case
15+
you need to mutate the argument, try lazily initializing a global variable
16+
instead of using a `const fn`, or refactoring the code to a functional style to
17+
avoid mutation if possible.

0 commit comments

Comments
 (0)