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

Compile error: std::error::Error is not implemented #29

Closed
David-OConnor opened this issue May 2, 2020 · 7 comments
Closed

Compile error: std::error::Error is not implemented #29

David-OConnor opened this issue May 2, 2020 · 7 comments

Comments

@David-OConnor
Copy link

David-OConnor commented May 2, 2020

serde = { version = "1.0.106", features = ["derive"], default-features = false }
serde-json-core = "0.1.0"
error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0                      .1.0/src/de/enum_.rs:16:5
   |
15 | impl<'a, 'de> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de> {
   | ---------------------------------------------------------------- in this `i                      mpl` item
16 |     type Error = Error;
   |     ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented fo                      r `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0                      .1.0/src/de/enum_.rs:29:5
   |
28 | impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
   | ------------------------------------------------------------------- in this                       `impl` item
29 |     type Error = Error;
   |     ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented fo                      r `de::Error`

// etc
@netzdoktor
Copy link

Similar issue here for the latest version "0.2.0".

@zicklag
Copy link

zicklag commented Aug 6, 2021

I'm getting the same thing for version 0.4.0.

@ryan-summers
Copy link
Member

ryan-summers commented Aug 6, 2021

I suspect this may be related to MSRV (minimum supported Rust version). What rustc version are you using? Currently, I believe we only support 1.51 and above.

Edit:

You need to enable the std feature for serde-json-core to implement std::error:Error for the type. Check your Cargo.toml file.

@eldruin eldruin changed the title Error bug when compiling: Compile error: std::error::Error is not implemented Aug 6, 2021
@zicklag
Copy link

zicklag commented Aug 6, 2021

Oh, OK, that would be it, I was trying to build without std. 👍

@eldruin
Copy link
Member

eldruin commented Aug 6, 2021

Closing then. I adapted the title for better discoverability.
For future reference: per default this crate is no_std-compatible, which per definition excludes implementing std::error::Error.
If you need std::error::Error, activate the std feature for this crate in your Cargo.toml file.

@eldruin eldruin closed this as completed Aug 6, 2021
@TomzBench
Copy link

TomzBench commented May 21, 2022

I dont want the std::error. im trying to use no-std. and i still get this error.

serde = { version = "1", default-features = false, features = ["derive"] }
serde-json-core = { version = "0.4", default-features = false, features = ["heapless"] }

is in my cargo.toml ... is there something missing?

@ryan-summers
Copy link
Member

This can be a result of some of your other dependencies if you're using an older version of Cargo. Cargo's original feature resolver had a bug where dev-dependencies and such could enable features on other crates. Check out https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html

Also, check out cargo tree -e features to look at what features are actually enabled.

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

6 participants