Skip to content
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

Closed
bblum opened this issue Jul 18, 2012 · 5 comments
Closed

Let destructors move out of class fields if it's the last use. #2955

bblum opened this issue Jul 18, 2012 · 5 comments

Comments

@bblum
Copy link
Contributor

bblum commented Jul 18, 2012

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.

@eholk
Copy link
Contributor

eholk commented Jul 19, 2012

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.

@nikomatsakis
Copy link
Contributor

I would prefer not to make liveness more complex by supporting this case. However, we should fairly trivially be able to support something like:

let {f, g, h, _} = self

for destructors or any other case that takes owns self.

@bblum
Copy link
Contributor Author

bblum commented Jul 19, 2012

If non-destructor code destructures self, does it bypass the destructor?

@nikomatsakis
Copy link
Contributor

Interesting question. I think it would have to be illegal in that event to destructure a class with a dtor?

@bblum
Copy link
Contributor Author

bblum commented Aug 8, 2012

not sure if this is worth supporting. it doesn't add any expressiveness power if you can just use the option dance.

@bblum bblum closed this as completed Aug 8, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants