alexcrichton requested pchickey for a review on PR #10760.
alexcrichton opened PR #10760 from alexcrichton:add-static-bound to bytecodealliance:main:
Since the beginning the
Ttype parameter onStore<T>has had no bounds on it. This was intended for maximal flexibility in terms of what embedders place within aStore<T>and I've personally advocated that we need to keep it this way. In the development of the WASIp3 work, however, I've at least personally reached the conclusion that this is no longer tenable and proceeding will require adding a'staticbound to data within a store.Wasmtime today [already] carries unsafe
transmutes to work around this lack of'staticbound, and while the number ofunsafeparts is relatively small right now we're still fundamentally lying to the compiler about lifetime bounds internally. With the WASIp3 async work this degree of "lying" has become even worse. Joel has written up some examples [on Zulip] about how the Rust compiler is requiring'staticbounds in surprising ways. These patterns are cropping up quite frequently in the WASIp3 work and it's becoming particularly onerous maintaining all of theunsafeand ensuring that everything is in sync.In the WASIp3 repository I've additionally [prototyped a change] which would additionally practically require
T: 'staticin more locations. This change is one I plan on landing in Wasmtime in the near future and while its main motivations are for enabling WASIp3 work it is also a much nicer system than what we have today, in my opinion.Overall the cost of not having
T: 'staticonStore<T>is effectively becoming quite costly, in particular with respect to WASIp3 work. This is coupled with all known embedders already usingT: 'staticdata within aStore<T>so the expectation of the impact of this change is not large. The main downside of this change as a result is that when and where to place'staticbounds is sort of a game of whack-a-mole with the compiler. For example I changedStore<T>to require'statichere, but the rest of the change is basically "hit compile until rustc says it's ok". There's not necessarily a huge amount of rhyme-or-reason to where'staticbounds crop up, which can be surprising or difficult to work with for users.In the end I feel that this change is necessary and one we can't shy away from. If problems crop up we'll need to figure out how to thread that needle at that time, but I'm coming around to thinking that
T: 'staticis just a fundamental constraint we'll have to take on at this time. Maybe a future version of Rust that fixes some of Joel's examples (if they can be fixed, we're not sure of that) we could consider relaxing this but that's left for future work.[already]: https://github.com/bytecodealliance/wasmtime/blob/35053d6d8d1a5d4692cf636cba0c920b4a79a44b/crates/wasmtime/src/runtime/store.rs#L602-L611
[on Zulip]: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.22type.20may.20not.20live.20long.20enough.22.20for.20generic.20closure/near/473862072
[prototyped a change]: https://github.com/bytecodealliance/wasip3-prototyping/pull/158<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-core-reviewers for a review on PR #10760.
alexcrichton requested wasmtime-default-reviewers for a review on PR #10760.
alexcrichton updated PR #10760.
alexcrichton updated PR #10760.
dicej submitted PR review.
Last updated: Dec 06 2025 at 06:05 UTC