rust/src/test/ui/borrowck/borrowck-if-no-else.stderr
Esteban Küber 29e2aa12ff On partial uninit error point at where we need init
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.
2022-07-07 12:25:55 -07:00

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`.