-
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
Variables bound with different modes in patterns #23610
Comments
Is there any reason we put in this restriction in the first place in a6a5c48? Seems like the type equality restriction on bindings should be enough. |
this error still occur in rustc 1.11.0 (9b21dcd 2016-08-15) |
@nikomatsakis Is there a chance the |
I don't understand what you mean here -- we have two bindings, both are "by reference", so how is the current code mixing by-move and by-ref in the same pattern? |
I think that in principle we do not need to require all bindings to be in the same mode; in that sense I agree with @ghost. However, I'm not sure how hard it would be to keep current code "up and going" without that simplifying restriction. I'd have to dig in in more detail. I think that once we are doing borrowck on MIR, things ought to be simpler, since most of the rules we have to keep borrowck + match sound could go away. |
Oh, I think I misread about the two bindings being by-move and by-reference -- never mind. I agree that we should probably leave this for after MIR borrowck (which might in its implementation resolve these sorts of issues on its own, I don't know). |
Triage: MIR borrowcheck has now landed, but this still gives this error. |
|
The following doesn't compile:
failing with the following error:
However, the following does work:
Is there any reason rust can't just perform this reborrow automatically?
&ref
is a very cryptic pattern.The text was updated successfully, but these errors were encountered: