]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0572.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0572.md
1 A return statement was found outside of a function body.
2
3 Erroneous code example:
4
5 ```compile_fail,E0572
6 const FOO: u32 = return 0; // error: return statement outside of function body
7
8 fn main() {}
9 ```
10
11 To fix this issue, just remove the return keyword or move the expression into a
12 function. Example:
13
14 ```
15 const FOO: u32 = 0;
16
17 fn some_fn() -> u32 {
18     return FOO;
19 }
20
21 fn main() {
22     some_fn();
23 }
24 ```