bytecodealliance / bytecodealliance/wit-bindgen
Rust: Wrong lifetime parameters for generated struct
- Lingua principale
- Rust
- Stelle
- 1.5k
- Fork
- 286
- Merge medio
- 6h 32m
- PR unite (30g)
- 19
Descrizione
For a particular combination of `use`, `import`, and `export` with aggregate types (records containing lists), wit-bindgen generates invalid Rust, producing the following compiler error:
```
struct takes 0 lifetime arguments but 1 lifetime argument was supplied
expected 0 lifetime arguments
```
wit-bindgen seems to mistakenly think that the generated `MyList` has a lifetime parameter when creating a typedef for it in the binding scope:
```
pub type MyList<'a> =
super::super::super::super::repro::repro::my_interface::MyList<'a>;
```
# world.wit
```
package repro:repro@0.0.1;
interface my-interface {
record my-list {
// Not reproducible without this.
groups: list,
}
}
interface plugin-core {
use my-interface.{my-list};
record info {
// Not reproducible without this.
settings: my-list,
}
}
interface plugin {
use plugin-core.{info};
// Not reproducible without this.
use my-interface.{my-list};
// Not reproducible without this.
get-plugin-info: func() -> info;
}
world my-world {
export plugin;
}
```
# lib.rs
```rust
pub mod bindings {
wit_bindgen::generate!(
{
world: "my-world",
path: "wit",
// Not reproducible with `false`.
generate_unused_types: true,
// Not reproducible with `Owning`.
ownership: Borrowing { duplicate_if_necessary: true },
additional_derives: [PartialEq, Clone],
}
);
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Riproduci il fallimento con gli esempi world.wit e lib.rs, usando wit_bindgen::generate! con generate_unused_types e Borrowing ownership abilitati. Traccia il typedef MyList generato e la gestione del relativo lifetime; il lavoro è completato quando i bindings non forniscono più un parametro di lifetime non valido e il Rust generato viene compilato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust, wasm
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 48/100