-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Let destructors move out of class fields if it's the last use. #2955
Comments
I usually use the option dance here. In a few places recently, I've written a box class that tries to do some of the option dance for you. I think there was an example of this in the ICFP code. |
I would prefer not to make liveness more complex by supporting this case. However, we should fairly trivially be able to support something like:
for destructors or any other case that takes owns self. |
If non-destructor code destructures self, does it bypass the destructor? |
Interesting question. I think it would have to be illegal in that event to destructure a class with a dtor? |
not sure if this is worth supporting. it doesn't add any expressiveness power if you can just use the option dance. |
Automatic sync from rustc
Currently writing taskgroup code, where the destructor needs to pass some exclusive ARCs around, which are noncopyable. This is only possible since every function that I pass them to takes them by reference - but maybe somebody will need to destruct a class by passing a noncopyable thing in move mode.
The text was updated successfully, but these errors were encountered: