bytecodealliance / bytecodealliance/wit-bindgen

Unable to use `serde` macros in `additional_derives` when importing `wasi::http` types

Open
#812 4 comments 1 reaction 0 assignees View on GitHub
gen-rust
Dominant language
Rust
Stars
1.5k
Forks
286
Avg merge
6h 32m
Merged PRs (30d)
19

Description

I have a simple library testing out the `wasi:http` types. When I try to add an `additional_derives: [serde::Serialize, serde::Deserialize]` to the `wit_bindgen::generate!` macro definition I get the below error. Not sure if thise repo or the `wasi-http` repo would be better for this issue, but trying here first.

Reproduction can be found in [this repo](https://github.com/landonxjames/wasi-http-test). Uncommenting [this line](https://github.com/landonxjames/wasi-http-test/blob/5c1c393e2f432dc3c6ca4effbd36879ca2924488/runtime/src/lib.rs#L10) will cause the error.

```sh
error[E0277]: the trait bound `wasi::io::error::Error: Deserialize<'_>` is not satisfied
--> src/lib.rs:5:1
|
5 | / wit_bindgen::generate!({
6 | | world: "wasi-http-tests",
7 | | exports: {
8 | | "wasi-http-tests:component/client/wasi-http-tests-client": WasiHttpTestsClient,
9 | | },
10 | | additional_derives: [serde::Serialize, serde::Deserialize]
11 | | });
| |__^ the trait `Deserialize<'_>` is not implemented for `wasi::io::error::Error`
|
= help: the following other types implement trait `Deserialize<'de>`:
bool
char
isize
i8
i16
i32
i64
i128
and 137 others
note: required by a bound in `newtype_variant`
--> /Users/lnj/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.193/src/de/mod.rs:2119:12
|
2117 | fn newtype_variant(self) -> Result
| --------------- required by a bound in this associated function
2118 | where
2119 | T: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound in `VariantAccess::newtype_variant`
= note: this error originates in the macro `wit_bindgen::generate` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `wasi::io::error::Error: Serialize` is not satisfied
--> src/lib.rs:5:1
|
5 | / wit_bindgen::generate!({
6 | | world: "wasi-http-tests",
7 | | exports: {
8 | | "wasi-http-tests:component/client/wasi-http-tests-client": WasiHttpTestsClient,
9 | | },
10 | | additional_derives: [serde::Serialize, serde::Deserialize]
11 | | });
| |__^ the trait `Serialize` is not implemented for `wasi::io::error::Error`
|
= help: the following other types implement trait `Serialize`:
bool
char
isize
i8
i16
i32
i64
i128
and 136 others
note: required by a bound in `serialize_newtype_variant`
--> /Users/lnj/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.193/src/ser/mod.rs:936:12
|
928 | fn serialize_newtype_variant(
| ------------------------- required by a bound in this associated function
...
936 | T: Serialize;
| ^^^^^^^^^ required by this bound in `Serializer::serialize_newtype_variant`
= note: this error originates in the macro `wit_bindgen::generate` (in Nightly builds, run with -Z macro-backtrace for more info)

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.