-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NLL: Reject partial init of uninitialized record (struct or tuple) #54986
Labels
Milestone
Comments
pnkfelix
changed the title
Reject partial init of uninitialized record (struct or tuple)
NLL: Reject partial init of uninitialized record (struct or tuple)
Oct 11, 2018
This was referenced Oct 11, 2018
Closed
pnkfelix
added
the
NLL-sound
Working towards the "invalid code does not compile" goal
label
Oct 16, 2018
The PR #54941 should address this. (Its still marked WIP but that should change soon.) |
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Oct 16, 2018
…#54986. Treat attempt to partially intialize local `l` as uses of a `mut` in `let mut l;`, to fix rust-lang#54499.
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Oct 16, 2018
… uninitialized struct. Under the semantics of rust-lang#54986 (our short term plan), the partial initialization itself will signal an error. We don't need to add noise to the output by also complaining about `mut`. (In particular, the user may well revise their code in a way that does not require `mut`.)
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Oct 16, 2018
davidtwco
added a commit
to davidtwco/rust
that referenced
this issue
Nov 3, 2018
This commit makes two changes: First, it updates the dataflow builder to add an init for the place containing a union if there is an assignment into the field of that union. Second, it stops a "use of uninitialized" error occuring when there is an assignment into the field of an uninitialized union that was previously initialized. Making this assignment would re-initialize the union, as tested in `src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr`. The check for previous initialization ensures that we do not start supporting partial initialization yet (cc rust-lang#21232, rust-lang#54499, rust-lang#54986).
bors
added a commit
that referenced
this issue
Nov 11, 2018
NLL Diagnostic Review 3: Unions not reinitialized after assignment into field Fixes #55651, #55652. This PR makes two changes: First, it updates the dataflow builder to add an init for the place containing a union if there is an assignment into the field of that union. Second, it stops a "use of uninitialized" error occuring when there is an assignment into the field of an uninitialized union that was previously initialized. Making this assignment would re-initialize the union, as tested in `src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr`. The check for previous initialization ensures that we do not start supporting partial initialization yet (cc #21232, #54499, #54986). This PR also fixes #55652 which was marked as requiring investigation as the changes in this PR add an error that was previously missing (and mentioned in the review comments) and confirms that the error that was present is correct and a result of earlier partial initialization changes in NLL. r? @pnkfelix (due to earlier work with partial initialization) cc @nikomatsakis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spawned off of #21232
In the short term, we want to reject code like this:
See #54987 for the long-term goal.
The text was updated successfully, but these errors were encountered: