Skip to content

Commit 5f22771

Browse files
dicejvados-cosmonic
authored andcommitted
Add support for async/streams/futures
This adds support for loading, compiling, linking, and running components which use the [Async ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md) along with the [`stream`, `future`, and `error-context`](WebAssembly/component-model#405) types. It also adds support for generating host bindings such that multiple host functions can be run concurrently with guest tasks -- without monopolizing the `Store`. See the [implementation RFC](bytecodealliance/rfcs#38) for details, as well as [this repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke tests. Signed-off-by: Joel Dice <[email protected]> fix clippy warnings and bench/fuzzing errors Signed-off-by: Joel Dice <[email protected]> revert atomic.wit whitespace change Signed-off-by: Joel Dice <[email protected]> fix build when component-model disabled Signed-off-by: Joel Dice <[email protected]> bless component-macro expected output Signed-off-by: Joel Dice <[email protected]> fix no-std build error Signed-off-by: Joel Dice <[email protected]> fix build with --no-default-features --features runtime,component-model Signed-off-by: Joel Dice <[email protected]> partly fix no-std build It's still broken due to the use of `std::collections::HashMap` in crates/wasmtime/src/runtime/vm/component.rs. I'll address that as part of the work to avoid exposing global task/future/stream/error-context handles to guests. Signed-off-by: Joel Dice <[email protected]> maintain per-instance tables for futures, streams, and error-contexts Signed-off-by: Joel Dice <[email protected]> refactor task/stream/future handle lifting/lowering This addresses a couple of issues: - Previously, we were passing task/stream/future/error-context reps directly to instances while keeping track of which instance had access to which rep. That worked fine in that there was no way to forge access to inaccessible reps, but it leaked information about what other instances were doing. Now we maintain per-instance waitable and error-context tables which map the reps to and from the handles which the instance sees. - The `no_std` build was broken due to use of `HashMap` in `runtime::vm::component`, which is now fixed. Note that we use one single table per instance for all tasks, streams, and futures. This is partly necessary because, when async events are delivered to the guest, it wouldn't have enough context to know which stream or future we're talking about if each unique stream and future type had its own table. So at minimum, we need to use the same table for all streams (regardless of payload type), and likewise for futures. Also, per WebAssembly/component-model#395 (comment), the plan is to move towards a shared table for all resource types as well, so this moves us in that direction. Signed-off-by: Joel Dice <[email protected]> fix wave breakage due to new stream/future/error-context types Signed-off-by: Joel Dice <[email protected]> switch wasm-tools to v1.220.0-based branch Signed-off-by: Joel Dice <[email protected]> check `task.return` type at runtime We can't statically verify a given call to `task.return` corresponds to the expected core signature appropriate for the currently running task, so we must do so at runtime. In order to make that check efficient, we intern the types. My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex` for interning, but that got hairy with WasmGC considerations, so instead I added new fields to `ComponentTypes` and `ComponentTypesBuilder`. Signed-off-by: Joel Dice <[email protected]> add `TypedFunc::call_concurrent` and refine stream/future APIs This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime. Specifically, it adds: - A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress. - A new `PromisesUnordered` type for `await`ing multiple promises concurrently -`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance. - Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise` The upshot is that the embedder can now ergonomically manage arbitrary numbers of concurrent operations. Previously, this was a lot more difficult to do without accidentally starving some of the operations due to another one monopolizing the `Store`. Finally, this includes various refactorings and fixes for bugs exposed by the newer, more versatile APIs. Signed-off-by: Joel Dice <[email protected]> clean up verbosity in component/func.rs Signed-off-by: Joel Dice <[email protected]> snapshot Signed-off-by: Joel Dice <[email protected]> implement stream/future read/write cancellation This required a somewhat viral addition of `Send` and `Sync` bounds for async host function closure types, unfortunately. Signed-off-by: Joel Dice <[email protected]> add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent` Signed-off-by: Joel Dice <[email protected]> dynamic API support for streams/futures/error-contexts Signed-off-by: Joel Dice <[email protected]> support callback-less (AKA stackful) async lifts Signed-off-by: Joel Dice <[email protected]> fix `call_host` regression Signed-off-by: Joel Dice <[email protected]> add component model async end-to-end tests I've ported these over from https://github.com/dicej/component-async-demo Signed-off-by: Joel Dice <[email protected]> fix test regressions and clippy warnings Signed-off-by: Joel Dice <[email protected]> satisfy clippy Signed-off-by: Joel Dice <[email protected]> fix async tests when `component-model-async` enabled Enabling this feature for all tests revealed various missing pieces in the new `concurrent.rs` fiber mechanism, which I've addressed. This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards, but those will all go away once I unify the two async fiber implementations. Signed-off-by: Joel Dice <[email protected]> add and modify tests to cover concurrent APIs Primarily, this tests and implements cases where parameters and/or results must be passed via linear memory instead of the stack. Signed-off-by: Joel Dice <[email protected]> `concurrent_{imports|exports}` component macro codegen tests This enables codegen testing of the `concurrent_imports` and `concurrent_exports` options to `wasmtime::component::bindgen` and also fixes code generation for world-level function and resource exports that use the concurrent call style. Signed-off-by: Joel Dice <[email protected]> `concurrent_{imports|exports}` component macro expanded tests This enables testing of the `concurrent_imports` and `concurrent_exports` options in `crates/component-macro/tests/expanded.rs`. Signed-off-by: Joel Dice <[email protected]> add tests/misc_testsuite/component-model-async/*.wast These only test instantiation of components which use various async options and built-ins so far. Next, I'll happy and sad path tests which actually execute code. Signed-off-by: Joel Dice <[email protected]> appease clippy Signed-off-by: Joel Dice <[email protected]> add tests/misc_testsuite/component-model-async/fused.wast Signed-off-by: Joel Dice <[email protected]> add non-panicking bounds checks where appropriate Signed-off-by: Joel Dice <[email protected]> remove post-return bits from async result lift code ...at least until we've determined whether post-return options even make sense for async-lifted exports. Signed-off-by: Joel Dice <[email protected]> fix component-model-async/fused.wast test failure Signed-off-by: Joel Dice <[email protected]> use `enum` types to represent status and event codes Signed-off-by: Joel Dice <[email protected]> fix component-model-async/fused.wast test failure (2nd try) Signed-off-by: Joel Dice <[email protected]> use `gc_types = true` in component-model-async/fused.wast We use `Instruction::RefFunc` when generating adapters for async lifts and/or lowers, which Winch doesn't understand, and apparently `gc_types = true` is what tells the test infra not to use Winch. Signed-off-by: Joel Dice <[email protected]> trap if async function finishes without calling `task.return` Signed-off-by: Joel Dice <[email protected]> update wit-bindgen and fix rebase damage Signed-off-by: Joel Dice <[email protected]> call post-return function if any for async->sync fused calls Signed-off-by: Joel Dice <[email protected]> fix non-component-model-async build; appease clippy Signed-off-by: Joel Dice <[email protected]> bless bindgen output whitespace changes Signed-off-by: Joel Dice <[email protected]> enforce resource borrow requirements for async calls Signed-off-by: Joel Dice <[email protected]> update `wit-bindgen` and simplify `async_borrowing_callee` test Signed-off-by: Joel Dice <[email protected]> call `InstanceFlags::set_may_enter` where appropriate There's still more work to do to fully implement (and test) the reentrance rules for concurrent tasks, but this is a start. Signed-off-by: Joel Dice <[email protected]> finish implementing reentrance checks Signed-off-by: Joel Dice <[email protected]> feat: implement error-context (bytecodealliance#1) * feat: initial error-context implementation This commit implements error-context related functions inside the VM, along with tests to ensure that basic error-context.new and error-context.debug-message functionality works. Signed-off-by: Victor Adossi <[email protected]> * wip: add test for error context callee/caller transfer Signed-off-by: Victor Adossi <[email protected]> * wip: test for async context transfer Signed-off-by: Victor Adossi <[email protected]> --------- Signed-off-by: Victor Adossi <[email protected]> run cargo fmt Signed-off-by: Joel Dice <[email protected]> appease clippy Signed-off-by: Joel Dice <[email protected]> pull in Roman's unit stream work; add world-level export test Signed-off-by: Joel Dice <[email protected]> add unit stream tests Signed-off-by: Joel Dice <[email protected]>
1 parent d1596df commit 5f22771

File tree

86 files changed

+577
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+577
-739
lines changed

crates/component-macro/tests/expanded/char_async.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<T> Clone for TheWorldPre<T> {
1818
}
1919
}
2020
}
21-
impl<_T> TheWorldPre<_T> {
21+
impl<_T: Send + 'static> TheWorldPre<_T> {
2222
/// Creates a new copy of `TheWorldPre` bindings which can then
2323
/// be used to instantiate into a particular store.
2424
///
@@ -46,10 +46,7 @@ impl<_T> TheWorldPre<_T> {
4646
pub async fn instantiate_async(
4747
&self,
4848
mut store: impl wasmtime::AsContextMut<Data = _T>,
49-
) -> wasmtime::Result<TheWorld>
50-
where
51-
_T: Send,
52-
{
49+
) -> wasmtime::Result<TheWorld> {
5350
let mut store = store.as_context_mut();
5451
let instance = self.instance_pre.instantiate_async(&mut store).await?;
5552
self.indices.load(&mut store, &instance)
@@ -157,7 +154,7 @@ const _: () = {
157154
linker: &wasmtime::component::Linker<_T>,
158155
) -> wasmtime::Result<TheWorld>
159156
where
160-
_T: Send,
157+
_T: Send + 'static,
161158
{
162159
let pre = linker.instantiate_pre(component)?;
163160
TheWorldPre::new(pre)?.instantiate_async(store).await
@@ -376,7 +373,7 @@ pub mod exports {
376373
arg0: char,
377374
) -> wasmtime::Result<()>
378375
where
379-
<S as wasmtime::AsContext>::Data: Send,
376+
<S as wasmtime::AsContext>::Data: Send + 'static,
380377
{
381378
let callee = unsafe {
382379
wasmtime::component::TypedFunc::<
@@ -396,7 +393,7 @@ pub mod exports {
396393
mut store: S,
397394
) -> wasmtime::Result<char>
398395
where
399-
<S as wasmtime::AsContext>::Data: Send,
396+
<S as wasmtime::AsContext>::Data: Send + 'static,
400397
{
401398
let callee = unsafe {
402399
wasmtime::component::TypedFunc::<

crates/component-macro/tests/expanded/char_tracing_async.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<T> Clone for TheWorldPre<T> {
1818
}
1919
}
2020
}
21-
impl<_T> TheWorldPre<_T> {
21+
impl<_T: Send + 'static> TheWorldPre<_T> {
2222
/// Creates a new copy of `TheWorldPre` bindings which can then
2323
/// be used to instantiate into a particular store.
2424
///
@@ -46,10 +46,7 @@ impl<_T> TheWorldPre<_T> {
4646
pub async fn instantiate_async(
4747
&self,
4848
mut store: impl wasmtime::AsContextMut<Data = _T>,
49-
) -> wasmtime::Result<TheWorld>
50-
where
51-
_T: Send,
52-
{
49+
) -> wasmtime::Result<TheWorld> {
5350
let mut store = store.as_context_mut();
5451
let instance = self.instance_pre.instantiate_async(&mut store).await?;
5552
self.indices.load(&mut store, &instance)
@@ -157,7 +154,7 @@ const _: () = {
157154
linker: &wasmtime::component::Linker<_T>,
158155
) -> wasmtime::Result<TheWorld>
159156
where
160-
_T: Send,
157+
_T: Send + 'static,
161158
{
162159
let pre = linker.instantiate_pre(component)?;
163160
TheWorldPre::new(pre)?.instantiate_async(store).await
@@ -405,7 +402,7 @@ pub mod exports {
405402
arg0: char,
406403
) -> wasmtime::Result<()>
407404
where
408-
<S as wasmtime::AsContext>::Data: Send,
405+
<S as wasmtime::AsContext>::Data: Send + 'static,
409406
{
410407
use tracing::Instrument;
411408
let span = tracing::span!(
@@ -434,7 +431,7 @@ pub mod exports {
434431
mut store: S,
435432
) -> wasmtime::Result<char>
436433
where
437-
<S as wasmtime::AsContext>::Data: Send,
434+
<S as wasmtime::AsContext>::Data: Send + 'static,
438435
{
439436
use tracing::Instrument;
440437
let span = tracing::span!(

crates/component-macro/tests/expanded/conventions_async.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<T> Clone for TheWorldPre<T> {
1818
}
1919
}
2020
}
21-
impl<_T> TheWorldPre<_T> {
21+
impl<_T: Send + 'static> TheWorldPre<_T> {
2222
/// Creates a new copy of `TheWorldPre` bindings which can then
2323
/// be used to instantiate into a particular store.
2424
///
@@ -46,10 +46,7 @@ impl<_T> TheWorldPre<_T> {
4646
pub async fn instantiate_async(
4747
&self,
4848
mut store: impl wasmtime::AsContextMut<Data = _T>,
49-
) -> wasmtime::Result<TheWorld>
50-
where
51-
_T: Send,
52-
{
49+
) -> wasmtime::Result<TheWorld> {
5350
let mut store = store.as_context_mut();
5451
let instance = self.instance_pre.instantiate_async(&mut store).await?;
5552
self.indices.load(&mut store, &instance)
@@ -159,7 +156,7 @@ const _: () = {
159156
linker: &wasmtime::component::Linker<_T>,
160157
) -> wasmtime::Result<TheWorld>
161158
where
162-
_T: Send,
159+
_T: Send + 'static,
163160
{
164161
let pre = linker.instantiate_pre(component)?;
165162
TheWorldPre::new(pre)?.instantiate_async(store).await
@@ -688,7 +685,7 @@ pub mod exports {
688685
mut store: S,
689686
) -> wasmtime::Result<()>
690687
where
691-
<S as wasmtime::AsContext>::Data: Send,
688+
<S as wasmtime::AsContext>::Data: Send + 'static,
692689
{
693690
let callee = unsafe {
694691
wasmtime::component::TypedFunc::<
@@ -706,7 +703,7 @@ pub mod exports {
706703
arg0: LudicrousSpeed,
707704
) -> wasmtime::Result<()>
708705
where
709-
<S as wasmtime::AsContext>::Data: Send,
706+
<S as wasmtime::AsContext>::Data: Send + 'static,
710707
{
711708
let callee = unsafe {
712709
wasmtime::component::TypedFunc::<
@@ -725,7 +722,7 @@ pub mod exports {
725722
mut store: S,
726723
) -> wasmtime::Result<()>
727724
where
728-
<S as wasmtime::AsContext>::Data: Send,
725+
<S as wasmtime::AsContext>::Data: Send + 'static,
729726
{
730727
let callee = unsafe {
731728
wasmtime::component::TypedFunc::<
@@ -741,7 +738,7 @@ pub mod exports {
741738
S: wasmtime::AsContextMut,
742739
>(&self, mut store: S) -> wasmtime::Result<()>
743740
where
744-
<S as wasmtime::AsContext>::Data: Send,
741+
<S as wasmtime::AsContext>::Data: Send + 'static,
745742
{
746743
let callee = unsafe {
747744
wasmtime::component::TypedFunc::<
@@ -758,7 +755,7 @@ pub mod exports {
758755
mut store: S,
759756
) -> wasmtime::Result<()>
760757
where
761-
<S as wasmtime::AsContext>::Data: Send,
758+
<S as wasmtime::AsContext>::Data: Send + 'static,
762759
{
763760
let callee = unsafe {
764761
wasmtime::component::TypedFunc::<
@@ -775,7 +772,7 @@ pub mod exports {
775772
mut store: S,
776773
) -> wasmtime::Result<()>
777774
where
778-
<S as wasmtime::AsContext>::Data: Send,
775+
<S as wasmtime::AsContext>::Data: Send + 'static,
779776
{
780777
let callee = unsafe {
781778
wasmtime::component::TypedFunc::<
@@ -792,7 +789,7 @@ pub mod exports {
792789
mut store: S,
793790
) -> wasmtime::Result<()>
794791
where
795-
<S as wasmtime::AsContext>::Data: Send,
792+
<S as wasmtime::AsContext>::Data: Send + 'static,
796793
{
797794
let callee = unsafe {
798795
wasmtime::component::TypedFunc::<
@@ -809,7 +806,7 @@ pub mod exports {
809806
mut store: S,
810807
) -> wasmtime::Result<()>
811808
where
812-
<S as wasmtime::AsContext>::Data: Send,
809+
<S as wasmtime::AsContext>::Data: Send + 'static,
813810
{
814811
let callee = unsafe {
815812
wasmtime::component::TypedFunc::<
@@ -831,7 +828,7 @@ pub mod exports {
831828
mut store: S,
832829
) -> wasmtime::Result<()>
833830
where
834-
<S as wasmtime::AsContext>::Data: Send,
831+
<S as wasmtime::AsContext>::Data: Send + 'static,
835832
{
836833
let callee = unsafe {
837834
wasmtime::component::TypedFunc::<
@@ -848,7 +845,7 @@ pub mod exports {
848845
mut store: S,
849846
) -> wasmtime::Result<()>
850847
where
851-
<S as wasmtime::AsContext>::Data: Send,
848+
<S as wasmtime::AsContext>::Data: Send + 'static,
852849
{
853850
let callee = unsafe {
854851
wasmtime::component::TypedFunc::<
@@ -865,7 +862,7 @@ pub mod exports {
865862
mut store: S,
866863
) -> wasmtime::Result<()>
867864
where
868-
<S as wasmtime::AsContext>::Data: Send,
865+
<S as wasmtime::AsContext>::Data: Send + 'static,
869866
{
870867
let callee = unsafe {
871868
wasmtime::component::TypedFunc::<
@@ -883,7 +880,7 @@ pub mod exports {
883880
mut store: S,
884881
) -> wasmtime::Result<()>
885882
where
886-
<S as wasmtime::AsContext>::Data: Send,
883+
<S as wasmtime::AsContext>::Data: Send + 'static,
887884
{
888885
let callee = unsafe {
889886
wasmtime::component::TypedFunc::<

crates/component-macro/tests/expanded/conventions_tracing_async.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<T> Clone for TheWorldPre<T> {
1818
}
1919
}
2020
}
21-
impl<_T> TheWorldPre<_T> {
21+
impl<_T: Send + 'static> TheWorldPre<_T> {
2222
/// Creates a new copy of `TheWorldPre` bindings which can then
2323
/// be used to instantiate into a particular store.
2424
///
@@ -46,10 +46,7 @@ impl<_T> TheWorldPre<_T> {
4646
pub async fn instantiate_async(
4747
&self,
4848
mut store: impl wasmtime::AsContextMut<Data = _T>,
49-
) -> wasmtime::Result<TheWorld>
50-
where
51-
_T: Send,
52-
{
49+
) -> wasmtime::Result<TheWorld> {
5350
let mut store = store.as_context_mut();
5451
let instance = self.instance_pre.instantiate_async(&mut store).await?;
5552
self.indices.load(&mut store, &instance)
@@ -159,7 +156,7 @@ const _: () = {
159156
linker: &wasmtime::component::Linker<_T>,
160157
) -> wasmtime::Result<TheWorld>
161158
where
162-
_T: Send,
159+
_T: Send + 'static,
163160
{
164161
let pre = linker.instantiate_pre(component)?;
165162
TheWorldPre::new(pre)?.instantiate_async(store).await
@@ -848,7 +845,7 @@ pub mod exports {
848845
mut store: S,
849846
) -> wasmtime::Result<()>
850847
where
851-
<S as wasmtime::AsContext>::Data: Send,
848+
<S as wasmtime::AsContext>::Data: Send + 'static,
852849
{
853850
use tracing::Instrument;
854851
let span = tracing::span!(
@@ -877,7 +874,7 @@ pub mod exports {
877874
arg0: LudicrousSpeed,
878875
) -> wasmtime::Result<()>
879876
where
880-
<S as wasmtime::AsContext>::Data: Send,
877+
<S as wasmtime::AsContext>::Data: Send + 'static,
881878
{
882879
use tracing::Instrument;
883880
let span = tracing::span!(
@@ -905,7 +902,7 @@ pub mod exports {
905902
mut store: S,
906903
) -> wasmtime::Result<()>
907904
where
908-
<S as wasmtime::AsContext>::Data: Send,
905+
<S as wasmtime::AsContext>::Data: Send + 'static,
909906
{
910907
use tracing::Instrument;
911908
let span = tracing::span!(
@@ -932,7 +929,7 @@ pub mod exports {
932929
S: wasmtime::AsContextMut,
933930
>(&self, mut store: S) -> wasmtime::Result<()>
934931
where
935-
<S as wasmtime::AsContext>::Data: Send,
932+
<S as wasmtime::AsContext>::Data: Send + 'static,
936933
{
937934
use tracing::Instrument;
938935
let span = tracing::span!(
@@ -961,7 +958,7 @@ pub mod exports {
961958
mut store: S,
962959
) -> wasmtime::Result<()>
963960
where
964-
<S as wasmtime::AsContext>::Data: Send,
961+
<S as wasmtime::AsContext>::Data: Send + 'static,
965962
{
966963
use tracing::Instrument;
967964
let span = tracing::span!(
@@ -989,7 +986,7 @@ pub mod exports {
989986
mut store: S,
990987
) -> wasmtime::Result<()>
991988
where
992-
<S as wasmtime::AsContext>::Data: Send,
989+
<S as wasmtime::AsContext>::Data: Send + 'static,
993990
{
994991
use tracing::Instrument;
995992
let span = tracing::span!(
@@ -1017,7 +1014,7 @@ pub mod exports {
10171014
mut store: S,
10181015
) -> wasmtime::Result<()>
10191016
where
1020-
<S as wasmtime::AsContext>::Data: Send,
1017+
<S as wasmtime::AsContext>::Data: Send + 'static,
10211018
{
10221019
use tracing::Instrument;
10231020
let span = tracing::span!(
@@ -1045,7 +1042,7 @@ pub mod exports {
10451042
mut store: S,
10461043
) -> wasmtime::Result<()>
10471044
where
1048-
<S as wasmtime::AsContext>::Data: Send,
1045+
<S as wasmtime::AsContext>::Data: Send + 'static,
10491046
{
10501047
use tracing::Instrument;
10511048
let span = tracing::span!(
@@ -1078,7 +1075,7 @@ pub mod exports {
10781075
mut store: S,
10791076
) -> wasmtime::Result<()>
10801077
where
1081-
<S as wasmtime::AsContext>::Data: Send,
1078+
<S as wasmtime::AsContext>::Data: Send + 'static,
10821079
{
10831080
use tracing::Instrument;
10841081
let span = tracing::span!(
@@ -1106,7 +1103,7 @@ pub mod exports {
11061103
mut store: S,
11071104
) -> wasmtime::Result<()>
11081105
where
1109-
<S as wasmtime::AsContext>::Data: Send,
1106+
<S as wasmtime::AsContext>::Data: Send + 'static,
11101107
{
11111108
use tracing::Instrument;
11121109
let span = tracing::span!(
@@ -1134,7 +1131,7 @@ pub mod exports {
11341131
mut store: S,
11351132
) -> wasmtime::Result<()>
11361133
where
1137-
<S as wasmtime::AsContext>::Data: Send,
1134+
<S as wasmtime::AsContext>::Data: Send + 'static,
11381135
{
11391136
use tracing::Instrument;
11401137
let span = tracing::span!(
@@ -1163,7 +1160,7 @@ pub mod exports {
11631160
mut store: S,
11641161
) -> wasmtime::Result<()>
11651162
where
1166-
<S as wasmtime::AsContext>::Data: Send,
1163+
<S as wasmtime::AsContext>::Data: Send + 'static,
11671164
{
11681165
use tracing::Instrument;
11691166
let span = tracing::span!(

crates/component-macro/tests/expanded/dead-code.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<T> Clone for ImportsPre<T> {
1818
}
1919
}
2020
}
21-
impl<_T> ImportsPre<_T> {
21+
impl<_T: 'static> ImportsPre<_T> {
2222
/// Creates a new copy of `ImportsPre` bindings which can then
2323
/// be used to instantiate into a particular store.
2424
///
@@ -142,7 +142,10 @@ const _: () = {
142142
mut store: impl wasmtime::AsContextMut<Data = _T>,
143143
component: &wasmtime::component::Component,
144144
linker: &wasmtime::component::Linker<_T>,
145-
) -> wasmtime::Result<Imports> {
145+
) -> wasmtime::Result<Imports>
146+
where
147+
_T: 'static,
148+
{
146149
let pre = linker.instantiate_pre(component)?;
147150
ImportsPre::new(pre)?.instantiate(store)
148151
}

0 commit comments

Comments
 (0)