]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0381.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0381.md
1 It is not allowed to use or capture an uninitialized variable.
2
3 Erroneous code example:
4
5 ```compile_fail,E0381
6 fn main() {
7     let x: i32;
8     let y = x; // error, use of possibly-uninitialized variable
9 }
10 ```
11
12 To fix this, ensure that any declared variables are initialized before being
13 used. Example:
14
15 ```
16 fn main() {
17     let x: i32 = 0;
18     let y = x; // ok!
19 }
20 ```