Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change WASI trait impls back to being blanket impls #8766

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

alexcrichton
Copy link
Member

This commit is a partial revert of #8609 to return wasmtime-wasi and wasmtime-wasi-http back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required &mut dyn WasiView to exist but sometimes only a Foo<'a> is held which is not easy to get a &mut dyn ... view of. By changing to a blanket impl in terms of a newtype wrapper, WasiImpl, it's possible to call bindgen!-generated add_to_linker_get_host functions with a return value of WasiImpl<Foo<'a>> which enables hooking into all the generated bindings.

This commit is a partial revert of bytecodealliance#8609 to return `wasmtime-wasi` and
`wasmtime-wasi-http` back to using blanket impls. The main change from
before is to change the blanket impls to be in terms of a local newtype
wrapper to avoid trait coherence issues. This is done because otherwise
using the traits before required `&mut dyn WasiView` to exist but
sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn
...` view of. By changing to a blanket impl in terms of a newtype
wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated
`add_to_linker_get_host` functions with a return value of
`WasiImpl<Foo<'a>>` which enables hooking into all the generated
bindings.
@alexcrichton alexcrichton requested a review from a team as a code owner June 10, 2024 22:01
@alexcrichton alexcrichton requested review from elliottt and removed request for a team June 10, 2024 22:01
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

@alexcrichton alexcrichton added this pull request to the merge queue Jun 10, 2024
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jun 10, 2024
…#8766)

This commit is a partial revert of bytecodealliance#8609 to return `wasmtime-wasi` and
`wasmtime-wasi-http` back to using blanket impls. The main change from
before is to change the blanket impls to be in terms of a local newtype
wrapper to avoid trait coherence issues. This is done because otherwise
using the traits before required `&mut dyn WasiView` to exist but
sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn
...` view of. By changing to a blanket impl in terms of a newtype
wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated
`add_to_linker_get_host` functions with a return value of
`WasiImpl<Foo<'a>>` which enables hooking into all the generated
bindings.
Merged via the queue into bytecodealliance:main with commit 9592d12 Jun 10, 2024
36 checks passed
@alexcrichton alexcrichton deleted the back-to-blankets branch June 10, 2024 22:41
alexcrichton added a commit that referenced this pull request Jun 10, 2024
* Change WASI trait impls back to being blanket impls (#8766)

This commit is a partial revert of #8609 to return `wasmtime-wasi` and
`wasmtime-wasi-http` back to using blanket impls. The main change from
before is to change the blanket impls to be in terms of a local newtype
wrapper to avoid trait coherence issues. This is done because otherwise
using the traits before required `&mut dyn WasiView` to exist but
sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn
...` view of. By changing to a blanket impl in terms of a newtype
wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated
`add_to_linker_get_host` functions with a return value of
`WasiImpl<Foo<'a>>` which enables hooking into all the generated
bindings.

* Update release notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants