bytecodealliance / bytecodealliance/wit-bindgen

Handling of typenames that match Rust typenames

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

Descrizione

Here is the minimal wit file:
```wit
record result {
data: list,
}

func: function() -> expected
```

Which yields the following error:
```
error[E0107]: this struct takes 0 generic arguments but 2 generic arguments were supplied
--> sdk/src/client.rs:1:1
|
1 | wit_bindgen_rust::import!("./wit/some.wit");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: remove these generics
| |
| expected 0 generic arguments
|
note: struct defined here, with 0 generic parameters
--> sdk/src/client.rs:1:1
|
1 | wit_bindgen_rust::import!("./wit/some.wit");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `wit_bindgen_rust::import` (in Nightly builds, run with -Z macro-backtrace for more info)
```

It wasn't obvious what's going on, but the generated code contains the following:
```rust
pub fn func() -> Result{
```

We wit-bindgen should either emit some warnings/errors, or perhaps use full paths like `::core::result::Result`? The latter is common in macros for any other types, but I think it's not common for `Result` and `Option`, so not sure what is the best option.

The issue is pretty minor, though.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Riprodurre l’esempio WIT minimo e ispezionare sdk/src/client.rs generato da wit_bindgen_rust::import!, in particolare la firma Result. Tracciare il punto in cui vengono selezionati i nomi dei tipi generati; il lavoro è completato quando l’esempio non entra più in conflitto con il tipo Result di Rust e compila senza l’errore E0107 segnalato.

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

Valutazione

Stack tecnologico
rust
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
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.