]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0154.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0154.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 Imports (`use` statements) are not allowed after non-item statements, such as
4 variable declarations and expression statements.
5
6 Here is an example that demonstrates the error:
7
8 ```
9 fn f() {
10     // Variable declaration before import
11     let x = 0;
12     use std::io::Read;
13     // ...
14 }
15 ```
16
17 The solution is to declare the imports at the top of the block, function, or
18 file.
19
20 Here is the previous example again, with the correct order:
21
22 ```
23 fn f() {
24     use std::io::Read;
25     let x = 0;
26     // ...
27 }
28 ```
29
30 See the [Declaration Statements][declaration-statements] section of the
31 reference for more information about what constitutes an item declaration
32 and what does not.
33
34 [declaration-statements]: https://doc.rust-lang.org/reference/statements.html#declaration-statements