bytecodealliance / bytecodealliance/wit-bindgen

rust: trivial changes to wit definition alters the API of the generated code in an incompatible way

Aperta
#775 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
gen-rust
Lingua principale
Rust
Stelle
1.5k
Fork
286
Merge medio
6h 32m
PR unite (30g)
19

Descrizione

for example,
```
package foo:bar;

interface hoge {
variant v1 {
a(u32),
}
set1: func(v: v1);
get1: func() -> v1;

variant v2 {
a(u32),
b(string),
}
set2: func(v: v2);
get2: func() -> v2;
}

world useless {
import hoge;
}
```

given the above wit definition, `wit-bindgen rust a.wit` generates functions like:
```rust
pub fn set1(v: V1,){
```
```rust
pub fn set2(v: &V2,){
```

it's a bit surprising to me they are incompatible.
IMO, it's better to keep the same API for trivial changes like this.
i suspect it's simpler for users to use the generated code if you always use borrowed parameters for compound types like variant/record/etc for example.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia con l'esempio a.wit fornito ed esegui `wit-bindgen rust a.wit` per confrontare le firme generate per V1 e V2. Traccia il punto di ingresso della generazione dei binding Rust responsabile della proprietà dei parametri dei tipi composti; il lavoro è completato quando modifiche banali a WIT non producono più firme incompatibili, con copertura per entrambi gli esempi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust, wasm
Ambito
compilers
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.