-
Notifications
You must be signed in to change notification settings - Fork 12.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
Ungreat diagnostic error borrowed data escapes outside of function #62953
Comments
This is effectively google's landing page for an explanation of this mysterious Rust error E0521, given that the official error spokeswomen and Luckily, just a few links further, google also lists a link to a stackoverflow question (even though it does not mention E0521 nor the same error message). It doesn't actually offer a complete example, but it allowed me to strip mine down and spot the solution. fn main() {
let mut stash: Option<&i32> = None;
let mut thief = |r: &i32| { stash = Some(r) };
thief(&42);
} Errors:
The problem here is that we need to remove the type from the closure: let mut thief = |r| { stash = Some(r) }; |
For my example, that is definitely very helpful and more than enough. |
@GuillaumeGomez , could you close this issue please? :) |
@ssomers seems satisfied so let's close it. Thanks @jesusprubio ! |
On an change I was implementing in the compiler I got the following error ...
I don't remember how the code looked like exactly but we can probably rebuild an example that shows this behavior.
More info https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/borrowed.20data.20escapes.20outside.20of.20function
The text was updated successfully, but these errors were encountered: