Skip to content

Refactor how InitContext works with factors #3134

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexcrichton
Copy link
Contributor

This commit is a refactoring to replace the concrete InitContext structure with a generic type parameter instead. The motivation for this is to prepare for handling bytecodealliance/wasmtime#10770. That's a big change to how add_to_linker functions work, notably that the argument to the generated functions is a fn, not a F: Fn. WASI factors currently rely on the closure-like nature this argument which means it's not compatible with that change. The refactoring to use a trait InitContext here enables plumbing a type parameter through a function to be able to get a function pointer without relying on closures.

This commit is a refactoring to replace the concrete `InitContext`
structure with a generic type parameter instead. The motivation for this
is to prepare for handling bytecodealliance/wasmtime#10770. That's a big
change to how `add_to_linker` functions work, notably that the argument
to the generated functions is a `fn`, not a `F: Fn`. WASI factors
currently rely on the closure-like nature this argument which means it's
not compatible with that change. The refactoring to use a `trait
InitContext` here enables plumbing a type parameter through a function
to be able to get a function pointer without relying on closures.

Signed-off-by: Alex Crichton <[email protected]>
@alexcrichton alexcrichton force-pushed the refactor-for-has-data branch from 005adbf to ec308bb Compare May 12, 2025 09:02
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.

1 participant