Unable to use #[derive(Response)] with #[prost(...)]
The following code fails to compile:
#[derive(Debug, Serialize, Deserialize)]
#[derive(Extract)]
#[derive(Response)] // LINE 3
pub struct Example {
#[prost(string, tag="1")] // LINE 5
pub data: String
}
with this error message:
error[E0658]: The attribute
prostis currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> src/logic.rs:89:5
|
89 | #[prost(string, tag="1")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^error: aborting due to previous error
And
- If we comment
LINE 3, it compiles fine. - If we comment
LINE 5, it compiles fine.
That implies Response doesn't work when prost is present.
Just ran into this with diesel's Insertable derive macro as well. The #[table_name = "..."] attribute suddenly becomes unknown and wont compile. To get around this I manually derived Serialize onto the base struct, created a wrapper struct and had to do
#[derive(Response, Serialize)]
#[serde(transparent)]
struct Wrapper(Inner);
(according to the docs, I shouldn't need to derive Serialize there, but got the same error about the serde attribute as above without it)
Found out the same thing that serde() don't work and you need to manually add Serialize and/or Deserialize to the derives. Should we actually update the docs or there is a bug here?