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

regression serde feature does not work with no-std #336

Closed
vmx opened this issue Aug 25, 2023 · 0 comments · Fixed by #337
Closed

regression serde feature does not work with no-std #336

vmx opened this issue Aug 25, 2023 · 0 comments · Fixed by #337
Assignees

Comments

@vmx
Copy link
Member

vmx commented Aug 25, 2023

With the release of v0.19 we broke the ability to use Serde in no_std contexts. When you compile with:

$ cargo build --no-default-features --features serde
   Compiling multihash v0.19.0 (/tmp/rust-multihash)
error[E0432]: unresolved import `std`
 --> src/serde.rs:3:5
  |
3 | use std::fmt;
  |     ^^^ use of undeclared crate or module `std`

error: cannot find macro `format` in this scope
  --> src/serde.rs:35:46
   |
35 |             .map_err(|err| de::Error::custom(format!("Failed to deserialize Multihash: {}", err)))
   |                                              ^^^^^^

error: cannot find macro `format` in this scope
  --> src/serde.rs:48:46
   |
48 |             .map_err(|err| de::Error::custom(format!("Failed to deserialize Multihash: {}", err)))
   |                                              ^^^^^^

error[E0599]: no method named `to_bytes` found for reference `&Multihash<SIZE>` in the current scope
  --> src/serde.rs:17:42
   |
17 |         serializer.serialize_bytes(&self.to_bytes())
   |                                          ^^^^^^^^ method not found in `&Multihash<SIZE>`

error[E0433]: failed to resolve: use of undeclared type `Vec`
  --> src/serde.rs:43:25
   |
43 |         let mut bytes = Vec::new();
   |                         ^^^ use of undeclared type `Vec`

Some errors have detailed explanations: E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `multihash` (lib) due to 5 previous errors

This is a regression as it works with v0.18.

@vmx vmx self-assigned this Aug 25, 2023
vmx added a commit that referenced this issue Aug 25, 2023
`multihash` v0.19 introduced a regression. It's no longer possible to compile
with `no_std` and `serde` feature enabled. This commit fixes that regression.

Due to generic_const_exprs not being a thing yet, we need to use unsafe code
to provide this functionality.

Fixes #336.
vmx added a commit that referenced this issue Aug 25, 2023
`multihash` v0.19 introduced a regression. It's no longer possible to compile
with `no_std` and `serde` feature enabled. This commit fixes that regression.

Due to generic_const_exprs not being a thing yet, we need to use unsafe code
to provide this functionality.

Fixes #336.
vmx added a commit that referenced this issue Aug 25, 2023
`multihash` v0.19 introduced a regression. It's no longer possible to compile
with `no_std` and `serde` feature enabled. This commit fixes that regression.

Due to generic_const_exprs not being a thing yet, we need to use unsafe code
to provide this functionality.

Fixes #336.
@vmx vmx closed this as completed in #337 Sep 5, 2023
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

Successfully merging a pull request may close this issue.

1 participant