-
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
mut borrow checker seems to be too conservative in matches #10390
Comments
Dup of #6393 -- fixing this is not so easy |
@nikomatsakis: You mentioned on IRC this might not actually get fixed once #6393 is implemented. Should this be reopened? |
We can reopen, but we have to be more precise what you are asking for. This is kind of a subtle problem with many dimensions. I think the problem, specifically, is that returning If I had to guess, I'd guess that what you wanted is more like "this Value object will be freed when I have encountered a similar scenario with the |
cc me |
Updated code:
Is this ticket still worthwhile? I would agree with what @nikomatsakis is saying, with regards to the lifetime here. |
(Also, I'm not sure what to tag this as) |
I am inclined to close this ticket. There are various ways we could improve the borrow checker and I don't know that having this ticket open will help us. It's not a bug in any case, more like an enhancement. |
I've been working on a new version of the serialization framework, and I've run into an edge case with the borrow checker that is a little painful. Here's my reduced code:
This errors with:
I'm not sure if this should be an error because the error is being caused by the
A
variant capturing the value, not theB
andC
variant. This is clear with this impl, which compiles fine:The only way currently that I can get this to work is if I use a mini-state machine, as in:
Which is a bit obnoxious to write when we have a large amount of value variants.
The text was updated successfully, but these errors were encountered: