bytecodealliance / bytecodealliance/wit-bindgen

Handling of typenames that match Rust typenames

Open
#146 3 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

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.

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.