Skip to content

Cannot derrive Clone for empty enums when using no_std #31574

Closed
@Roxxik

Description

@Roxxik

derriving clone on an empty enum does not work without std, because it calls core::rt::begin_unwind:

#![no_std]

#[derive(Copy, Clone)]
enum MyEnum { }

leads to:

<anon>:4:16: 4:21 error: failed to resolve. Could not find `rt` in `core` [E0433]
<anon>:4 #[derive(Copy, Clone)]
                        ^~~~~
<anon>:4:16: 4:21 note: in this expansion of #[derive_Clone] (defined in <anon>)
<anon>:4:16: 4:21 help: see the detailed explanation for E0433
<anon>:4:16: 4:21 error: unresolved name `core::rt::begin_unwind` [E0425]
<anon>:4 #[derive(Copy, Clone)]
                        ^~~~~
<anon>:4:16: 4:21 note: in this expansion of #[derive_Clone] (defined in <anon>)
<anon>:4:16: 4:21 help: see the detailed explanation for E0425
error: main function not found
error: aborting due to 3 previous errors

Playground: https://play.rust-lang.org/?gist=7f786db03eca51a39900&version=nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions