-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
"can't find crate for _serde" when deriving #856
Comments
Thanks for the report! Yes, adding serde to Cargo.toml is one of the setup steps in https://serde.rs/codegen.html. I pushed 2c49f9a to add |
@dtolnay OK, I thought so. The reason I mention this is because together with tree
Cargo.toml[package]
name = "issue-lib"
version = "0.1.0"
[dependencies]
serde_derive = "0.9"
toml = "0.3" lib.rs#[macro_use]
extern crate serde_derive;
extern crate toml;
#[derive(Deserialize)]
pub struct Foo {
} Backtrace
I would create an issue in the Rust repo for that, but it's not really a minimal example because of its dependencies. Note: |
Looks like that bug is fixed as of rustc 1.17.0-beta.3 so you don't need to file an issue. |
Hey, sorry for bumping. I have enabled |
Thanks @ishitatsuyuki, I filed #1026 and serde-rs/json#350 and serde-rs/serde-rs.github.io#62 to follow up. |
I don't understand, how to fix it? |
@GildedHonour read the entire thread before bumping. Basically, you need serde as a dependency in your Cargo.toml. |
yabai yo! |
I just encountered this error— My use case is slightly different. I have a project set up as a Cargo workspace, and I am thinking about setting up an internal With the I haven't looked into the internal workings of these macros at all, but I'm guessing they are looking for |
@kardeiz No, it only needs a cargo dependency. |
Hey, This doesn't work with package renaming |
how could we use it in web assembly |
Just wanted to mention that there is a solution/workaround someone found here: #1465 (comment) use common::serde::{self, Deserialize, Serialize}
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(crate = "self::serde")] // must be below the derive attribute
struct Vertex {
position: [u32; 3],
} I've been using it, and it seems to work fine. (the extra line for each derive usage is not the greatest, but it works -- and is better than adding an extraneous dependency on |
If I only include
serde_derive
in myCargo.toml
, I'll get anThis is the source code:
Adding
serde
to my dependencies fixes this.Is this a known issue?
The text was updated successfully, but these errors were encountered: