29e2aa12ff
When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
14 lines
506 B
Plaintext
14 lines
506 B
Plaintext
error[E0381]: binding `x` isn't initialized in all conditions
|
|
--> $DIR/borrowck-if-no-else.rs:5:9
|
|
|
|
|
LL | let x: isize; if 1 > 2 { x = 10; }
|
|
| - ----- this `if` expression might be missing an `else` arm where `x` is initialized
|
|
| |
|
|
| variable declared here
|
|
LL | foo(x);
|
|
| ^ `x` used here but it isn't initialized in all conditions
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0381`.
|