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(flatten)] does not compile without "std" feature: could not find Content in de #1935

Closed
pftbest opened this issue Dec 19, 2020 · 2 comments

Comments

@pftbest
Copy link

pftbest commented Dec 19, 2020

error[E0433]: failed to resolve: could not find `Content` in `de`
  --> src/lib.rs:45:24
   |
45 | #[derive(Clone, Debug, Deserialize)]
   |                        ^^^^^^^^^^^ could not find `Content` in `de`
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Content` in module `_serde::private::de`
  --> src/lib.rs:45:24
   |
45 | #[derive(Clone, Debug, Deserialize)]
   |                        ^^^^^^^^^^^ not found in `_serde::private::de`
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `ToString` in `export`
  --> src/lib.rs:45:24
   |
45 | #[derive(Clone, Debug, Deserialize)]
   |                        ^^^^^^^^^^^ not found in `_serde::export`
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this trait
   |
5  | use std::string::ToString;
   |

error[E0433]: failed to resolve: could not find `Vec` in `export`
  --> src/lib.rs:45:24
   |
45 | #[derive(Clone, Debug, Deserialize)]
   |                        ^^^^^^^^^^^ not found in `_serde::export`
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
   |
5  | use std::vec::Vec;
   |
@dtolnay
Copy link
Member

dtolnay commented Dec 19, 2020

This is intentional - it needs a heap allocated buffer which is not present unless you use std or alloc.

@dtolnay dtolnay closed this as completed Dec 19, 2020
@t-moe
Copy link

t-moe commented Feb 23, 2024

Run into the same issue today, too bad there is no doc saying that this needs std.

https://serde.rs/attr-flatten.html

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

No branches or pull requests

3 participants