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

RFC: Limit what types can have destructors #4301

Closed
nikomatsakis opened this issue Dec 28, 2012 · 5 comments
Closed

RFC: Limit what types can have destructors #4301

nikomatsakis opened this issue Dec 28, 2012 · 5 comments
Labels
A-destructors Area: destructors (Drop, ..)

Comments

@nikomatsakis
Copy link
Contributor

We need some limits on destructors to prevent bugs like bugs like #3167, #3039, #4170. Also to address the various challenges of destructors and finalizers that have been uncovered in other languages.

My current preference is to say that destructors can only be created for sendable types. Or, put another way, destructors should only be able to access owned content. Perhaps this is too extreme, but it's a nice simple rule.

Anyway, I wanted to open a blanket bug for those other bugs, and perhaps to spark some discussion and thought.

@catamorphism
Copy link
Contributor

I vote for trying the "extreme" rule first (destructors can only access owned memory), and loosening it if it turns out to be too restrictive in practice.

@pcwalton
Copy link
Contributor

Note that I think this kills the icx_popper, and kills using destructors for Go-like defer as well.

@nikomatsakis
Copy link
Contributor Author

Yes, I think the extended version we talked about was somehow limiting non-sendable types with dtors from being placed into @ boxes, or something like that, with the goal of ensuring that they exist only on the stack, but that sounds like it requires more type system machinery (another kind) to achieve.

@catamorphism
Copy link
Contributor

Can this be closed given d4fee24?

@nikomatsakis
Copy link
Contributor Author

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: destructors (Drop, ..)
Projects
None yet
Development

No branches or pull requests

3 participants