-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Add Drop support for enums #15272
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Drop support for enums #15272
Conversation
@alexcrichton I know you had an interesting test case for this: enum Foo { NoDrop, NeedsDrop(Box<int>) }
impl Drop for Foo {
fn drop(&mut self) {
*self = NeedsDrop(box 3);
}
} but this just overflows the stack, which I guess is intended behaviour? |
This program also overflows its stack, so I think it is intended behavior yeah: struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
*self = Foo;
}
}
fn main() {
let _a = Foo;
} |
I'm not sure if there was a philosophical reason that |
@alexcrichton I see! Happy to feature gate it for now. I wasn't sure if this may in fact warrant an RFC. |
@alexcrichton IIRC it used to ICE. |
Indeed it used to ICE, but was that intentional or accidental? (I don't know) |
There's no reason why History time!
|
Nice @pcwalton |
@pcwalton Interesting, thanks! |
@pcwalton Would you be able to take a look at this? :-) |
span_err!(cx.tcx.sess, span, E0125, | ||
"cannot implement a destructor on a \ | ||
structure that does not satisfy Send"); | ||
nominal type that does not satisfy Send"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can you change this to "structure or enumeration"? "Nominal type" is a bit jargony, IMO.
Seems OK modulo a couple of nits. |
minor: Use a permalink to the SIMD line index code, and add a note on the GitHub API
Fixes #13041.