-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
reject partial init and reinit of uninitialized data #54941
reject partial init and reinit of uninitialized data #54941
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
This PR is almost certainly subsumed by the work of @spastorino on PR #54621 I have put this PR up here mostly as a point of comparison (e.g. to double-check the tests and to compare the choice of diagnostic wording under the two approaches). |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
(I am still working on this. I need to extend it to cover #54499 (even if that means "just" adding tests) |
…clarify why we need the former.
…#54986. Treat attempt to partially intialize local `l` as uses of a `mut` in `let mut l;`, to fix rust-lang#54499.
…current point in flow.
…aks. (This makes it a little easier to add instrumentation of the entry and exit by adding `debug!` at the beginning and end, though note that the function body *does* use the `?` operator...)
… 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`.)
d52c071
to
936d9c0
Compare
this is now ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with update
let init_indices = &self.move_data.init_path_map[mpi]; | ||
let first_init_index = init_indices.iter().find(|&ii| flow_state.ever_inits.contains(*ii)); | ||
if let Some(&init_index) = first_init_index { | ||
if let Some(init_index) = self.is_local_ever_initialized(local, flow_state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice place for a helper fn 💯
936d9c0
to
258f9ca
Compare
@bors r=nikomatsakis |
📌 Commit 258f9cab12c08a3d43661a48b947b3e4a61ffb58 has been approved by |
@bors r- Oops: I added the |
258f9ca
to
233fdb4
Compare
@bors r=nikomatsakis |
📌 Commit 233fdb4 has been approved by |
@bors r- @nikomatsakis had warned about not breaking unions here: #21232 (comment) but I'm worried that I may have broken that exact case. |
@bors r=nikomatsakis I double-checked: the code that @nikomatsakis wrote was actually (I think) referring to the hypothetical world of #54987. This PR is solely about #54986. As far as I can tell, this change does not break |
📌 Commit 233fdb4 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Reject partial initialization of uninitialized structured types (i.e. structs and tuples) and also reject partial reinitialization of such types.
Fix #54986
Fix #54499
cc #21232