-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cannot derrive Clone for empty enums when using no_std #31574
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
Comments
Related: #29548 |
This is actually common to all derives, and the bug is that when generating a panic expression, it hardcodes |
Oh wow now that's just crazy (calling some runtime panic function..) I think this would be more appropriate to perhaps derive as: impl Clone for MyEnum {
fn clone(&self) -> MyEnum {
match *self {}
}
} |
@alexcrichton it could equivalently call |
Perhaps, but using |
@alexcrichton as far as I can tell this is the only in-tree usage of |
Hm, in theory we should just never call those functions. In contexts with empty enums they never exist so they shouldn't even panic, I'm not sure about others though. |
Generating For that reason, changing it to use intrinsics unreachable may be the simplest. |
derive: use intrinsics::unreachable over unreachable!() derive: use intrinsics::unreachable over unreachable!() Fixes #31574. Spawned from #32139. r? @alexcrichton
derriving clone on an empty enum does not work without std, because it calls
core::rt::begin_unwind
:leads to:
Playground: https://play.rust-lang.org/?gist=7f786db03eca51a39900&version=nightly
The text was updated successfully, but these errors were encountered: