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

Unable to use #[derive(Response)] with #[prost(...)] #203

Open
snawaz opened this issue Mar 27, 2019 · 2 comments
Open

Unable to use #[derive(Response)] with #[prost(...)] #203

snawaz opened this issue Mar 27, 2019 · 2 comments

Comments

@snawaz
Copy link

snawaz commented Mar 27, 2019

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 prost is 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.

@repnop
Copy link

repnop commented May 3, 2019

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)

@elpiel
Copy link
Contributor

elpiel commented Jun 17, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants