-
Notifications
You must be signed in to change notification settings - Fork 533
Document how closure capturing interacts with discriminant reads #1837
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
base: master
Are you sure you want to change the base?
Conversation
This is the behavior after the bugfixes in rustc PR 138961.
r[type.closure.capture.precision.discriminants] | ||
### Capturing for discriminant reads | ||
|
||
If pattern matching requires inspecting a discriminant, the relevant place will get captured by `ImmBorrow`. |
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.
Unless we mutably access the contents, right? E.g.
let c = || match x {
(Example::A(ref mut _y), _) => println!("variant A"),
(Example::B(_), _) => println!("variant B"),
};
Is that already implied by the other rules?
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.
ok yep, that's the "Shared prefix" thing
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.
Yup. Do you think this deserves a clarification? (if so, how would you word it)
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.
no, I think it's clear in the context
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.
The changes look accurate to me. I don't know about things related to how the reference is organized so I'll leave to someone who knows to approve this.
This is the behavior after the bugfixes in rust-lang/rust#138961. I have successfully ran
mdbook test
withRUSTUP_TOOLCHAIN
pointed at a stage1 built on top of the aforementioned PR – until it's merged, the CI here will fail.