bytecodealliance / bytecodealliance/wit-bindgen
[Rust] See through type aliases for borrowing optimizations
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 286
- Avg merge
- 6h 32m
- Merged PRs (30d)
- 19
Description
As noted in https://github.com/bytecodealliance/wit-bindgen/issues/769 and https://github.com/bytecodealliance/wit-bindgen/pull/675, type aliases cause certain optimizations around borrowing to not longer be applied.
For example take the following semantically equivalent functions in wit:
```wit
borrow: func(param: list);
type param = list;
no-borrow: func(param: param);
```
Those functions will be generated as the following:
```rust
fn borrow(param: &[u8]);
type Param = Vec;
fn no_borrow(param: Param);
```
Unfortunately, we want to preserve the structure of the wit files in the generated code meaning that generating the `no_borrow` function with a `&[u8]` param instead of the `Param` alias would violate that tenant. It is unclear which should take precedent, the borrowing optimization or the desire to maintain wit structure.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.