-
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
Odd loaning errors when similar code works #4666
Comments
This is probably caused by #3850 |
I may or may be running into this same problem with this code:
This errors with:
However, if instead I use the commented out closure, it compiles fine. Likewise, if I move out of self, it also compiles fine. |
I think I may be having the same issue. I think this code should compile, but it doesn't:
The error rustc produces is:
|
That's the general flow-control problem that currently exists. It's going away with the borrowchecker changes that haven't landed yet; until then, you can work around it by assigning the result of the takes_self calls to temporaries and passing those instead. |
Part of #5074 (fix coming soon) |
…omatsakis This rather sprawling branch refactors the borrow checker and much of the region code, addressing a number of outstanding issues. I will close them manually after validating that there are test cases for each one, but here is a (probably partial) list: - #4903: Flow sensitivity - #3387: Moves in overloaded operators - #3850: Region granularity - #4666: Odd loaning errors - #6021: borrow check errors with hashmaps - #5910: @mut broken cc #5047 (take 5)
This bug is mostly fixed. Some of the examples (Such as |
existing tests. The bug itself was fixed as part of recent borrowck reform. Fixes #4666.
Awesome, thanks @nikomatsakis! |
For this code
fun1
passes through the compiler, but bothfun2
andfun3
generate an error (listed infun2
) and I'm not sure whyfun2
is invalid whilefun1
is valid.The text was updated successfully, but these errors were encountered: