bytecodealliance / bytecodealliance/wit-bindgen
Unable to use `serde` macros in `additional_derives` when importing `wasi::http` types
- Lingua principale
- Rust
- Stelle
- 1.5k
- Fork
- 286
- Merge medio
- 6h 32m
- PR unite (30g)
- 19
Descrizione
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)
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con la riproduzione in runtime/src/lib.rs e l’invocazione di wit_bindgen::generate!, quindi esamina come additional_derives viene applicato ai tipi wasi:http importati. Esegui la riproduzione collegata con i derives decommentati e traccia il motivo per cui wasi::io::error::Error non dispone dei trait serde richiesti. Il lavoro è completato quando i tipi wasi:http segnalati possono usare i derives richiesti senza questi errori dei trait.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust, wasm
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100