-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Order of code affects lifetime resolution #23108
Comments
I think this is intended. Because items are destroyed in the opposite order that they are created when they go out of scope, the Edit: If you put them on the same line, e.g.: let (mut handle, long_enough_lifetime) = (Handle(None), DropCanary{label:"long"}); it also works. I'm not sure if this is correct because I'm not aware of the order in which they are dropped in this case. |
This is all by design. See #21657 and rust-lang/rfcs#769 |
(If we had a way to attach a lifetime to a struct |
Note also that the reason it is okay to put them on the same line is because Handle does not implement Drop. |
This playpen code snippet now fails in compile : playpen
with error
But if you just swap the following 2 lines, line 17 with line 18, it compiles fine.
The text was updated successfully, but these errors were encountered: