-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Begin documenting initialization checking #2174
Conversation
this is not particularly pretty, but I believe it complies with the union RFC and it doesn't appear to create much conflict.
text/2094-nll.md
Outdated
- supporting prefixes were defined earlier | ||
- so: reading a path like `a` is illegal if `a.b` is mutably | ||
borrowed, but -- in contrast with shallow accesses -- reading `a` is also | ||
illegal if `*a` is mutably borrowed | ||
|
||
|
||
And the accessed data and all children in its lvalue tree must be definitely initialized. |
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.
Is this sentence fragment supposed to be connected to the "3." bullet point immediately above, or something higher up?
cc @pnkfelix |
```Rust | ||
let x: (u32, u32); | ||
x.0 = 4; | ||
x.1 = 5; |
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.
In the current borrow checker, we do not accept this program. Are there corner cases that I am overlooking here?
Presuming there are not, I think that the current borrow checker basically enforces a rule like "Assigning to an lvalue LV requires that all prefixes of LV are definitely initialized", right?
Maybe we should just adopt this rule for now?
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.
This is indeed a difference from the current borrow checker. I see no problem with this rule.
I think I'd like to move these changes over to /~https://github.com/nikomatsakis/nll-rfc/ -- I still view that as the 'official home' of the NLL RFC, at least until stabilization. |
@nikomatsakis What do you want to do with this RFC? |
I'm going to try to follow @nikomatsakis 's request and turn this PR into a PR against /~https://github.com/nikomatsakis/nll-rfc/ ; after I have created that second PR, I will close this one. |
Okay as promised (too long ago) I have trivially ported ariel's hard work over to nikomatsakis/nll-rfc#51 I did not attempt to fill in any of the todo's in the text; that can happen over on the nll-rfc repo. Closing as any future work should happen over there. |
If we're going to have a spec for the borrow checker, it shouldn't leave out important components.
Edit: Rendered