Skip to content
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

Serde field attributes not written to TokenStream #585

Closed
KodrAus opened this Issue Oct 14, 2016 · 1 comment

Comments

3 participants
@KodrAus
Copy link

KodrAus commented Oct 14, 2016

Previously, I've piggybacked on serde_codegen_internals to get whether or not a field will be serialised, and if so, what it will be called.

With the new macros 1.1 stuff this doesn't work because the serde field attributes are being removed from the token stream output if my code runs after Serialize:

//No serde attributes for ElasticType
#[derive(Serialize, ElasticType)]
struct MyType { ... }
//All the serde attributes for ElasticType
#[derive(ElasticType, Serialize)]
struct MyType { ... }

Wouldn't this also affect attributes visible to Deserialize if you also derive Serialize first?

@KodrAus KodrAus changed the title Serde attributes not to TokenStream Serde attributes not written to TokenStream Oct 14, 2016

@KodrAus KodrAus changed the title Serde attributes not written to TokenStream Serde field attributes not written to TokenStream Oct 14, 2016

@sfackler

This comment has been minimized.

Copy link
Contributor

sfackler commented Oct 15, 2016

This is intentional - the crate would fail to compile if the attributes weren't stripped since they're unknown to the compiler. It's one of the known bugs on the tracking issue for macros 1.1: rust-lang/rust#35900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.