Skip to content

Cannot derive Clone when using 'braced_empty_structs' #29548

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

Closed
Thinkofname opened this issue Nov 3, 2015 · 6 comments
Closed

Cannot derive Clone when using 'braced_empty_structs' #29548

Thinkofname opened this issue Nov 3, 2015 · 6 comments
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Thinkofname
Copy link

Code:

#![feature(braced_empty_structs)]

#[derive(Clone)]
struct Test {}

fn main() {
}

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

Error:

<anon>:1:1: 1:1 error: unresolved enum variant, struct or const `Test` [E0419]
<anon>:1 #![feature(braced_empty_structs)]
         ^
<anon>:3:10: 3:15 note: in this expansion of #[derive_Clone] (defined in <anon>)
<anon>:1:1: 1:1 help: see the detailed explanation for E0419
<anon>:3:10: 3:15 error: `Test` is the name of a struct or struct variant, but this expression uses it like a function name [E0423]
<anon>:3 #[derive(Clone)]
                  ^~~~~
<anon>:3:10: 3:15 note: in this expansion of #[derive_Clone] (defined in <anon>)
<anon>:3:10: 3:15 help: see the detailed explanation for E0423
<anon>:3:10: 3:15 help: did you mean to write: `Test { /* fields */ }`?
error: aborting due to 2 previous errors

This should work just like struct Test; unless i'm missing something?

@steveklabnik
Copy link
Member

Yup, seems like a bug.

@petrochenkov
Copy link
Contributor

Derive can be simplified and always emit {} version for non-tuple structs, fixing this issue, but #29383 should land first.

@solson
Copy link
Member

solson commented Feb 19, 2016

This also affects enums, e.g. http://is.gd/qwKetS.

@alexreg
Copy link
Contributor

alexreg commented Feb 19, 2016

Any progress on this? This has been around a while.

It also occurs in enums:

#![feature(braced_empty_structs)]

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

@petrochenkov
Copy link
Contributor

I was waiting for stabilization of braced_empty_structs to fix this cleanly.
But it can be done without stabilization too, I'll try to fix it this weekend.

@alexreg
Copy link
Contributor

alexreg commented Feb 20, 2016

Thanks, that would be great.

Sent from my iPhone

On 20 Feb 2016, at 08:20, Vadim Petrochenkov notifications@github.com wrote:

I was waiting for stabilization of braced_empty_structs to fix this cleanly.
But it can be done without stabilization too, I'll try to fix it this weekend.


Reply to this email directly or view it on GitHub.

@steveklabnik steveklabnik added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Mar 24, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants