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? :-) |
src/librustc/middle/kind.rs
Outdated
There was a problem hiding this comment.
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.