Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upCodegen errors when `proc_macro` feature enabled #1232
Comments
This comment has been minimized.
|
As mentioned, this is not a bug in Diesel. Closing as there's nothing actionable for us to do. |
sgrif
closed this
Oct 6, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
kardeiz commentedOct 2, 2017
If you have the
proc_macrofeature enabled and use Diesel's codegen derives, you will (usually) get compilation errors like:I realized that I wasn't having the same issue with serde's derive/attributes, and discovered that it is because, when
proc_macrois enabled, it only allows the set of whitelisted attributes for the first derived trait. So if you use only#[derive(Queryable)(or any one trait), you are fine. If you#[derive(Queryable, Identifiable)you will get an error.I think this has to be a bug in
proc_macro. This can be worked around in Diesel by putting all the possible attributes in each attribute set, for example indiesel_codegenlike:However, if you need custom derives on a struct from both Diesel and, say, serde, you would be in trouble; only the top level attributes from one library or the other could be applied.
See rust-lang/rust#44925 for some more details. This is not a bug in Diesel, but I am putting it here for discussion or in case anyone runs into the same issue and needs a quick fix.