1
Fork 0

Make use of possibly uninitialized data a hard error

This is one of the behaviors we no longer allow in NLL. Since it can
lead to undefined behavior, I think it's definitely worth making it a
hard error without waiting to turn off migration mode (#58781).

Closes #60450.

My ulterior motive here is making it impossible to leave variables
partially initialized across a yield (see discussion at #63035), so
tests are included for that.
This commit is contained in:
Tyler Mandry 2019-08-02 17:08:16 -07:00
parent c43753f910
commit 9058bf2100
20 changed files with 209 additions and 131 deletions

View file

@ -11,17 +11,13 @@ LL | | }
LL | let Helper::U(u) = Helper::T(t, []);
| ^^^^^^^^^^^^ pattern `T(_, _)` not covered
warning[E0381]: use of possibly uninitialized variable: `u`
error[E0381]: use of possibly uninitialized variable: `u`
--> $DIR/empty-never-array.rs:12:5
|
LL | u
| ^ use of possibly uninitialized `u`
|
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
= note: for more information, try `rustc --explain E0729`
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.