Compile error: std::error::Error is not implemented
David-OConnor opened this issue · 7 comments
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`
// etcSimilar issue here for the latest version "0.2.0".
I'm getting the same thing for version 0.4.0.
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.
Oh, OK, that would be it, I was trying to build without std. 👍
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.
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?
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.