diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml index 9e4fc214e1..9596d04419 100644 --- a/.github/actions/install-rust/action.yml +++ b/.github/actions/install-rust/action.yml @@ -9,7 +9,7 @@ inputs: msrv_range: description: 'Versions later-than-latest-Rust the MSRV supports' required: false - default: '2' + default: '1' runs: using: composite diff --git a/Cargo.toml b/Cargo.toml index d6272395ff..bc9923e9a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,7 +176,7 @@ authors = ["The Wasmtime Project Developers"] edition = "2021" # Wasmtime's current policy is that this number can be no larger than the # current stable release of Rust minus 2. -rust-version = "1.84.0" +rust-version = "1.85.0" [workspace.lints.rust] # Turn on some lints which are otherwise allow-by-default in rustc. diff --git a/benches/call.rs b/benches/call.rs index 03967f0e45..f9ba1bb7c0 100644 --- a/benches/call.rs +++ b/benches/call.rs @@ -360,7 +360,7 @@ fn wasm_to_host(c: &mut Criterion) { return; } - let mut typed = Linker::new(&engine); + let mut typed = Linker::<()>::new(&engine); typed .func_wrap_async("", "nop", |caller, _: ()| { Box::new(async { diff --git a/ci/build-test-matrix.js b/ci/build-test-matrix.js index 803a537b42..9f19a9a1ac 100644 --- a/ci/build-test-matrix.js +++ b/ci/build-test-matrix.js @@ -95,12 +95,14 @@ const FULL_MATRIX = [ "name": "Test Windows MSVC x86_64", "filter": "windows-x64", }, - { - "os": windows, - "target": "x86_64-pc-windows-gnu", - "name": "Test Windows MinGW x86_64", - "filter": "mingw-x64" - }, + // FIXME: As of this writing, some of the GitHub images have a broken MinGW, + // leading CI to fail nondeterministically. + // { + // "os": windows, + // "target": "x86_64-pc-windows-gnu", + // "name": "Test Windows MinGW x86_64", + // "filter": "mingw-x64" + // }, { "os": ubuntu + '-arm', "target": "aarch64-unknown-linux-gnu", diff --git a/crates/component-macro/tests/expanded/char.rs b/crates/component-macro/tests/expanded/char.rs index d40cb79492..945412bcfa 100644 --- a/crates/component-macro/tests/expanded/char.rs +++ b/crates/component-macro/tests/expanded/char.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -300,7 +300,7 @@ pub mod exports { arg0: char, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -318,7 +318,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/char_async.rs b/crates/component-macro/tests/expanded/char_async.rs index dde5e30a29..d0d7902e95 100644 --- a/crates/component-macro/tests/expanded/char_async.rs +++ b/crates/component-macro/tests/expanded/char_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -311,7 +311,7 @@ pub mod exports { arg0: char, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -331,7 +331,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/char_concurrent.rs b/crates/component-macro/tests/expanded/char_concurrent.rs index 6fd772530f..eae01b1b63 100644 --- a/crates/component-macro/tests/expanded/char_concurrent.rs +++ b/crates/component-macro/tests/expanded/char_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -316,7 +316,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -334,7 +334,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/char_tracing_async.rs b/crates/component-macro/tests/expanded/char_tracing_async.rs index 069cc6f9b0..06269758a7 100644 --- a/crates/component-macro/tests/expanded/char_tracing_async.rs +++ b/crates/component-macro/tests/expanded/char_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -340,7 +340,7 @@ pub mod exports { arg0: char, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -369,7 +369,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/conventions.rs b/crates/component-macro/tests/expanded/conventions.rs index ba3ebe52d7..a2935ed962 100644 --- a/crates/component-macro/tests/expanded/conventions.rs +++ b/crates/component-macro/tests/expanded/conventions.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -592,7 +592,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -610,7 +610,7 @@ pub mod exports { arg0: LudicrousSpeed, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -627,7 +627,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -643,7 +643,7 @@ pub mod exports { S: wasmtime::AsContextMut, >(&self, mut store: S) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -660,7 +660,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -677,7 +677,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -694,7 +694,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -711,7 +711,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -733,7 +733,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -750,7 +750,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -767,7 +767,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -785,7 +785,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/conventions_async.rs b/crates/component-macro/tests/expanded/conventions_async.rs index 1816bc13f9..514471ed78 100644 --- a/crates/component-macro/tests/expanded/conventions_async.rs +++ b/crates/component-macro/tests/expanded/conventions_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -623,7 +623,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -641,7 +641,7 @@ pub mod exports { arg0: LudicrousSpeed, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -660,7 +660,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -676,7 +676,7 @@ pub mod exports { S: wasmtime::AsContextMut, >(&self, mut store: S) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -693,7 +693,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -710,7 +710,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -727,7 +727,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -744,7 +744,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -766,7 +766,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -783,7 +783,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -800,7 +800,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -818,7 +818,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/conventions_concurrent.rs b/crates/component-macro/tests/expanded/conventions_concurrent.rs index 0c85d5303a..a686f6679e 100644 --- a/crates/component-macro/tests/expanded/conventions_concurrent.rs +++ b/crates/component-macro/tests/expanded/conventions_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -639,7 +639,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -657,7 +657,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -674,7 +674,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -693,7 +693,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -710,7 +710,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -727,7 +727,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -744,7 +744,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -761,7 +761,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -783,7 +783,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -800,7 +800,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -817,7 +817,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -835,7 +835,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/conventions_tracing_async.rs b/crates/component-macro/tests/expanded/conventions_tracing_async.rs index 2e6fa82d4e..850f47b933 100644 --- a/crates/component-macro/tests/expanded/conventions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/conventions_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -783,7 +783,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -812,7 +812,7 @@ pub mod exports { arg0: LudicrousSpeed, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -840,7 +840,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -867,7 +867,7 @@ pub mod exports { S: wasmtime::AsContextMut, >(&self, mut store: S) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -896,7 +896,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -924,7 +924,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -952,7 +952,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -980,7 +980,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1013,7 +1013,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1041,7 +1041,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1069,7 +1069,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1098,7 +1098,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/dead-code.rs b/crates/component-macro/tests/expanded/dead-code.rs index c63e341ede..c0ada91415 100644 --- a/crates/component-macro/tests/expanded/dead-code.rs +++ b/crates/component-macro/tests/expanded/dead-code.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Imports`] as well. -pub struct ImportsPre { +pub struct ImportsPre { instance_pre: wasmtime::component::InstancePre, indices: ImportsIndices, } -impl Clone for ImportsPre { +impl Clone for ImportsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ImportsPre { } } } -impl<_T> ImportsPre<_T> { +impl<_T: 'static> ImportsPre<_T> { /// Creates a new copy of `ImportsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Imports { /// Convenience wrapper around [`ImportsPre::new`] and /// [`ImportsPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/dead-code_async.rs b/crates/component-macro/tests/expanded/dead-code_async.rs index 2ef38c8335..d08ae6c358 100644 --- a/crates/component-macro/tests/expanded/dead-code_async.rs +++ b/crates/component-macro/tests/expanded/dead-code_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Imports`] as well. -pub struct ImportsPre { +pub struct ImportsPre { instance_pre: wasmtime::component::InstancePre, indices: ImportsIndices, } -impl Clone for ImportsPre { +impl Clone for ImportsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ImportsPre { } } } -impl<_T> ImportsPre<_T> { +impl<_T: 'static> ImportsPre<_T> { /// Creates a new copy of `ImportsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Imports { /// Convenience wrapper around [`ImportsPre::new`] and /// [`ImportsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/dead-code_concurrent.rs b/crates/component-macro/tests/expanded/dead-code_concurrent.rs index 51dba89d63..13d54676e1 100644 --- a/crates/component-macro/tests/expanded/dead-code_concurrent.rs +++ b/crates/component-macro/tests/expanded/dead-code_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Imports`] as well. -pub struct ImportsPre { +pub struct ImportsPre { instance_pre: wasmtime::component::InstancePre, indices: ImportsIndices, } -impl Clone for ImportsPre { +impl Clone for ImportsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ImportsPre { } } } -impl<_T> ImportsPre<_T> { +impl<_T: 'static> ImportsPre<_T> { /// Creates a new copy of `ImportsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Imports { /// Convenience wrapper around [`ImportsPre::new`] and /// [`ImportsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/dead-code_tracing_async.rs b/crates/component-macro/tests/expanded/dead-code_tracing_async.rs index 80f8f34692..ce07851376 100644 --- a/crates/component-macro/tests/expanded/dead-code_tracing_async.rs +++ b/crates/component-macro/tests/expanded/dead-code_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Imports`] as well. -pub struct ImportsPre { +pub struct ImportsPre { instance_pre: wasmtime::component::InstancePre, indices: ImportsIndices, } -impl Clone for ImportsPre { +impl Clone for ImportsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ImportsPre { } } } -impl<_T> ImportsPre<_T> { +impl<_T: 'static> ImportsPre<_T> { /// Creates a new copy of `ImportsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Imports { /// Convenience wrapper around [`ImportsPre::new`] and /// [`ImportsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/direct-import.rs b/crates/component-macro/tests/expanded/direct-import.rs index 8382c5827d..aa6d3c9214 100644 --- a/crates/component-macro/tests/expanded/direct-import.rs +++ b/crates/component-macro/tests/expanded/direct-import.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/direct-import_async.rs b/crates/component-macro/tests/expanded/direct-import_async.rs index 0b693fc8d2..bd0aefd2a4 100644 --- a/crates/component-macro/tests/expanded/direct-import_async.rs +++ b/crates/component-macro/tests/expanded/direct-import_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -134,7 +134,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/direct-import_concurrent.rs b/crates/component-macro/tests/expanded/direct-import_concurrent.rs index b91de77837..f2c72e3343 100644 --- a/crates/component-macro/tests/expanded/direct-import_concurrent.rs +++ b/crates/component-macro/tests/expanded/direct-import_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -136,7 +136,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/direct-import_tracing_async.rs b/crates/component-macro/tests/expanded/direct-import_tracing_async.rs index f75f0635ec..38ef543771 100644 --- a/crates/component-macro/tests/expanded/direct-import_tracing_async.rs +++ b/crates/component-macro/tests/expanded/direct-import_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -134,7 +134,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/empty.rs b/crates/component-macro/tests/expanded/empty.rs index 51705a4d88..a22ec54f9f 100644 --- a/crates/component-macro/tests/expanded/empty.rs +++ b/crates/component-macro/tests/expanded/empty.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Empty`] as well. -pub struct EmptyPre { +pub struct EmptyPre { instance_pre: wasmtime::component::InstancePre, indices: EmptyIndices, } -impl Clone for EmptyPre { +impl Clone for EmptyPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for EmptyPre { } } } -impl<_T> EmptyPre<_T> { +impl<_T: 'static> EmptyPre<_T> { /// Creates a new copy of `EmptyPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Empty { /// Convenience wrapper around [`EmptyPre::new`] and /// [`EmptyPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/empty_async.rs b/crates/component-macro/tests/expanded/empty_async.rs index 392e9f0c13..5bdd9a700e 100644 --- a/crates/component-macro/tests/expanded/empty_async.rs +++ b/crates/component-macro/tests/expanded/empty_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Empty`] as well. -pub struct EmptyPre { +pub struct EmptyPre { instance_pre: wasmtime::component::InstancePre, indices: EmptyIndices, } -impl Clone for EmptyPre { +impl Clone for EmptyPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for EmptyPre { } } } -impl<_T> EmptyPre<_T> { +impl<_T: 'static> EmptyPre<_T> { /// Creates a new copy of `EmptyPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Empty { /// Convenience wrapper around [`EmptyPre::new`] and /// [`EmptyPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/empty_concurrent.rs b/crates/component-macro/tests/expanded/empty_concurrent.rs index 392e9f0c13..5bdd9a700e 100644 --- a/crates/component-macro/tests/expanded/empty_concurrent.rs +++ b/crates/component-macro/tests/expanded/empty_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Empty`] as well. -pub struct EmptyPre { +pub struct EmptyPre { instance_pre: wasmtime::component::InstancePre, indices: EmptyIndices, } -impl Clone for EmptyPre { +impl Clone for EmptyPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for EmptyPre { } } } -impl<_T> EmptyPre<_T> { +impl<_T: 'static> EmptyPre<_T> { /// Creates a new copy of `EmptyPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Empty { /// Convenience wrapper around [`EmptyPre::new`] and /// [`EmptyPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/empty_tracing_async.rs b/crates/component-macro/tests/expanded/empty_tracing_async.rs index 392e9f0c13..5bdd9a700e 100644 --- a/crates/component-macro/tests/expanded/empty_tracing_async.rs +++ b/crates/component-macro/tests/expanded/empty_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Empty`] as well. -pub struct EmptyPre { +pub struct EmptyPre { instance_pre: wasmtime::component::InstancePre, indices: EmptyIndices, } -impl Clone for EmptyPre { +impl Clone for EmptyPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for EmptyPre { } } } -impl<_T> EmptyPre<_T> { +impl<_T: 'static> EmptyPre<_T> { /// Creates a new copy of `EmptyPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Empty { /// Convenience wrapper around [`EmptyPre::new`] and /// [`EmptyPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/flags.rs b/crates/component-macro/tests/expanded/flags.rs index 262428047e..4648b02733 100644 --- a/crates/component-macro/tests/expanded/flags.rs +++ b/crates/component-macro/tests/expanded/flags.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheFlags`] as well. -pub struct TheFlagsPre { +pub struct TheFlagsPre { instance_pre: wasmtime::component::InstancePre, indices: TheFlagsIndices, } -impl Clone for TheFlagsPre { +impl Clone for TheFlagsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheFlagsPre { } } } -impl<_T> TheFlagsPre<_T> { +impl<_T: 'static> TheFlagsPre<_T> { /// Creates a new copy of `TheFlagsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl TheFlags { /// Convenience wrapper around [`TheFlagsPre::new`] and /// [`TheFlagsPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -697,7 +697,7 @@ pub mod exports { arg0: Flag1, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -715,7 +715,7 @@ pub mod exports { arg0: Flag2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -733,7 +733,7 @@ pub mod exports { arg0: Flag4, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -751,7 +751,7 @@ pub mod exports { arg0: Flag8, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -769,7 +769,7 @@ pub mod exports { arg0: Flag16, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -787,7 +787,7 @@ pub mod exports { arg0: Flag32, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -805,7 +805,7 @@ pub mod exports { arg0: Flag64, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/flags_async.rs b/crates/component-macro/tests/expanded/flags_async.rs index bab3200118..d6f33f83f0 100644 --- a/crates/component-macro/tests/expanded/flags_async.rs +++ b/crates/component-macro/tests/expanded/flags_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheFlags`] as well. -pub struct TheFlagsPre { +pub struct TheFlagsPre { instance_pre: wasmtime::component::InstancePre, indices: TheFlagsIndices, } -impl Clone for TheFlagsPre { +impl Clone for TheFlagsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheFlagsPre { } } } -impl<_T> TheFlagsPre<_T> { +impl<_T: 'static> TheFlagsPre<_T> { /// Creates a new copy of `TheFlagsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheFlags { /// Convenience wrapper around [`TheFlagsPre::new`] and /// [`TheFlagsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -718,7 +718,7 @@ pub mod exports { arg0: Flag1, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -738,7 +738,7 @@ pub mod exports { arg0: Flag2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -758,7 +758,7 @@ pub mod exports { arg0: Flag4, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -778,7 +778,7 @@ pub mod exports { arg0: Flag8, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -798,7 +798,7 @@ pub mod exports { arg0: Flag16, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -818,7 +818,7 @@ pub mod exports { arg0: Flag32, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -838,7 +838,7 @@ pub mod exports { arg0: Flag64, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/flags_concurrent.rs b/crates/component-macro/tests/expanded/flags_concurrent.rs index 154b826d39..561baea730 100644 --- a/crates/component-macro/tests/expanded/flags_concurrent.rs +++ b/crates/component-macro/tests/expanded/flags_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheFlags`] as well. -pub struct TheFlagsPre { +pub struct TheFlagsPre { instance_pre: wasmtime::component::InstancePre, indices: TheFlagsIndices, } -impl Clone for TheFlagsPre { +impl Clone for TheFlagsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheFlagsPre { } } } -impl<_T> TheFlagsPre<_T> { +impl<_T: 'static> TheFlagsPre<_T> { /// Creates a new copy of `TheFlagsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheFlags { /// Convenience wrapper around [`TheFlagsPre::new`] and /// [`TheFlagsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -763,7 +763,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -784,7 +784,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -805,7 +805,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -826,7 +826,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -847,7 +847,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -868,7 +868,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -889,7 +889,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/flags_tracing_async.rs b/crates/component-macro/tests/expanded/flags_tracing_async.rs index ba0d750068..36cae08d6f 100644 --- a/crates/component-macro/tests/expanded/flags_tracing_async.rs +++ b/crates/component-macro/tests/expanded/flags_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheFlags`] as well. -pub struct TheFlagsPre { +pub struct TheFlagsPre { instance_pre: wasmtime::component::InstancePre, indices: TheFlagsIndices, } -impl Clone for TheFlagsPre { +impl Clone for TheFlagsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheFlagsPre { } } } -impl<_T> TheFlagsPre<_T> { +impl<_T: 'static> TheFlagsPre<_T> { /// Creates a new copy of `TheFlagsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheFlags { /// Convenience wrapper around [`TheFlagsPre::new`] and /// [`TheFlagsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -830,7 +830,7 @@ pub mod exports { arg0: Flag1, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -859,7 +859,7 @@ pub mod exports { arg0: Flag2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -888,7 +888,7 @@ pub mod exports { arg0: Flag4, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -917,7 +917,7 @@ pub mod exports { arg0: Flag8, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -946,7 +946,7 @@ pub mod exports { arg0: Flag16, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -975,7 +975,7 @@ pub mod exports { arg0: Flag32, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1004,7 +1004,7 @@ pub mod exports { arg0: Flag64, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/floats.rs b/crates/component-macro/tests/expanded/floats.rs index 221b783344..aef4f36de0 100644 --- a/crates/component-macro/tests/expanded/floats.rs +++ b/crates/component-macro/tests/expanded/floats.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -334,7 +334,7 @@ pub mod exports { arg0: f32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -352,7 +352,7 @@ pub mod exports { arg0: f64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -369,7 +369,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -386,7 +386,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/floats_async.rs b/crates/component-macro/tests/expanded/floats_async.rs index 5daaad5583..ec0a77974c 100644 --- a/crates/component-macro/tests/expanded/floats_async.rs +++ b/crates/component-macro/tests/expanded/floats_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -349,7 +349,7 @@ pub mod exports { arg0: f32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -369,7 +369,7 @@ pub mod exports { arg0: f64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -388,7 +388,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -407,7 +407,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/floats_concurrent.rs b/crates/component-macro/tests/expanded/floats_concurrent.rs index ee04280787..1af918d17b 100644 --- a/crates/component-macro/tests/expanded/floats_concurrent.rs +++ b/crates/component-macro/tests/expanded/floats_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -366,7 +366,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -384,7 +384,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -401,7 +401,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -421,7 +421,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/floats_tracing_async.rs b/crates/component-macro/tests/expanded/floats_tracing_async.rs index 0a145ec5d7..faba1e11f2 100644 --- a/crates/component-macro/tests/expanded/floats_tracing_async.rs +++ b/crates/component-macro/tests/expanded/floats_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -407,7 +407,7 @@ pub mod exports { arg0: f32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -436,7 +436,7 @@ pub mod exports { arg0: f64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -464,7 +464,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -492,7 +492,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/function-new.rs b/crates/component-macro/tests/expanded/function-new.rs index 235eab4b3e..a56ab011ce 100644 --- a/crates/component-macro/tests/expanded/function-new.rs +++ b/crates/component-macro/tests/expanded/function-new.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -141,7 +141,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -163,7 +163,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.new) diff --git a/crates/component-macro/tests/expanded/function-new_async.rs b/crates/component-macro/tests/expanded/function-new_async.rs index a954ac63a8..47967b6524 100644 --- a/crates/component-macro/tests/expanded/function-new_async.rs +++ b/crates/component-macro/tests/expanded/function-new_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -169,7 +169,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.new) diff --git a/crates/component-macro/tests/expanded/function-new_concurrent.rs b/crates/component-macro/tests/expanded/function-new_concurrent.rs index 43dd508ace..b873f5ceba 100644 --- a/crates/component-macro/tests/expanded/function-new_concurrent.rs +++ b/crates/component-macro/tests/expanded/function-new_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -171,7 +171,7 @@ const _: () = { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.new) diff --git a/crates/component-macro/tests/expanded/function-new_tracing_async.rs b/crates/component-macro/tests/expanded/function-new_tracing_async.rs index 08ec1ad534..c5a352e4c7 100644 --- a/crates/component-macro/tests/expanded/function-new_tracing_async.rs +++ b/crates/component-macro/tests/expanded/function-new_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -169,7 +169,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/host-world.rs b/crates/component-macro/tests/expanded/host-world.rs index 8dc41c964e..116ecdcd62 100644 --- a/crates/component-macro/tests/expanded/host-world.rs +++ b/crates/component-macro/tests/expanded/host-world.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Host_`] as well. -pub struct Host_Pre { +pub struct Host_Pre { instance_pre: wasmtime::component::InstancePre, indices: Host_Indices, } -impl Clone for Host_Pre { +impl Clone for Host_Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Host_Pre { } } } -impl<_T> Host_Pre<_T> { +impl<_T: 'static> Host_Pre<_T> { /// Creates a new copy of `Host_Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl Host_ { /// Convenience wrapper around [`Host_Pre::new`] and /// [`Host_Pre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/host-world_async.rs b/crates/component-macro/tests/expanded/host-world_async.rs index f5bb26f161..df2bf79f65 100644 --- a/crates/component-macro/tests/expanded/host-world_async.rs +++ b/crates/component-macro/tests/expanded/host-world_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Host_`] as well. -pub struct Host_Pre { +pub struct Host_Pre { instance_pre: wasmtime::component::InstancePre, indices: Host_Indices, } -impl Clone for Host_Pre { +impl Clone for Host_Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Host_Pre { } } } -impl<_T> Host_Pre<_T> { +impl<_T: 'static> Host_Pre<_T> { /// Creates a new copy of `Host_Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -134,7 +134,7 @@ const _: () = { impl Host_ { /// Convenience wrapper around [`Host_Pre::new`] and /// [`Host_Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/host-world_concurrent.rs b/crates/component-macro/tests/expanded/host-world_concurrent.rs index 399eceeef1..92dad7e101 100644 --- a/crates/component-macro/tests/expanded/host-world_concurrent.rs +++ b/crates/component-macro/tests/expanded/host-world_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Host_`] as well. -pub struct Host_Pre { +pub struct Host_Pre { instance_pre: wasmtime::component::InstancePre, indices: Host_Indices, } -impl Clone for Host_Pre { +impl Clone for Host_Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Host_Pre { } } } -impl<_T> Host_Pre<_T> { +impl<_T: 'static> Host_Pre<_T> { /// Creates a new copy of `Host_Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -136,7 +136,7 @@ const _: () = { impl Host_ { /// Convenience wrapper around [`Host_Pre::new`] and /// [`Host_Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/host-world_tracing_async.rs b/crates/component-macro/tests/expanded/host-world_tracing_async.rs index 7bdd987c39..52adb6ef9b 100644 --- a/crates/component-macro/tests/expanded/host-world_tracing_async.rs +++ b/crates/component-macro/tests/expanded/host-world_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Host_`] as well. -pub struct Host_Pre { +pub struct Host_Pre { instance_pre: wasmtime::component::InstancePre, indices: Host_Indices, } -impl Clone for Host_Pre { +impl Clone for Host_Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Host_Pre { } } } -impl<_T> Host_Pre<_T> { +impl<_T: 'static> Host_Pre<_T> { /// Creates a new copy of `Host_Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -134,7 +134,7 @@ const _: () = { impl Host_ { /// Convenience wrapper around [`Host_Pre::new`] and /// [`Host_Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/integers.rs b/crates/component-macro/tests/expanded/integers.rs index 9aa4f0e962..9a242d24cb 100644 --- a/crates/component-macro/tests/expanded/integers.rs +++ b/crates/component-macro/tests/expanded/integers.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -662,7 +662,7 @@ pub mod exports { arg0: u8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -680,7 +680,7 @@ pub mod exports { arg0: i8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -698,7 +698,7 @@ pub mod exports { arg0: u16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -716,7 +716,7 @@ pub mod exports { arg0: i16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -734,7 +734,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -752,7 +752,7 @@ pub mod exports { arg0: i32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -770,7 +770,7 @@ pub mod exports { arg0: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -788,7 +788,7 @@ pub mod exports { arg0: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -813,7 +813,7 @@ pub mod exports { arg7: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -834,7 +834,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -851,7 +851,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -868,7 +868,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -885,7 +885,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -902,7 +902,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -919,7 +919,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -936,7 +936,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -953,7 +953,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -970,7 +970,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(i64, u8)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/integers_async.rs b/crates/component-macro/tests/expanded/integers_async.rs index 92663bd9a3..aca8713cef 100644 --- a/crates/component-macro/tests/expanded/integers_async.rs +++ b/crates/component-macro/tests/expanded/integers_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -706,7 +706,7 @@ pub mod exports { arg0: u8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -726,7 +726,7 @@ pub mod exports { arg0: i8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -746,7 +746,7 @@ pub mod exports { arg0: u16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -766,7 +766,7 @@ pub mod exports { arg0: i16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -786,7 +786,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -806,7 +806,7 @@ pub mod exports { arg0: i32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -826,7 +826,7 @@ pub mod exports { arg0: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -846,7 +846,7 @@ pub mod exports { arg0: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -873,7 +873,7 @@ pub mod exports { arg7: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -895,7 +895,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -914,7 +914,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -933,7 +933,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -952,7 +952,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -971,7 +971,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -990,7 +990,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1009,7 +1009,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1028,7 +1028,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1047,7 +1047,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(i64, u8)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/integers_concurrent.rs b/crates/component-macro/tests/expanded/integers_concurrent.rs index 41e78f38d9..8e2eaf4250 100644 --- a/crates/component-macro/tests/expanded/integers_concurrent.rs +++ b/crates/component-macro/tests/expanded/integers_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -741,7 +741,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -759,7 +759,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -777,7 +777,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -795,7 +795,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -813,7 +813,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -831,7 +831,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -849,7 +849,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -867,7 +867,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -892,7 +892,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -913,7 +913,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -933,7 +933,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -953,7 +953,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -973,7 +973,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -993,7 +993,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1013,7 +1013,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1033,7 +1033,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1053,7 +1053,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1073,7 +1073,7 @@ pub mod exports { Output = wasmtime::Result<(i64, u8)>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/integers_tracing_async.rs b/crates/component-macro/tests/expanded/integers_tracing_async.rs index 60ccd044e8..effa35b1ee 100644 --- a/crates/component-macro/tests/expanded/integers_tracing_async.rs +++ b/crates/component-macro/tests/expanded/integers_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -971,7 +971,7 @@ pub mod exports { arg0: u8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1000,7 +1000,7 @@ pub mod exports { arg0: i8, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1029,7 +1029,7 @@ pub mod exports { arg0: u16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1058,7 +1058,7 @@ pub mod exports { arg0: i16, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1087,7 +1087,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1116,7 +1116,7 @@ pub mod exports { arg0: i32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1145,7 +1145,7 @@ pub mod exports { arg0: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1174,7 +1174,7 @@ pub mod exports { arg0: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1210,7 +1210,7 @@ pub mod exports { arg7: i64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1241,7 +1241,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1269,7 +1269,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1297,7 +1297,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1325,7 +1325,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1353,7 +1353,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1381,7 +1381,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1409,7 +1409,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1437,7 +1437,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1465,7 +1465,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(i64, u8)> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/lists.rs b/crates/component-macro/tests/expanded/lists.rs index acc67b7839..c6d92c4809 100644 --- a/crates/component-macro/tests/expanded/lists.rs +++ b/crates/component-macro/tests/expanded/lists.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheLists`] as well. -pub struct TheListsPre { +pub struct TheListsPre { instance_pre: wasmtime::component::InstancePre, indices: TheListsIndices, } -impl Clone for TheListsPre { +impl Clone for TheListsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheListsPre { } } } -impl<_T> TheListsPre<_T> { +impl<_T: 'static> TheListsPre<_T> { /// Creates a new copy of `TheListsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl TheLists { /// Convenience wrapper around [`TheListsPre::new`] and /// [`TheListsPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1519,7 +1519,7 @@ pub mod exports { arg0: &[u8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1537,7 +1537,7 @@ pub mod exports { arg0: &[u16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1555,7 +1555,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1573,7 +1573,7 @@ pub mod exports { arg0: &[u64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1591,7 +1591,7 @@ pub mod exports { arg0: &[i8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1609,7 +1609,7 @@ pub mod exports { arg0: &[i16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1627,7 +1627,7 @@ pub mod exports { arg0: &[i32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1645,7 +1645,7 @@ pub mod exports { arg0: &[i64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1663,7 +1663,7 @@ pub mod exports { arg0: &[f32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1681,7 +1681,7 @@ pub mod exports { arg0: &[f64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1698,7 +1698,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1715,7 +1715,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1732,7 +1732,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1749,7 +1749,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1766,7 +1766,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1783,7 +1783,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1800,7 +1800,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1817,7 +1817,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1834,7 +1834,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1851,7 +1851,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1871,7 +1871,7 @@ pub mod exports { wasmtime::component::__internal::Vec<(i64, u32)>, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1889,7 +1889,7 @@ pub mod exports { arg0: &[wasmtime::component::__internal::String], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1910,7 +1910,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1936,7 +1936,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1962,7 +1962,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1986,7 +1986,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2006,7 +2006,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2026,7 +2026,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2044,7 +2044,7 @@ pub mod exports { arg0: &LoadStoreAllSizes, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/lists_async.rs b/crates/component-macro/tests/expanded/lists_async.rs index 25d6df6c92..89600d6735 100644 --- a/crates/component-macro/tests/expanded/lists_async.rs +++ b/crates/component-macro/tests/expanded/lists_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheLists`] as well. -pub struct TheListsPre { +pub struct TheListsPre { instance_pre: wasmtime::component::InstancePre, indices: TheListsIndices, } -impl Clone for TheListsPre { +impl Clone for TheListsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheListsPre { } } } -impl<_T> TheListsPre<_T> { +impl<_T: 'static> TheListsPre<_T> { /// Creates a new copy of `TheListsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheLists { /// Convenience wrapper around [`TheListsPre::new`] and /// [`TheListsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1624,7 +1624,7 @@ pub mod exports { arg0: &[u8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1644,7 +1644,7 @@ pub mod exports { arg0: &[u16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1664,7 +1664,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1684,7 +1684,7 @@ pub mod exports { arg0: &[u64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1704,7 +1704,7 @@ pub mod exports { arg0: &[i8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1724,7 +1724,7 @@ pub mod exports { arg0: &[i16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1744,7 +1744,7 @@ pub mod exports { arg0: &[i32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1764,7 +1764,7 @@ pub mod exports { arg0: &[i64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1784,7 +1784,7 @@ pub mod exports { arg0: &[f32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1804,7 +1804,7 @@ pub mod exports { arg0: &[f64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1823,7 +1823,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1842,7 +1842,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1861,7 +1861,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1880,7 +1880,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1899,7 +1899,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1918,7 +1918,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1937,7 +1937,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1956,7 +1956,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1975,7 +1975,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1994,7 +1994,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2016,7 +2016,7 @@ pub mod exports { wasmtime::component::__internal::Vec<(i64, u32)>, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2036,7 +2036,7 @@ pub mod exports { arg0: &[wasmtime::component::__internal::String], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2059,7 +2059,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2087,7 +2087,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2115,7 +2115,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2141,7 +2141,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2163,7 +2163,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2185,7 +2185,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2205,7 +2205,7 @@ pub mod exports { arg0: &LoadStoreAllSizes, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/lists_concurrent.rs b/crates/component-macro/tests/expanded/lists_concurrent.rs index 3e786dc727..bc868e586e 100644 --- a/crates/component-macro/tests/expanded/lists_concurrent.rs +++ b/crates/component-macro/tests/expanded/lists_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheLists`] as well. -pub struct TheListsPre { +pub struct TheListsPre { instance_pre: wasmtime::component::InstancePre, indices: TheListsIndices, } -impl Clone for TheListsPre { +impl Clone for TheListsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheListsPre { } } } -impl<_T> TheListsPre<_T> { +impl<_T: 'static> TheListsPre<_T> { /// Creates a new copy of `TheListsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheLists { /// Convenience wrapper around [`TheListsPre::new`] and /// [`TheListsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1575,7 +1575,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1593,7 +1593,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1611,7 +1611,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1629,7 +1629,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1647,7 +1647,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1665,7 +1665,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1683,7 +1683,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1701,7 +1701,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1719,7 +1719,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1737,7 +1737,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1756,7 +1756,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1778,7 +1778,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1800,7 +1800,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1822,7 +1822,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1844,7 +1844,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1866,7 +1866,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1888,7 +1888,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1910,7 +1910,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1932,7 +1932,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1954,7 +1954,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1977,7 +1977,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2000,7 +2000,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2025,7 +2025,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2056,7 +2056,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2091,7 +2091,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2122,7 +2122,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2145,7 +2145,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2168,7 +2168,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2189,7 +2189,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/lists_tracing_async.rs b/crates/component-macro/tests/expanded/lists_tracing_async.rs index 78a5857656..b6e1b2c763 100644 --- a/crates/component-macro/tests/expanded/lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/lists_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheLists`] as well. -pub struct TheListsPre { +pub struct TheListsPre { instance_pre: wasmtime::component::InstancePre, indices: TheListsIndices, } -impl Clone for TheListsPre { +impl Clone for TheListsPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheListsPre { } } } -impl<_T> TheListsPre<_T> { +impl<_T: 'static> TheListsPre<_T> { /// Creates a new copy of `TheListsPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheLists { /// Convenience wrapper around [`TheListsPre::new`] and /// [`TheListsPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -2055,7 +2055,7 @@ pub mod exports { arg0: &[u8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2084,7 +2084,7 @@ pub mod exports { arg0: &[u16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2113,7 +2113,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2142,7 +2142,7 @@ pub mod exports { arg0: &[u64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2171,7 +2171,7 @@ pub mod exports { arg0: &[i8], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2200,7 +2200,7 @@ pub mod exports { arg0: &[i16], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2229,7 +2229,7 @@ pub mod exports { arg0: &[i32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2258,7 +2258,7 @@ pub mod exports { arg0: &[i64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2287,7 +2287,7 @@ pub mod exports { arg0: &[f32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2316,7 +2316,7 @@ pub mod exports { arg0: &[f64], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2344,7 +2344,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2372,7 +2372,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2400,7 +2400,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2428,7 +2428,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2456,7 +2456,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2484,7 +2484,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2512,7 +2512,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2540,7 +2540,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2568,7 +2568,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2596,7 +2596,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2627,7 +2627,7 @@ pub mod exports { wasmtime::component::__internal::Vec<(i64, u32)>, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2656,7 +2656,7 @@ pub mod exports { arg0: &[wasmtime::component::__internal::String], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2688,7 +2688,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2725,7 +2725,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2762,7 +2762,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2797,7 +2797,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2828,7 +2828,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2859,7 +2859,7 @@ pub mod exports { wasmtime::component::__internal::Vec, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2888,7 +2888,7 @@ pub mod exports { arg0: &LoadStoreAllSizes, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/many-arguments.rs b/crates/component-macro/tests/expanded/many-arguments.rs index 8641179f7d..a2e618113d 100644 --- a/crates/component-macro/tests/expanded/many-arguments.rs +++ b/crates/component-macro/tests/expanded/many-arguments.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -607,7 +607,7 @@ pub mod exports { arg15: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -663,7 +663,7 @@ pub mod exports { arg0: &BigStruct, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/many-arguments_async.rs b/crates/component-macro/tests/expanded/many-arguments_async.rs index e057958d31..0f2683e9bd 100644 --- a/crates/component-macro/tests/expanded/many-arguments_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -620,7 +620,7 @@ pub mod exports { arg15: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -677,7 +677,7 @@ pub mod exports { arg0: &BigStruct, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs index 99e1326c08..80bf9abe4b 100644 --- a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs +++ b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -588,7 +588,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -644,7 +644,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs index 06488f156c..1c0c7d08a9 100644 --- a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -663,7 +663,7 @@ pub mod exports { arg15: u64, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -729,7 +729,7 @@ pub mod exports { arg0: &BigStruct, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/multiversion.rs b/crates/component-macro/tests/expanded/multiversion.rs index 45bd1a2a76..38d990ca8d 100644 --- a/crates/component-macro/tests/expanded/multiversion.rs +++ b/crates/component-macro/tests/expanded/multiversion.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -134,7 +134,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -313,7 +313,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -395,7 +395,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/multiversion_async.rs b/crates/component-macro/tests/expanded/multiversion_async.rs index 49d1b55918..7ed7f7e422 100644 --- a/crates/component-macro/tests/expanded/multiversion_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -137,7 +137,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -325,7 +325,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -407,7 +407,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/multiversion_concurrent.rs b/crates/component-macro/tests/expanded/multiversion_concurrent.rs index 1f782e569d..98d0ce72d5 100644 --- a/crates/component-macro/tests/expanded/multiversion_concurrent.rs +++ b/crates/component-macro/tests/expanded/multiversion_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -137,7 +137,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -331,7 +331,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -413,7 +413,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs index 2b27d66391..9a63323c43 100644 --- a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -137,7 +137,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -351,7 +351,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -444,7 +444,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/path1.rs b/crates/component-macro/tests/expanded/path1.rs index 26da408a37..e42e95f6cf 100644 --- a/crates/component-macro/tests/expanded/path1.rs +++ b/crates/component-macro/tests/expanded/path1.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path1`] as well. -pub struct Path1Pre { +pub struct Path1Pre { instance_pre: wasmtime::component::InstancePre, indices: Path1Indices, } -impl Clone for Path1Pre { +impl Clone for Path1Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path1Pre { } } } -impl<_T> Path1Pre<_T> { +impl<_T: 'static> Path1Pre<_T> { /// Creates a new copy of `Path1Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Path1 { /// Convenience wrapper around [`Path1Pre::new`] and /// [`Path1Pre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path1_async.rs b/crates/component-macro/tests/expanded/path1_async.rs index 7a1b0dc2bd..62ab40989c 100644 --- a/crates/component-macro/tests/expanded/path1_async.rs +++ b/crates/component-macro/tests/expanded/path1_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path1`] as well. -pub struct Path1Pre { +pub struct Path1Pre { instance_pre: wasmtime::component::InstancePre, indices: Path1Indices, } -impl Clone for Path1Pre { +impl Clone for Path1Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path1Pre { } } } -impl<_T> Path1Pre<_T> { +impl<_T: 'static> Path1Pre<_T> { /// Creates a new copy of `Path1Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path1 { /// Convenience wrapper around [`Path1Pre::new`] and /// [`Path1Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path1_concurrent.rs b/crates/component-macro/tests/expanded/path1_concurrent.rs index 7a1b0dc2bd..62ab40989c 100644 --- a/crates/component-macro/tests/expanded/path1_concurrent.rs +++ b/crates/component-macro/tests/expanded/path1_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path1`] as well. -pub struct Path1Pre { +pub struct Path1Pre { instance_pre: wasmtime::component::InstancePre, indices: Path1Indices, } -impl Clone for Path1Pre { +impl Clone for Path1Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path1Pre { } } } -impl<_T> Path1Pre<_T> { +impl<_T: 'static> Path1Pre<_T> { /// Creates a new copy of `Path1Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path1 { /// Convenience wrapper around [`Path1Pre::new`] and /// [`Path1Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path1_tracing_async.rs b/crates/component-macro/tests/expanded/path1_tracing_async.rs index 7a1b0dc2bd..62ab40989c 100644 --- a/crates/component-macro/tests/expanded/path1_tracing_async.rs +++ b/crates/component-macro/tests/expanded/path1_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path1`] as well. -pub struct Path1Pre { +pub struct Path1Pre { instance_pre: wasmtime::component::InstancePre, indices: Path1Indices, } -impl Clone for Path1Pre { +impl Clone for Path1Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path1Pre { } } } -impl<_T> Path1Pre<_T> { +impl<_T: 'static> Path1Pre<_T> { /// Creates a new copy of `Path1Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path1 { /// Convenience wrapper around [`Path1Pre::new`] and /// [`Path1Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path2.rs b/crates/component-macro/tests/expanded/path2.rs index a55018aab0..e75482aa8b 100644 --- a/crates/component-macro/tests/expanded/path2.rs +++ b/crates/component-macro/tests/expanded/path2.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path2`] as well. -pub struct Path2Pre { +pub struct Path2Pre { instance_pre: wasmtime::component::InstancePre, indices: Path2Indices, } -impl Clone for Path2Pre { +impl Clone for Path2Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path2Pre { } } } -impl<_T> Path2Pre<_T> { +impl<_T: 'static> Path2Pre<_T> { /// Creates a new copy of `Path2Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Path2 { /// Convenience wrapper around [`Path2Pre::new`] and /// [`Path2Pre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path2_async.rs b/crates/component-macro/tests/expanded/path2_async.rs index 215125c94e..b99b42b754 100644 --- a/crates/component-macro/tests/expanded/path2_async.rs +++ b/crates/component-macro/tests/expanded/path2_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path2`] as well. -pub struct Path2Pre { +pub struct Path2Pre { instance_pre: wasmtime::component::InstancePre, indices: Path2Indices, } -impl Clone for Path2Pre { +impl Clone for Path2Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path2Pre { } } } -impl<_T> Path2Pre<_T> { +impl<_T: 'static> Path2Pre<_T> { /// Creates a new copy of `Path2Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path2 { /// Convenience wrapper around [`Path2Pre::new`] and /// [`Path2Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path2_concurrent.rs b/crates/component-macro/tests/expanded/path2_concurrent.rs index 215125c94e..b99b42b754 100644 --- a/crates/component-macro/tests/expanded/path2_concurrent.rs +++ b/crates/component-macro/tests/expanded/path2_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path2`] as well. -pub struct Path2Pre { +pub struct Path2Pre { instance_pre: wasmtime::component::InstancePre, indices: Path2Indices, } -impl Clone for Path2Pre { +impl Clone for Path2Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path2Pre { } } } -impl<_T> Path2Pre<_T> { +impl<_T: 'static> Path2Pre<_T> { /// Creates a new copy of `Path2Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path2 { /// Convenience wrapper around [`Path2Pre::new`] and /// [`Path2Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/path2_tracing_async.rs b/crates/component-macro/tests/expanded/path2_tracing_async.rs index 215125c94e..b99b42b754 100644 --- a/crates/component-macro/tests/expanded/path2_tracing_async.rs +++ b/crates/component-macro/tests/expanded/path2_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Path2`] as well. -pub struct Path2Pre { +pub struct Path2Pre { instance_pre: wasmtime::component::InstancePre, indices: Path2Indices, } -impl Clone for Path2Pre { +impl Clone for Path2Pre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for Path2Pre { } } } -impl<_T> Path2Pre<_T> { +impl<_T: 'static> Path2Pre<_T> { /// Creates a new copy of `Path2Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Path2 { /// Convenience wrapper around [`Path2Pre::new`] and /// [`Path2Pre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/records.rs b/crates/component-macro/tests/expanded/records.rs index 40fd7934bc..0433fad0a3 100644 --- a/crates/component-macro/tests/expanded/records.rs +++ b/crates/component-macro/tests/expanded/records.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -861,7 +861,7 @@ pub mod exports { arg0: (char, u32), ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -878,7 +878,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(char, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -896,7 +896,7 @@ pub mod exports { arg0: Empty, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -913,7 +913,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -931,7 +931,7 @@ pub mod exports { arg0: Scalars, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -948,7 +948,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -966,7 +966,7 @@ pub mod exports { arg0: ReallyFlags, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -983,7 +983,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1001,7 +1001,7 @@ pub mod exports { arg0: &Aggregates, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1018,7 +1018,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1036,7 +1036,7 @@ pub mod exports { arg0: TupleTypedef2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/records_async.rs b/crates/component-macro/tests/expanded/records_async.rs index c4ec09ed13..68148f1644 100644 --- a/crates/component-macro/tests/expanded/records_async.rs +++ b/crates/component-macro/tests/expanded/records_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -890,7 +890,7 @@ pub mod exports { arg0: (char, u32), ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -909,7 +909,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(char, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -929,7 +929,7 @@ pub mod exports { arg0: Empty, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -948,7 +948,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -968,7 +968,7 @@ pub mod exports { arg0: Scalars, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -987,7 +987,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1007,7 +1007,7 @@ pub mod exports { arg0: ReallyFlags, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1026,7 +1026,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1046,7 +1046,7 @@ pub mod exports { arg0: &Aggregates, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1065,7 +1065,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1085,7 +1085,7 @@ pub mod exports { arg0: TupleTypedef2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/records_concurrent.rs b/crates/component-macro/tests/expanded/records_concurrent.rs index 366aeca191..57df2d7caf 100644 --- a/crates/component-macro/tests/expanded/records_concurrent.rs +++ b/crates/component-macro/tests/expanded/records_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -917,7 +917,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -934,7 +934,7 @@ pub mod exports { Output = wasmtime::Result<(char, u32)>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -955,7 +955,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -972,7 +972,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -993,7 +993,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1010,7 +1010,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1031,7 +1031,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1048,7 +1048,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1069,7 +1069,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1086,7 +1086,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1107,7 +1107,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/records_tracing_async.rs b/crates/component-macro/tests/expanded/records_tracing_async.rs index 0c64038121..54e2231e31 100644 --- a/crates/component-macro/tests/expanded/records_tracing_async.rs +++ b/crates/component-macro/tests/expanded/records_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1051,7 +1051,7 @@ pub mod exports { arg0: (char, u32), ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1079,7 +1079,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(char, u32)> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1108,7 +1108,7 @@ pub mod exports { arg0: Empty, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1136,7 +1136,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1165,7 +1165,7 @@ pub mod exports { arg0: Scalars, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1193,7 +1193,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1222,7 +1222,7 @@ pub mod exports { arg0: ReallyFlags, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1250,7 +1250,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1279,7 +1279,7 @@ pub mod exports { arg0: &Aggregates, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1307,7 +1307,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1336,7 +1336,7 @@ pub mod exports { arg0: TupleTypedef2, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/rename.rs b/crates/component-macro/tests/expanded/rename.rs index 99e7bafa25..922d873e9a 100644 --- a/crates/component-macro/tests/expanded/rename.rs +++ b/crates/component-macro/tests/expanded/rename.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Neptune`] as well. -pub struct NeptunePre { +pub struct NeptunePre { instance_pre: wasmtime::component::InstancePre, indices: NeptuneIndices, } -impl Clone for NeptunePre { +impl Clone for NeptunePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NeptunePre { } } } -impl<_T> NeptunePre<_T> { +impl<_T: 'static> NeptunePre<_T> { /// Creates a new copy of `NeptunePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Neptune { /// Convenience wrapper around [`NeptunePre::new`] and /// [`NeptunePre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/rename_async.rs b/crates/component-macro/tests/expanded/rename_async.rs index 40ba513af5..993335a9fb 100644 --- a/crates/component-macro/tests/expanded/rename_async.rs +++ b/crates/component-macro/tests/expanded/rename_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Neptune`] as well. -pub struct NeptunePre { +pub struct NeptunePre { instance_pre: wasmtime::component::InstancePre, indices: NeptuneIndices, } -impl Clone for NeptunePre { +impl Clone for NeptunePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NeptunePre { } } } -impl<_T> NeptunePre<_T> { +impl<_T: 'static> NeptunePre<_T> { /// Creates a new copy of `NeptunePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Neptune { /// Convenience wrapper around [`NeptunePre::new`] and /// [`NeptunePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/rename_concurrent.rs b/crates/component-macro/tests/expanded/rename_concurrent.rs index 7433dbab59..46e3430d99 100644 --- a/crates/component-macro/tests/expanded/rename_concurrent.rs +++ b/crates/component-macro/tests/expanded/rename_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Neptune`] as well. -pub struct NeptunePre { +pub struct NeptunePre { instance_pre: wasmtime::component::InstancePre, indices: NeptuneIndices, } -impl Clone for NeptunePre { +impl Clone for NeptunePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NeptunePre { } } } -impl<_T> NeptunePre<_T> { +impl<_T: 'static> NeptunePre<_T> { /// Creates a new copy of `NeptunePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Neptune { /// Convenience wrapper around [`NeptunePre::new`] and /// [`NeptunePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/rename_tracing_async.rs b/crates/component-macro/tests/expanded/rename_tracing_async.rs index 0963cf6962..8f025ffbf9 100644 --- a/crates/component-macro/tests/expanded/rename_tracing_async.rs +++ b/crates/component-macro/tests/expanded/rename_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Neptune`] as well. -pub struct NeptunePre { +pub struct NeptunePre { instance_pre: wasmtime::component::InstancePre, indices: NeptuneIndices, } -impl Clone for NeptunePre { +impl Clone for NeptunePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NeptunePre { } } } -impl<_T> NeptunePre<_T> { +impl<_T: 'static> NeptunePre<_T> { /// Creates a new copy of `NeptunePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Neptune { /// Convenience wrapper around [`NeptunePre::new`] and /// [`NeptunePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/resources-export.rs b/crates/component-macro/tests/expanded/resources-export.rs index db6fd608ed..183004fd2f 100644 --- a/crates/component-macro/tests/expanded/resources-export.rs +++ b/crates/component-macro/tests/expanded/resources-export.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`W`] as well. -pub struct WPre { +pub struct WPre { instance_pre: wasmtime::component::InstancePre, indices: WIndices, } -impl Clone for WPre { +impl Clone for WPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WPre { } } } -impl<_T> WPre<_T> { +impl<_T: 'static> WPre<_T> { /// Creates a new copy of `WPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -157,7 +157,7 @@ const _: () = { impl W { /// Convenience wrapper around [`WPre::new`] and /// [`WPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -361,7 +361,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -378,7 +378,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -396,7 +396,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -519,7 +519,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -536,7 +536,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -555,7 +555,7 @@ pub mod exports { arg1: wasmtime::component::Resource, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -652,7 +652,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -748,7 +748,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-export_async.rs b/crates/component-macro/tests/expanded/resources-export_async.rs index 4ebfc684d0..22c82a5af3 100644 --- a/crates/component-macro/tests/expanded/resources-export_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`W`] as well. -pub struct WPre { +pub struct WPre { instance_pre: wasmtime::component::InstancePre, indices: WIndices, } -impl Clone for WPre { +impl Clone for WPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WPre { } } } -impl<_T> WPre<_T> { +impl<_T: 'static> WPre<_T> { /// Creates a new copy of `WPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -160,7 +160,7 @@ const _: () = { impl W { /// Convenience wrapper around [`WPre::new`] and /// [`WPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -372,7 +372,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -391,7 +391,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -411,7 +411,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -536,7 +536,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -555,7 +555,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -576,7 +576,7 @@ pub mod exports { arg1: wasmtime::component::Resource, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -675,7 +675,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -773,7 +773,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-export_concurrent.rs b/crates/component-macro/tests/expanded/resources-export_concurrent.rs index 2ce4ffd018..a147a615d7 100644 --- a/crates/component-macro/tests/expanded/resources-export_concurrent.rs +++ b/crates/component-macro/tests/expanded/resources-export_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`W`] as well. -pub struct WPre { +pub struct WPre { instance_pre: wasmtime::component::InstancePre, indices: WIndices, } -impl Clone for WPre { +impl Clone for WPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WPre { } } } -impl<_T> WPre<_T> { +impl<_T: 'static> WPre<_T> { /// Creates a new copy of `WPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -160,7 +160,7 @@ const _: () = { impl W { /// Convenience wrapper around [`WPre::new`] and /// [`WPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -374,7 +374,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -394,7 +394,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -415,7 +415,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -541,7 +541,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -561,7 +561,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -583,7 +583,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -683,7 +683,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -782,7 +782,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs index ea7d17aeec..2af3380592 100644 --- a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`W`] as well. -pub struct WPre { +pub struct WPre { instance_pre: wasmtime::component::InstancePre, indices: WIndices, } -impl Clone for WPre { +impl Clone for WPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WPre { } } } -impl<_T> WPre<_T> { +impl<_T: 'static> WPre<_T> { /// Creates a new copy of `WPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -160,7 +160,7 @@ const _: () = { impl W { /// Convenience wrapper around [`WPre::new`] and /// [`WPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -372,7 +372,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -400,7 +400,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -429,7 +429,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -563,7 +563,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -591,7 +591,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -622,7 +622,7 @@ pub mod exports { arg1: wasmtime::component::Resource, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -731,7 +731,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -838,7 +838,7 @@ pub mod exports { arg0: wasmtime::component::ResourceAny, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/resources-import.rs b/crates/component-macro/tests/expanded/resources-import.rs index e0d87a929e..5badf5f07a 100644 --- a/crates/component-macro/tests/expanded/resources-import.rs +++ b/crates/component-macro/tests/expanded/resources-import.rs @@ -33,11 +33,11 @@ impl<_T: HostWorldResource> HostWorldResource for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -45,7 +45,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -205,7 +205,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -315,7 +315,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1075,7 +1075,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-import_async.rs b/crates/component-macro/tests/expanded/resources-import_async.rs index 3da3666de1..659ee2ad0b 100644 --- a/crates/component-macro/tests/expanded/resources-import_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_async.rs @@ -34,11 +34,11 @@ impl<_T: HostWorldResource + Send> HostWorldResource for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -46,7 +46,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -211,7 +211,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -336,7 +336,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1173,7 +1173,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-import_concurrent.rs b/crates/component-macro/tests/expanded/resources-import_concurrent.rs index 7b361f5805..f8bc884b3e 100644 --- a/crates/component-macro/tests/expanded/resources-import_concurrent.rs +++ b/crates/component-macro/tests/expanded/resources-import_concurrent.rs @@ -43,11 +43,11 @@ impl<_T: HostWorldResource + Send> HostWorldResource for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -55,7 +55,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -224,7 +224,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -364,7 +364,7 @@ const _: () = { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1204,7 +1204,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs index 3bcff0ba38..87f151d572 100644 --- a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs @@ -34,11 +34,11 @@ impl<_T: HostWorldResource + Send> HostWorldResource for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -46,7 +46,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -211,7 +211,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -391,7 +391,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1577,7 +1577,7 @@ pub mod exports { arg0: wasmtime::component::Resource, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/share-types.rs b/crates/component-macro/tests/expanded/share-types.rs index a3633f8f3f..9f26f0f0e4 100644 --- a/crates/component-macro/tests/expanded/share-types.rs +++ b/crates/component-macro/tests/expanded/share-types.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`HttpInterface`] as well. -pub struct HttpInterfacePre { +pub struct HttpInterfacePre { instance_pre: wasmtime::component::InstancePre, indices: HttpInterfaceIndices, } -impl Clone for HttpInterfacePre { +impl Clone for HttpInterfacePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for HttpInterfacePre { } } } -impl<_T> HttpInterfacePre<_T> { +impl<_T: 'static> HttpInterfacePre<_T> { /// Creates a new copy of `HttpInterfacePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl HttpInterface { /// Convenience wrapper around [`HttpInterfacePre::new`] and /// [`HttpInterfacePre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -345,7 +345,7 @@ pub mod exports { arg0: &Request, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/share-types_async.rs b/crates/component-macro/tests/expanded/share-types_async.rs index dd99ea76a8..81dc0d875c 100644 --- a/crates/component-macro/tests/expanded/share-types_async.rs +++ b/crates/component-macro/tests/expanded/share-types_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`HttpInterface`] as well. -pub struct HttpInterfacePre { +pub struct HttpInterfacePre { instance_pre: wasmtime::component::InstancePre, indices: HttpInterfaceIndices, } -impl Clone for HttpInterfacePre { +impl Clone for HttpInterfacePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for HttpInterfacePre { } } } -impl<_T> HttpInterfacePre<_T> { +impl<_T: 'static> HttpInterfacePre<_T> { /// Creates a new copy of `HttpInterfacePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl HttpInterface { /// Convenience wrapper around [`HttpInterfacePre::new`] and /// [`HttpInterfacePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -355,7 +355,7 @@ pub mod exports { arg0: &Request, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/share-types_concurrent.rs b/crates/component-macro/tests/expanded/share-types_concurrent.rs index 36434aa575..4f81e58d1c 100644 --- a/crates/component-macro/tests/expanded/share-types_concurrent.rs +++ b/crates/component-macro/tests/expanded/share-types_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`HttpInterface`] as well. -pub struct HttpInterfacePre { +pub struct HttpInterfacePre { instance_pre: wasmtime::component::InstancePre, indices: HttpInterfaceIndices, } -impl Clone for HttpInterfacePre { +impl Clone for HttpInterfacePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for HttpInterfacePre { } } } -impl<_T> HttpInterfacePre<_T> { +impl<_T: 'static> HttpInterfacePre<_T> { /// Creates a new copy of `HttpInterfacePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl HttpInterface { /// Convenience wrapper around [`HttpInterfacePre::new`] and /// [`HttpInterfacePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -360,7 +360,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/share-types_tracing_async.rs b/crates/component-macro/tests/expanded/share-types_tracing_async.rs index 1cfd90420b..3edcedda64 100644 --- a/crates/component-macro/tests/expanded/share-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/share-types_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`HttpInterface`] as well. -pub struct HttpInterfacePre { +pub struct HttpInterfacePre { instance_pre: wasmtime::component::InstancePre, indices: HttpInterfaceIndices, } -impl Clone for HttpInterfacePre { +impl Clone for HttpInterfacePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for HttpInterfacePre { } } } -impl<_T> HttpInterfacePre<_T> { +impl<_T: 'static> HttpInterfacePre<_T> { /// Creates a new copy of `HttpInterfacePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl HttpInterface { /// Convenience wrapper around [`HttpInterfacePre::new`] and /// [`HttpInterfacePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -371,7 +371,7 @@ pub mod exports { arg0: &Request, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/simple-functions.rs b/crates/component-macro/tests/expanded/simple-functions.rs index c3ecd060c0..849c71b3a0 100644 --- a/crates/component-macro/tests/expanded/simple-functions.rs +++ b/crates/component-macro/tests/expanded/simple-functions.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -375,7 +375,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -393,7 +393,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -412,7 +412,7 @@ pub mod exports { arg1: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -429,7 +429,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -446,7 +446,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -466,7 +466,7 @@ pub mod exports { arg2: u32, ) -> wasmtime::Result<(u32, u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-functions_async.rs b/crates/component-macro/tests/expanded/simple-functions_async.rs index 77322c465e..6498f3dcac 100644 --- a/crates/component-macro/tests/expanded/simple-functions_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -394,7 +394,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -412,7 +412,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -433,7 +433,7 @@ pub mod exports { arg1: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -452,7 +452,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -471,7 +471,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -493,7 +493,7 @@ pub mod exports { arg2: u32, ) -> wasmtime::Result<(u32, u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs index b1005236db..6fc4f568f9 100644 --- a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs +++ b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -414,7 +414,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -432,7 +432,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -451,7 +451,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -468,7 +468,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -488,7 +488,7 @@ pub mod exports { Output = wasmtime::Result<(u32, u32)>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -511,7 +511,7 @@ pub mod exports { Output = wasmtime::Result<(u32, u32, u32)>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs index c275ea5da5..1f2d0e7b37 100644 --- a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -482,7 +482,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -511,7 +511,7 @@ pub mod exports { arg0: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -541,7 +541,7 @@ pub mod exports { arg1: u32, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -569,7 +569,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -597,7 +597,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<(u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -628,7 +628,7 @@ pub mod exports { arg2: u32, ) -> wasmtime::Result<(u32, u32, u32)> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/simple-lists.rs b/crates/component-macro/tests/expanded/simple-lists.rs index 88737eeb61..61797cc7f2 100644 --- a/crates/component-macro/tests/expanded/simple-lists.rs +++ b/crates/component-macro/tests/expanded/simple-lists.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -410,7 +410,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -427,7 +427,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -451,7 +451,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -478,7 +478,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-lists_async.rs b/crates/component-macro/tests/expanded/simple-lists_async.rs index 6dda158147..8f82e05fe7 100644 --- a/crates/component-macro/tests/expanded/simple-lists_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -429,7 +429,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -448,7 +448,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -474,7 +474,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -503,7 +503,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs index ff09bd6567..d4988ce8a7 100644 --- a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs +++ b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -422,7 +422,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -441,7 +441,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -468,7 +468,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -503,7 +503,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs index 1bb398c83f..04482ed5ad 100644 --- a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -490,7 +490,7 @@ pub mod exports { arg0: &[u32], ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -518,7 +518,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -553,7 +553,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -591,7 +591,7 @@ pub mod exports { >, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/simple-wasi.rs b/crates/component-macro/tests/expanded/simple-wasi.rs index 0aaead61f0..bd71b7ef48 100644 --- a/crates/component-macro/tests/expanded/simple-wasi.rs +++ b/crates/component-macro/tests/expanded/simple-wasi.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Wasi`] as well. -pub struct WasiPre { +pub struct WasiPre { instance_pre: wasmtime::component::InstancePre, indices: WasiIndices, } -impl Clone for WasiPre { +impl Clone for WasiPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WasiPre { } } } -impl<_T> WasiPre<_T> { +impl<_T: 'static> WasiPre<_T> { /// Creates a new copy of `WasiPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Wasi { /// Convenience wrapper around [`WasiPre::new`] and /// [`WasiPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/simple-wasi_async.rs b/crates/component-macro/tests/expanded/simple-wasi_async.rs index cc6a2e0e90..55e7653da1 100644 --- a/crates/component-macro/tests/expanded/simple-wasi_async.rs +++ b/crates/component-macro/tests/expanded/simple-wasi_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Wasi`] as well. -pub struct WasiPre { +pub struct WasiPre { instance_pre: wasmtime::component::InstancePre, indices: WasiIndices, } -impl Clone for WasiPre { +impl Clone for WasiPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WasiPre { } } } -impl<_T> WasiPre<_T> { +impl<_T: 'static> WasiPre<_T> { /// Creates a new copy of `WasiPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Wasi { /// Convenience wrapper around [`WasiPre::new`] and /// [`WasiPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs b/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs index 764645ec10..d43c3385bb 100644 --- a/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs +++ b/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Wasi`] as well. -pub struct WasiPre { +pub struct WasiPre { instance_pre: wasmtime::component::InstancePre, indices: WasiIndices, } -impl Clone for WasiPre { +impl Clone for WasiPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WasiPre { } } } -impl<_T> WasiPre<_T> { +impl<_T: 'static> WasiPre<_T> { /// Creates a new copy of `WasiPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Wasi { /// Convenience wrapper around [`WasiPre::new`] and /// [`WasiPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs b/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs index 2db7d4fad5..bdbb2e4c8f 100644 --- a/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Wasi`] as well. -pub struct WasiPre { +pub struct WasiPre { instance_pre: wasmtime::component::InstancePre, indices: WasiIndices, } -impl Clone for WasiPre { +impl Clone for WasiPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for WasiPre { } } } -impl<_T> WasiPre<_T> { +impl<_T: 'static> WasiPre<_T> { /// Creates a new copy of `WasiPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Wasi { /// Convenience wrapper around [`WasiPre::new`] and /// [`WasiPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/small-anonymous.rs b/crates/component-macro/tests/expanded/small-anonymous.rs index e130472e05..1b6d55b4b9 100644 --- a/crates/component-macro/tests/expanded/small-anonymous.rs +++ b/crates/component-macro/tests/expanded/small-anonymous.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -379,7 +379,7 @@ pub mod exports { Result, Error>, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/small-anonymous_async.rs b/crates/component-macro/tests/expanded/small-anonymous_async.rs index 851a5e37ed..7612ae353b 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -388,7 +388,7 @@ pub mod exports { Result, Error>, > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs index 1dd11efa1c..0f370ff9c4 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -396,7 +396,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs index f5e0dcb749..2b2aaa43a1 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -401,7 +401,7 @@ pub mod exports { Result, Error>, > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/smoke-default.rs b/crates/component-macro/tests/expanded/smoke-default.rs index 7dbcfa49bd..235c1f8c2b 100644 --- a/crates/component-macro/tests/expanded/smoke-default.rs +++ b/crates/component-macro/tests/expanded/smoke-default.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -141,7 +141,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -163,7 +163,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-default_async.rs b/crates/component-macro/tests/expanded/smoke-default_async.rs index eeef13c512..04f07782a6 100644 --- a/crates/component-macro/tests/expanded/smoke-default_async.rs +++ b/crates/component-macro/tests/expanded/smoke-default_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -169,7 +169,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-default_concurrent.rs b/crates/component-macro/tests/expanded/smoke-default_concurrent.rs index 89bba4d6f6..90fc4e4dc9 100644 --- a/crates/component-macro/tests/expanded/smoke-default_concurrent.rs +++ b/crates/component-macro/tests/expanded/smoke-default_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -171,7 +171,7 @@ const _: () = { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs index 59adb46dcf..28e79b5744 100644 --- a/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -144,7 +144,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -169,7 +169,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/smoke-export.rs b/crates/component-macro/tests/expanded/smoke-export.rs index 3919bba6c9..37ca4dff06 100644 --- a/crates/component-macro/tests/expanded/smoke-export.rs +++ b/crates/component-macro/tests/expanded/smoke-export.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -127,7 +127,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -212,7 +212,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-export_async.rs b/crates/component-macro/tests/expanded/smoke-export_async.rs index 2abe17cafa..9543475a9f 100644 --- a/crates/component-macro/tests/expanded/smoke-export_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -218,7 +218,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-export_concurrent.rs b/crates/component-macro/tests/expanded/smoke-export_concurrent.rs index 0b33d03c7d..0f2c9207c2 100644 --- a/crates/component-macro/tests/expanded/smoke-export_concurrent.rs +++ b/crates/component-macro/tests/expanded/smoke-export_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -220,7 +220,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) diff --git a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs index 8d2475dd97..ef726d0546 100644 --- a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -130,7 +130,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -218,7 +218,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/smoke.rs b/crates/component-macro/tests/expanded/smoke.rs index 20a8743874..a4620a9e45 100644 --- a/crates/component-macro/tests/expanded/smoke.rs +++ b/crates/component-macro/tests/expanded/smoke.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/smoke_async.rs b/crates/component-macro/tests/expanded/smoke_async.rs index e2a89cf7f3..c8edf6851b 100644 --- a/crates/component-macro/tests/expanded/smoke_async.rs +++ b/crates/component-macro/tests/expanded/smoke_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/smoke_concurrent.rs b/crates/component-macro/tests/expanded/smoke_concurrent.rs index 1b20771f34..cfe72db28a 100644 --- a/crates/component-macro/tests/expanded/smoke_concurrent.rs +++ b/crates/component-macro/tests/expanded/smoke_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/smoke_tracing_async.rs b/crates/component-macro/tests/expanded/smoke_tracing_async.rs index 28ddeb7e05..88b974ab8e 100644 --- a/crates/component-macro/tests/expanded/smoke_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/strings.rs b/crates/component-macro/tests/expanded/strings.rs index 047567a2a4..30d5c1c246 100644 --- a/crates/component-macro/tests/expanded/strings.rs +++ b/crates/component-macro/tests/expanded/strings.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -332,7 +332,7 @@ pub mod exports { arg0: &str, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -349,7 +349,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -368,7 +368,7 @@ pub mod exports { arg1: &str, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/strings_async.rs b/crates/component-macro/tests/expanded/strings_async.rs index 9cd83cdbef..8db554a380 100644 --- a/crates/component-macro/tests/expanded/strings_async.rs +++ b/crates/component-macro/tests/expanded/strings_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -345,7 +345,7 @@ pub mod exports { arg0: &str, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -364,7 +364,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -385,7 +385,7 @@ pub mod exports { arg1: &str, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/strings_concurrent.rs b/crates/component-macro/tests/expanded/strings_concurrent.rs index 60822ecf21..5cdb99e28b 100644 --- a/crates/component-macro/tests/expanded/strings_concurrent.rs +++ b/crates/component-macro/tests/expanded/strings_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -350,7 +350,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -369,7 +369,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -393,7 +393,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/strings_tracing_async.rs b/crates/component-macro/tests/expanded/strings_tracing_async.rs index 01a3783133..39fdaaf46d 100644 --- a/crates/component-macro/tests/expanded/strings_tracing_async.rs +++ b/crates/component-macro/tests/expanded/strings_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -390,7 +390,7 @@ pub mod exports { arg0: &str, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -418,7 +418,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -448,7 +448,7 @@ pub mod exports { arg1: &str, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/unstable-features.rs b/crates/component-macro/tests/expanded/unstable-features.rs index 1e6ebb76b2..ebd6b5ba25 100644 --- a/crates/component-macro/tests/expanded/unstable-features.rs +++ b/crates/component-macro/tests/expanded/unstable-features.rs @@ -99,11 +99,11 @@ impl<_T: HostBaz> HostBaz for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -111,7 +111,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -222,7 +222,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unstable-features_async.rs b/crates/component-macro/tests/expanded/unstable-features_async.rs index f7178c66ce..e9cf88be27 100644 --- a/crates/component-macro/tests/expanded/unstable-features_async.rs +++ b/crates/component-macro/tests/expanded/unstable-features_async.rs @@ -106,11 +106,11 @@ impl<_T: HostBaz + Send> HostBaz for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -118,7 +118,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -234,7 +234,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unstable-features_concurrent.rs b/crates/component-macro/tests/expanded/unstable-features_concurrent.rs index 6c4e1ec49e..e558f43616 100644 --- a/crates/component-macro/tests/expanded/unstable-features_concurrent.rs +++ b/crates/component-macro/tests/expanded/unstable-features_concurrent.rs @@ -111,11 +111,11 @@ impl<_T: HostBaz + Send> HostBaz for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -123,7 +123,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -241,7 +241,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs b/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs index e3a8dfec16..80a630af00 100644 --- a/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs +++ b/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs @@ -106,11 +106,11 @@ impl<_T: HostBaz + Send> HostBaz for &mut _T { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`TheWorld`] as well. -pub struct TheWorldPre { +pub struct TheWorldPre { instance_pre: wasmtime::component::InstancePre, indices: TheWorldIndices, } -impl Clone for TheWorldPre { +impl Clone for TheWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -118,7 +118,7 @@ impl Clone for TheWorldPre { } } } -impl<_T> TheWorldPre<_T> { +impl<_T: 'static> TheWorldPre<_T> { /// Creates a new copy of `TheWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -234,7 +234,7 @@ const _: () = { impl TheWorld { /// Convenience wrapper around [`TheWorldPre::new`] and /// [`TheWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unversioned-foo.rs b/crates/component-macro/tests/expanded/unversioned-foo.rs index 535f3ac3a3..5bbbc12621 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Nope`] as well. -pub struct NopePre { +pub struct NopePre { instance_pre: wasmtime::component::InstancePre, indices: NopeIndices, } -impl Clone for NopePre { +impl Clone for NopePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NopePre { } } } -impl<_T> NopePre<_T> { +impl<_T: 'static> NopePre<_T> { /// Creates a new copy of `NopePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl Nope { /// Convenience wrapper around [`NopePre::new`] and /// [`NopePre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unversioned-foo_async.rs b/crates/component-macro/tests/expanded/unversioned-foo_async.rs index 1dee96ad2f..992e074269 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo_async.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Nope`] as well. -pub struct NopePre { +pub struct NopePre { instance_pre: wasmtime::component::InstancePre, indices: NopeIndices, } -impl Clone for NopePre { +impl Clone for NopePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NopePre { } } } -impl<_T> NopePre<_T> { +impl<_T: 'static> NopePre<_T> { /// Creates a new copy of `NopePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Nope { /// Convenience wrapper around [`NopePre::new`] and /// [`NopePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs b/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs index f71c325cf6..37b83c18dc 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Nope`] as well. -pub struct NopePre { +pub struct NopePre { instance_pre: wasmtime::component::InstancePre, indices: NopeIndices, } -impl Clone for NopePre { +impl Clone for NopePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NopePre { } } } -impl<_T> NopePre<_T> { +impl<_T: 'static> NopePre<_T> { /// Creates a new copy of `NopePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Nope { /// Convenience wrapper around [`NopePre::new`] and /// [`NopePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs b/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs index defa581249..0692679840 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Nope`] as well. -pub struct NopePre { +pub struct NopePre { instance_pre: wasmtime::component::InstancePre, indices: NopeIndices, } -impl Clone for NopePre { +impl Clone for NopePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for NopePre { } } } -impl<_T> NopePre<_T> { +impl<_T: 'static> NopePre<_T> { /// Creates a new copy of `NopePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl Nope { /// Convenience wrapper around [`NopePre::new`] and /// [`NopePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/use-paths.rs b/crates/component-macro/tests/expanded/use-paths.rs index 75b1b8ef7d..d9729020f9 100644 --- a/crates/component-macro/tests/expanded/use-paths.rs +++ b/crates/component-macro/tests/expanded/use-paths.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`D`] as well. -pub struct DPre { +pub struct DPre { instance_pre: wasmtime::component::InstancePre, indices: DIndices, } -impl Clone for DPre { +impl Clone for DPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for DPre { } } } -impl<_T> DPre<_T> { +impl<_T: 'static> DPre<_T> { /// Creates a new copy of `DPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -121,7 +121,7 @@ const _: () = { impl D { /// Convenience wrapper around [`DPre::new`] and /// [`DPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/use-paths_async.rs b/crates/component-macro/tests/expanded/use-paths_async.rs index b1e3006049..a6d588e699 100644 --- a/crates/component-macro/tests/expanded/use-paths_async.rs +++ b/crates/component-macro/tests/expanded/use-paths_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`D`] as well. -pub struct DPre { +pub struct DPre { instance_pre: wasmtime::component::InstancePre, indices: DIndices, } -impl Clone for DPre { +impl Clone for DPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for DPre { } } } -impl<_T> DPre<_T> { +impl<_T: 'static> DPre<_T> { /// Creates a new copy of `DPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl D { /// Convenience wrapper around [`DPre::new`] and /// [`DPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/use-paths_concurrent.rs b/crates/component-macro/tests/expanded/use-paths_concurrent.rs index d5a013c6a8..eea3fd2bbd 100644 --- a/crates/component-macro/tests/expanded/use-paths_concurrent.rs +++ b/crates/component-macro/tests/expanded/use-paths_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`D`] as well. -pub struct DPre { +pub struct DPre { instance_pre: wasmtime::component::InstancePre, indices: DIndices, } -impl Clone for DPre { +impl Clone for DPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for DPre { } } } -impl<_T> DPre<_T> { +impl<_T: 'static> DPre<_T> { /// Creates a new copy of `DPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl D { /// Convenience wrapper around [`DPre::new`] and /// [`DPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/use-paths_tracing_async.rs b/crates/component-macro/tests/expanded/use-paths_tracing_async.rs index fcf73502a2..3ffac40d0a 100644 --- a/crates/component-macro/tests/expanded/use-paths_tracing_async.rs +++ b/crates/component-macro/tests/expanded/use-paths_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`D`] as well. -pub struct DPre { +pub struct DPre { instance_pre: wasmtime::component::InstancePre, indices: DIndices, } -impl Clone for DPre { +impl Clone for DPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for DPre { } } } -impl<_T> DPre<_T> { +impl<_T: 'static> DPre<_T> { /// Creates a new copy of `DPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -124,7 +124,7 @@ const _: () = { impl D { /// Convenience wrapper around [`DPre::new`] and /// [`DPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/variants.rs b/crates/component-macro/tests/expanded/variants.rs index 1a4e49dfc7..60bd240793 100644 --- a/crates/component-macro/tests/expanded/variants.rs +++ b/crates/component-macro/tests/expanded/variants.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1515,7 +1515,7 @@ pub mod exports { arg0: E1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1532,7 +1532,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1550,7 +1550,7 @@ pub mod exports { arg0: &V1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1567,7 +1567,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1585,7 +1585,7 @@ pub mod exports { arg0: bool, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1602,7 +1602,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1625,7 +1625,7 @@ pub mod exports { arg5: Option>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1662,7 +1662,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1696,7 +1696,7 @@ pub mod exports { (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1723,7 +1723,7 @@ pub mod exports { arg5: Result<&str, &[u8]>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1763,7 +1763,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1792,7 +1792,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1809,7 +1809,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1826,7 +1826,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1843,7 +1843,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1860,7 +1860,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1877,7 +1877,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1894,7 +1894,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1912,7 +1912,7 @@ pub mod exports { arg0: &IsClone, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1929,7 +1929,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/variants_async.rs b/crates/component-macro/tests/expanded/variants_async.rs index 895bb63cb8..a7d61de0a7 100644 --- a/crates/component-macro/tests/expanded/variants_async.rs +++ b/crates/component-macro/tests/expanded/variants_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1565,7 +1565,7 @@ pub mod exports { arg0: E1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1584,7 +1584,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1604,7 +1604,7 @@ pub mod exports { arg0: &V1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1623,7 +1623,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1643,7 +1643,7 @@ pub mod exports { arg0: bool, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1662,7 +1662,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1687,7 +1687,7 @@ pub mod exports { arg5: Option>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1725,7 +1725,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1761,7 +1761,7 @@ pub mod exports { (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1789,7 +1789,7 @@ pub mod exports { arg5: Result<&str, &[u8]>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1830,7 +1830,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1861,7 +1861,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1880,7 +1880,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1899,7 +1899,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1918,7 +1918,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1937,7 +1937,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1956,7 +1956,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1975,7 +1975,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1995,7 +1995,7 @@ pub mod exports { arg0: &IsClone, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2014,7 +2014,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/variants_concurrent.rs b/crates/component-macro/tests/expanded/variants_concurrent.rs index ada8e955d1..590fbb2050 100644 --- a/crates/component-macro/tests/expanded/variants_concurrent.rs +++ b/crates/component-macro/tests/expanded/variants_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1561,7 +1561,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1578,7 +1578,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1599,7 +1599,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1616,7 +1616,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1637,7 +1637,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1654,7 +1654,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1680,7 +1680,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1717,7 +1717,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1754,7 +1754,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1787,7 +1787,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1830,7 +1830,7 @@ pub mod exports { >, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1862,7 +1862,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1882,7 +1882,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1902,7 +1902,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1922,7 +1922,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1942,7 +1942,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1962,7 +1962,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -1982,7 +1982,7 @@ pub mod exports { Output = wasmtime::Result>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2003,7 +2003,7 @@ pub mod exports { Output = wasmtime::Result<()>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< @@ -2020,7 +2020,7 @@ pub mod exports { Output = wasmtime::Result, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::< diff --git a/crates/component-macro/tests/expanded/variants_tracing_async.rs b/crates/component-macro/tests/expanded/variants_tracing_async.rs index 6e7b8b823f..d98ad32f76 100644 --- a/crates/component-macro/tests/expanded/variants_tracing_async.rs +++ b/crates/component-macro/tests/expanded/variants_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`MyWorld`] as well. -pub struct MyWorldPre { +pub struct MyWorldPre { instance_pre: wasmtime::component::InstancePre, indices: MyWorldIndices, } -impl Clone for MyWorldPre { +impl Clone for MyWorldPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for MyWorldPre { } } } -impl<_T> MyWorldPre<_T> { +impl<_T: 'static> MyWorldPre<_T> { /// Creates a new copy of `MyWorldPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl MyWorld { /// Convenience wrapper around [`MyWorldPre::new`] and /// [`MyWorldPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -1863,7 +1863,7 @@ pub mod exports { arg0: E1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1891,7 +1891,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1920,7 +1920,7 @@ pub mod exports { arg0: &V1, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1948,7 +1948,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -1977,7 +1977,7 @@ pub mod exports { arg0: bool, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2005,7 +2005,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2039,7 +2039,7 @@ pub mod exports { arg5: Option>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2086,7 +2086,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2131,7 +2131,7 @@ pub mod exports { (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2168,7 +2168,7 @@ pub mod exports { arg5: Result<&str, &[u8]>, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2218,7 +2218,7 @@ pub mod exports { ), > where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2258,7 +2258,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2286,7 +2286,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2314,7 +2314,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2342,7 +2342,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2370,7 +2370,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2398,7 +2398,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2426,7 +2426,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2455,7 +2455,7 @@ pub mod exports { arg0: &IsClone, ) -> wasmtime::Result<()> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( @@ -2483,7 +2483,7 @@ pub mod exports { mut store: S, ) -> wasmtime::Result where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/component-macro/tests/expanded/wat.rs b/crates/component-macro/tests/expanded/wat.rs index 5fb8cafb1b..c116fc3dad 100644 --- a/crates/component-macro/tests/expanded/wat.rs +++ b/crates/component-macro/tests/expanded/wat.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Example`] as well. -pub struct ExamplePre { +pub struct ExamplePre { instance_pre: wasmtime::component::InstancePre, indices: ExampleIndices, } -impl Clone for ExamplePre { +impl Clone for ExamplePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ExamplePre { } } } -impl<_T> ExamplePre<_T> { +impl<_T: 'static> ExamplePre<_T> { /// Creates a new copy of `ExamplePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -129,7 +129,7 @@ const _: () = { impl Example { /// Convenience wrapper around [`ExamplePre::new`] and /// [`ExamplePre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/wat_async.rs b/crates/component-macro/tests/expanded/wat_async.rs index c9d80e5326..f0651b004a 100644 --- a/crates/component-macro/tests/expanded/wat_async.rs +++ b/crates/component-macro/tests/expanded/wat_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Example`] as well. -pub struct ExamplePre { +pub struct ExamplePre { instance_pre: wasmtime::component::InstancePre, indices: ExampleIndices, } -impl Clone for ExamplePre { +impl Clone for ExamplePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ExamplePre { } } } -impl<_T> ExamplePre<_T> { +impl<_T: 'static> ExamplePre<_T> { /// Creates a new copy of `ExamplePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl Example { /// Convenience wrapper around [`ExamplePre::new`] and /// [`ExamplePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/wat_concurrent.rs b/crates/component-macro/tests/expanded/wat_concurrent.rs index c9d80e5326..f0651b004a 100644 --- a/crates/component-macro/tests/expanded/wat_concurrent.rs +++ b/crates/component-macro/tests/expanded/wat_concurrent.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Example`] as well. -pub struct ExamplePre { +pub struct ExamplePre { instance_pre: wasmtime::component::InstancePre, indices: ExampleIndices, } -impl Clone for ExamplePre { +impl Clone for ExamplePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ExamplePre { } } } -impl<_T> ExamplePre<_T> { +impl<_T: 'static> ExamplePre<_T> { /// Creates a new copy of `ExamplePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl Example { /// Convenience wrapper around [`ExamplePre::new`] and /// [`ExamplePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/wat_tracing_async.rs b/crates/component-macro/tests/expanded/wat_tracing_async.rs index c9d80e5326..f0651b004a 100644 --- a/crates/component-macro/tests/expanded/wat_tracing_async.rs +++ b/crates/component-macro/tests/expanded/wat_tracing_async.rs @@ -6,11 +6,11 @@ /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Example`] as well. -pub struct ExamplePre { +pub struct ExamplePre { instance_pre: wasmtime::component::InstancePre, indices: ExampleIndices, } -impl Clone for ExamplePre { +impl Clone for ExamplePre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -18,7 +18,7 @@ impl Clone for ExamplePre { } } } -impl<_T> ExamplePre<_T> { +impl<_T: 'static> ExamplePre<_T> { /// Creates a new copy of `ExamplePre` bindings which can then /// be used to instantiate into a particular store. /// @@ -132,7 +132,7 @@ const _: () = { impl Example { /// Convenience wrapper around [`ExamplePre::new`] and /// [`ExamplePre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, diff --git a/crates/component-macro/tests/expanded/worlds-with-types.rs b/crates/component-macro/tests/expanded/worlds-with-types.rs index e5bcbc2465..481de5598c 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types.rs @@ -31,11 +31,11 @@ const _: () = { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -43,7 +43,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -168,7 +168,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate`]. - pub fn instantiate<_T>( + pub fn instantiate<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -202,7 +202,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<(T, U, R)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ((T, U, R),)>::new_unchecked(self.f) diff --git a/crates/component-macro/tests/expanded/worlds-with-types_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_async.rs index 7dba549c24..1c8beecc24 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_async.rs @@ -31,11 +31,11 @@ const _: () = { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -43,7 +43,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -171,7 +171,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -208,7 +208,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<(T, U, R)> where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ((T, U, R),)>::new_unchecked(self.f) diff --git a/crates/component-macro/tests/expanded/worlds-with-types_concurrent.rs b/crates/component-macro/tests/expanded/worlds-with-types_concurrent.rs index d58789ca5f..f9d0962e7e 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_concurrent.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_concurrent.rs @@ -31,11 +31,11 @@ const _: () = { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -43,7 +43,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -171,7 +171,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -210,7 +210,7 @@ const _: () = { Output = wasmtime::Result<(T, U, R)>, > + Send + 'static + use where - ::Data: Send, + ::Data: Send + 'static, { let callee = unsafe { wasmtime::component::TypedFunc::<(), ((T, U, R),)>::new_unchecked(self.f) diff --git a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs index b40bff0736..c4722f22b4 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs @@ -31,11 +31,11 @@ const _: () = { /// has been created through a [`Linker`](wasmtime::component::Linker). /// /// For more information see [`Foo`] as well. -pub struct FooPre { +pub struct FooPre { instance_pre: wasmtime::component::InstancePre, indices: FooIndices, } -impl Clone for FooPre { +impl Clone for FooPre { fn clone(&self) -> Self { Self { instance_pre: self.instance_pre.clone(), @@ -43,7 +43,7 @@ impl Clone for FooPre { } } } -impl<_T> FooPre<_T> { +impl<_T: 'static> FooPre<_T> { /// Creates a new copy of `FooPre` bindings which can then /// be used to instantiate into a particular store. /// @@ -171,7 +171,7 @@ const _: () = { impl Foo { /// Convenience wrapper around [`FooPre::new`] and /// [`FooPre::instantiate_async`]. - pub async fn instantiate_async<_T>( + pub async fn instantiate_async<_T: 'static>( store: impl wasmtime::AsContextMut, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, @@ -208,7 +208,7 @@ const _: () = { mut store: S, ) -> wasmtime::Result<(T, U, R)> where - ::Data: Send, + ::Data: Send + 'static, { use tracing::Instrument; let span = tracing::span!( diff --git a/crates/fuzzing/src/oracles/dummy.rs b/crates/fuzzing/src/oracles/dummy.rs index c5790e759e..66933b857b 100644 --- a/crates/fuzzing/src/oracles/dummy.rs +++ b/crates/fuzzing/src/oracles/dummy.rs @@ -4,7 +4,7 @@ use anyhow::Context; use wasmtime::*; /// Create a set of dummy functions/globals/etc for the given imports. -pub fn dummy_linker(store: &mut Store, module: &Module) -> Result> { +pub fn dummy_linker(store: &mut Store, module: &Module) -> Result> { let mut linker = Linker::new(store.engine()); linker.allow_shadowing(true); for import in module.imports() { diff --git a/crates/misc/component-async-tests/http/src/lib.rs b/crates/misc/component-async-tests/http/src/lib.rs index db1110c9b5..8ffefb2895 100644 --- a/crates/misc/component-async-tests/http/src/lib.rs +++ b/crates/misc/component-async-tests/http/src/lib.rs @@ -217,7 +217,7 @@ impl wasi::http::types::HostFields for WasiHttpImpl { } impl wasi::http::types::HostBodyConcurrent for WasiHttp { - async fn new( + async fn new( accessor: &mut Accessor, stream: HostStream, ) -> wasmtime::Result> { @@ -230,7 +230,7 @@ impl wasi::http::types::HostBodyConcurrent for WasiHt }) } - async fn new_with_trailers( + async fn new_with_trailers( accessor: &mut Accessor, stream: HostStream, trailers: HostFuture>, @@ -246,7 +246,7 @@ impl wasi::http::types::HostBodyConcurrent for WasiHt // TODO: once access to the store is possible in a non-async context (similar to Accessor pattern) // we should convert this to a sync function that works w/ &mut self. - async fn finish( + async fn finish( accessor: &mut Accessor, this: Resource, ) -> wasmtime::Result>> { diff --git a/crates/wasi-common/src/lib.rs b/crates/wasi-common/src/lib.rs index a7574f2797..d1dd6771ec 100644 --- a/crates/wasi-common/src/lib.rs +++ b/crates/wasi-common/src/lib.rs @@ -117,6 +117,7 @@ macro_rules! define_wasi { where U: Send + crate::snapshots::preview_0::wasi_unstable::WasiUnstable + crate::snapshots::preview_1::wasi_snapshot_preview1::WasiSnapshotPreview1, + T: 'static, $($bounds)* { snapshots::preview_1::add_wasi_snapshot_preview1_to_linker(linker, get_cx)?; diff --git a/crates/wasi-common/tests/all/async_.rs b/crates/wasi-common/tests/all/async_.rs index 10b70b79c4..cd6407b7c5 100644 --- a/crates/wasi-common/tests/all/async_.rs +++ b/crates/wasi-common/tests/all/async_.rs @@ -1,6 +1,7 @@ use super::*; use test_programs_artifacts::*; use wasi_common::tokio::{add_to_linker, WasiCtxBuilder}; +use wasi_common::WasiCtx; foreach_preview1!(assert_test_exists); @@ -20,7 +21,7 @@ async fn run(path: &str, inherit_stdio: bool) -> Result<()> { let engine = test_programs_artifacts::engine(|config| { config.async_support(true); }); - let mut linker = Linker::new(&engine); + let mut linker = Linker::::new(&engine); add_to_linker(&mut linker, |cx| cx)?; // Create our wasi context. diff --git a/crates/wasi-http/src/p3/host/types.rs b/crates/wasi-http/src/p3/host/types.rs index 4ef430aa5e..97927f041e 100644 --- a/crates/wasi-http/src/p3/host/types.rs +++ b/crates/wasi-http/src/p3/host/types.rs @@ -739,7 +739,7 @@ impl HostRequestConcurrent for WasiHttp where T: WasiHttpView + 'static, { - async fn new( + async fn new( store: &mut Accessor, headers: Resource>, contents: Option>, @@ -1066,7 +1066,7 @@ impl HostResponseConcurrent for WasiHttp where T: WasiHttpView + 'static, { - async fn new( + async fn new( store: &mut Accessor, headers: Resource>, contents: Option>, diff --git a/crates/wasi-http/src/p3/proxy.rs b/crates/wasi-http/src/p3/proxy.rs index 171d7e8df5..554197c1a7 100644 --- a/crates/wasi-http/src/p3/proxy.rs +++ b/crates/wasi-http/src/p3/proxy.rs @@ -12,7 +12,7 @@ use crate::p3::{Request, Response}; impl Proxy { /// Call `handle` on [Proxy] getting a [Future] back. - pub fn handle, R: Into>( + pub fn handle, R: Into>( &self, mut store: S, req: R, diff --git a/crates/wasi/src/p3/filesystem/host.rs b/crates/wasi/src/p3/filesystem/host.rs index 093dd5ccea..437e3eb164 100644 --- a/crates/wasi/src/p3/filesystem/host.rs +++ b/crates/wasi/src/p3/filesystem/host.rs @@ -142,7 +142,7 @@ where }) } - async fn write_via_stream( + async fn write_via_stream( store: &mut Accessor, fd: Resource, data: HostStream, @@ -191,7 +191,7 @@ where } } - async fn append_via_stream( + async fn append_via_stream( store: &mut Accessor, fd: Resource, data: HostStream, diff --git a/crates/wasi/src/p3/sockets/host/types/tcp.rs b/crates/wasi/src/p3/sockets/host/types/tcp.rs index 57120115ed..4dcf6ee99f 100644 --- a/crates/wasi/src/p3/sockets/host/types/tcp.rs +++ b/crates/wasi/src/p3/sockets/host/types/tcp.rs @@ -372,7 +372,7 @@ where } } - async fn send( + async fn send( store: &mut Accessor, socket: Resource, data: HostStream, diff --git a/crates/wasi/src/preview0.rs b/crates/wasi/src/preview0.rs index b67d5fb3e0..44344889c8 100644 --- a/crates/wasi/src/preview0.rs +++ b/crates/wasi/src/preview0.rs @@ -9,14 +9,14 @@ use crate::preview1::wasi_snapshot_preview1::WasiSnapshotPreview1 as Snapshot1; use crate::preview1::WasiP1Ctx; use wiggle::{GuestError, GuestMemory, GuestPtr}; -pub fn add_to_linker_async( +pub fn add_to_linker_async( linker: &mut wasmtime::Linker, f: impl Fn(&mut T) -> &mut WasiP1Ctx + Copy + Send + Sync + 'static, ) -> anyhow::Result<()> { wasi_unstable::add_to_linker(linker, f) } -pub fn add_to_linker_sync( +pub fn add_to_linker_sync( linker: &mut wasmtime::Linker, f: impl Fn(&mut T) -> &mut WasiP1Ctx + Copy + Send + Sync + 'static, ) -> anyhow::Result<()> { diff --git a/crates/wasi/src/preview1.rs b/crates/wasi/src/preview1.rs index 3285ff45b2..e64a28dd58 100644 --- a/crates/wasi/src/preview1.rs +++ b/crates/wasi/src/preview1.rs @@ -739,7 +739,7 @@ enum FdWrite { /// Ok(()) /// } /// ``` -pub fn add_to_linker_async( +pub fn add_to_linker_async( linker: &mut wasmtime::Linker, f: impl Fn(&mut T) -> &mut WasiP1Ctx + Copy + Send + Sync + 'static, ) -> anyhow::Result<()> { @@ -813,7 +813,7 @@ pub fn add_to_linker_async( /// Ok(()) /// } /// ``` -pub fn add_to_linker_sync( +pub fn add_to_linker_sync( linker: &mut wasmtime::Linker, f: impl Fn(&mut T) -> &mut WasiP1Ctx + Copy + Send + Sync + 'static, ) -> anyhow::Result<()> { diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs index 08b3fb31b3..259dd1695b 100644 --- a/crates/wasmtime/src/runtime/component/concurrent.rs +++ b/crates/wasmtime/src/runtime/component/concurrent.rs @@ -4,7 +4,7 @@ use { func::{self, Func, Options}, HasData, HasSelf, Instance, }, - store::{StoreInner, StoreOpaque}, + store::{StoreInner, StoreOpaque, StoreToken}, vm::{ component::{CallContext, ComponentInstance, InstanceFlags, ResourceTables}, mpk::{self, ProtectionMask}, @@ -240,8 +240,7 @@ where /// - `instance`: used to access the `Instance` to which this `Accessor` /// (and the future which closes over it) belongs /// - /// SAFETY: This relies on `get` either returning a pair of pointers such - /// that the first is a valid `*mut U` and the second is a `*mut dyn VMStore` + /// SAFETY: This relies on `get` either returning a valid `*mut dyn VMStore` /// whose data is of type `T` _or_ panicking if it is called outside its /// intended scope. See the comment in `Access::get` for further details. #[doc(hidden)] @@ -295,7 +294,10 @@ where /// `stream` or `future` must run after the function returns. /// /// The returned [`AbortHandle`] may be used to cancel the task. - pub fn spawn(&mut self, task: impl AccessorTask>) -> AbortHandle { + pub fn spawn(&mut self, task: impl AccessorTask>) -> AbortHandle + where + T: 'static, + { let mut accessor = Self { get: self.get.clone(), get_data: self.get_data, @@ -303,25 +305,9 @@ where instance: self.instance, _phantom: PhantomData, }; - let future = Arc::new(Mutex::new(AbortWrapper::Unpolled(unsafe { - // This `transmute` is to avoid requiring a `U: 'static` bound, - // which should be unnecessary. - // - // SAFETY: We don't actually store a value of type `U` in the - // `Accessor` we're `move`ing into the `async` block; access to a - // `U` is brokered via `Accessor::with` by way of a thread-local - // variable in `wasmtime-wit-bindgen`-generated code or the - // `poll_with_state` function in this module. Furthermore, - // `AccessorTask` implementations are required to be `'static`, so - // no lifetime issues there. We have no way to explain any of that - // to the compiler, though, so we resort to a transmute here. - // - // See the comment in `Access::get` for further details. - mem::transmute::< - Pin> + Send>>, - Pin> + Send + 'static>>, - >(Box::pin(async move { task.run(&mut accessor).await })) - }))); + let future = Arc::new(Mutex::new(AbortWrapper::Unpolled(Box::pin(async move { + task.run(&mut accessor).await + })))); let handle = AbortHandle::new(future.clone()); (self.spawn)(future); handle @@ -422,9 +408,91 @@ struct State { spawned: Vec, } +/// Thread-local state for making the store and component instance available to +/// futures polled as part of that instance's event loop. +/// +/// This allows us to safely give those futures access to the store and +/// component instance between (but not across) `await` points, as well as +/// assert that any future which _must_ be polled as part of a specific +/// instance's event loop is indeed being polled that way. +#[derive(Copy, Clone)] +enum InstanceThreadLocalState { + /// No instance's event loop is currently polling a future. + None, + /// An instance's event loop is currently polling a future, but the store + /// and instance references have been temporarily taken out of the thread + /// local state. + Polling, + /// The specified instance's event loop is currently polling a future, and + /// the store and instance references may be accessed using + /// the `with_local_instance` function. + /// + /// In this case, the store and instance are in a "detached" state, meaning + /// they can be mutably referenced without either one aliasing the other. + Detached { + instance: SendSyncPtr, + store: VMStoreRawPtr, + }, + /// The specified instance's event loop is currently polling a future, and + /// the instance handle is available via the `instance` field. + /// + /// In this case, the store and instance are in an "attached" state, meaning + /// the instance state may only be retrieved by indexing into the + /// `StoreData`. + Attached { instance: Instance }, +} + +impl fmt::Debug for InstanceThreadLocalState { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct(match self { + Self::None => "None", + Self::Polling => "Polling", + Self::Detached { .. } => "Detached", + Self::Attached { .. } => "Attached", + }) + .finish() + } +} + thread_local! { static STATE: RefCell> = RefCell::new(None); - static INSTANCE: Cell<*mut ComponentInstance> = Cell::new(ptr::null_mut()); + static INSTANCE_STATE: Cell = Cell::new(InstanceThreadLocalState::None); +} + +/// Temporarily take exclusive access to the store and component instance state +/// from the thread-local state set when the instance's event loop polls a +/// future, passing them both to the specified function and returning the +/// result. +fn with_local_instance(fun: impl FnOnce(&mut dyn VMStore, &mut ComponentInstance) -> R) -> R { + let state = ResetInstanceThreadLocalState( + INSTANCE_STATE.with(|v| v.replace(InstanceThreadLocalState::Polling)), + ); + + let InstanceThreadLocalState::Detached { instance, store } = state.0 else { + unreachable!("expected `Detached`; got `{:?}`", state.0) + }; + let (store, instance) = unsafe { (&mut *store.0.as_ptr(), &mut *instance.as_ptr()) }; + fun(store, instance) +} + +/// Poll the specified future with the thread-local instance state pointing to +/// the specified store and instance. +fn poll_with_local_instance( + store: &mut dyn VMStore, + instance: &mut ComponentInstance, + future: &mut Pin<&mut F>, + cx: &mut Context, +) -> Poll { + let state = ResetInstanceThreadLocalState(INSTANCE_STATE.with(|v| { + v.replace(InstanceThreadLocalState::Detached { + instance: SendSyncPtr::new(instance.into()), + store: VMStoreRawPtr(store.into()), + }) + })); + + assert!(matches!(state.0, InstanceThreadLocalState::None)); + + future.as_mut().poll(cx) } struct ResetState(Option); @@ -437,11 +505,11 @@ impl Drop for ResetState { } } -struct ResetInstance(Option>); +struct ResetInstanceThreadLocalState(InstanceThreadLocalState); -impl Drop for ResetInstance { +impl Drop for ResetInstanceThreadLocalState { fn drop(&mut self) { - INSTANCE.with(|v| v.set(self.0.map(|v| v.as_ptr()).unwrap_or_else(ptr::null_mut))) + INSTANCE_STATE.with(|v| v.set(self.0)) } } @@ -455,57 +523,54 @@ fn spawn_task(task: Spawned) { STATE.with(|v| v.borrow_mut().as_mut().unwrap().spawned.push(task)); } -// SAFETY: `store` must be a valid `*mut dyn VMStore` with a data type of `T`, -// and `instance` must be a valid `*mut ComponentInstance`. -// -// Note that we must smuggle these pointers in as `VMStoreRawPtr` and -// `SendSyncPtr`, respectively, to allow this function to be -// called within a future that is `Send`. This is sound because -// `ComponentInstance::poll_until` is the only place those futures are polled, -// that function has exclusive access to both the store and the -// `ComponentInstance`. -unsafe fn poll_with_state( - store: VMStoreRawPtr, - instance: SendSyncPtr, +/// Poll the specified future using the store and instance references borrowed +/// using `with_local_instance`. +/// +/// This will set the `STATE` thread-local variable to make the store available +/// to any `Accessor`s referenced by the future. Additionally, it will spawn +/// any background tasks which may accumulate in `State::spawned` while the +/// future is being polled. +fn poll_with_state( + token: StoreToken, cx: &mut Context, future: Pin<&mut F>, ) -> Poll { - let (result, spawned) = { - let old_state = STATE.with(|v| { - v.replace(Some(State { - store: store.0.as_ptr().cast(), - spawned: Vec::new(), - })) + with_local_instance(|store, instance| { + let store_ptr = (store as *mut dyn VMStore).cast(); + let mut store_cx = token.as_context_mut(store); + + let (result, spawned) = store_cx.with_attached_instance(instance, |_, _| { + let old_state = STATE.with(|v| { + v.replace(Some(State { + store: store_ptr, + spawned: Vec::new(), + })) + }); + let _reset_state = ResetState(old_state); + (future.poll(cx), STATE.with(|v| v.take()).unwrap().spawned) }); - let _reset_state = ResetState(old_state); - let old_instance = INSTANCE.with(|v| v.replace(instance.as_ptr())); - let _reset_instance = ResetInstance(NonNull::new(old_instance).map(SendSyncPtr::new)); - (future.poll(cx), STATE.with(|v| v.take()).unwrap().spawned) - }; - // SAFETY: Per the function precondition, `instance` must be a valid `*mut - // ComponentInstance` - let instance_ref = unsafe { &mut *instance.as_ptr() }; - for spawned in spawned { - instance_ref.spawn(future::poll_fn(move |cx| { - let mut spawned = spawned.try_lock().unwrap(); - let inner = mem::replace(DerefMut::deref_mut(&mut spawned), AbortWrapper::Aborted); - if let AbortWrapper::Unpolled(mut future) | AbortWrapper::Polled { mut future, .. } = - inner - { - let result = poll_with_state::(store, instance, cx, future.as_mut()); - *DerefMut::deref_mut(&mut spawned) = AbortWrapper::Polled { - future, - waker: cx.waker().clone(), - }; - result - } else { - Poll::Ready(Ok(())) - } - })) - } + for spawned in spawned { + instance.spawn(future::poll_fn(move |cx| { + let mut spawned = spawned.try_lock().unwrap(); + let inner = mem::replace(DerefMut::deref_mut(&mut spawned), AbortWrapper::Aborted); + if let AbortWrapper::Unpolled(mut future) + | AbortWrapper::Polled { mut future, .. } = inner + { + let result = poll_with_state::(token, cx, future.as_mut()); + *DerefMut::deref_mut(&mut spawned) = AbortWrapper::Polled { + future, + waker: cx.waker().clone(), + }; + result + } else { + Poll::Ready(Ok(())) + } + })) + } - result + result + }) } /// Represents the state of a waitable handle. @@ -556,7 +621,7 @@ enum GuestCallKind { instance: RuntimeComponentInstanceIndex, set: Option>, }, - Start(Box Result<()> + Send + Sync>), + Start(Box Result<()> + Send + Sync>), } impl fmt::Debug for GuestCallKind { @@ -620,6 +685,102 @@ impl fmt::Debug for WorkItem { } } +impl StoreContextMut<'_, T> { + /// Temporarily split the specified store and instance into a "detached" + /// state (i.e. clearing the pointers they have to each other) so that they + /// can both safely be exclusively referenced. + /// + /// This will take the specified instance out of the store, null out the + /// pointer in the instance which points back to the store, call the + /// specified function with exclusive references to both, and then reset + /// everything back to the way it was before returning a result. + /// + /// This is appropriate for use in code which needs safe, exclusive access + /// to both the store and the instance simultaneously. Note that you'll + /// need to temporarily re-attach the instance to the store using + /// `with_attached_instance` when calling guest code or calling + /// application-defined host functions, since they both expect the instance + /// to be in an "attached" state. + /// + /// See also `with_detached_instance_async` for async closures. + fn with_detached_instance( + &mut self, + instance: &Instance, + fun: impl FnOnce(StoreContextMut<'_, T>, &mut ComponentInstance) -> R, + ) -> R { + let _state = ResetInstanceThreadLocalState(INSTANCE_STATE.with(|v| match v.get() { + state @ (InstanceThreadLocalState::None | InstanceThreadLocalState::Polling) => state, + InstanceThreadLocalState::Attached { .. } => { + v.replace(InstanceThreadLocalState::Polling) + } + _ => unreachable!(), + })); + let ptr = self.0.hide_instance(*instance); + // SAFETY: We've taken the instance out of the store, so now we own + // it and can take an exclusive reference to it. + let reference = unsafe { &mut *ptr }; + reference.set_store(None); + let result = fun(self.as_context_mut(), reference); + reference.set_store(Some(VMStoreRawPtr(self.traitobj()))); + self.0.unhide_instance(*instance); + result + } + + /// Same as `with_detached_instance`, but for async closures. + async fn with_detached_instance_async( + &mut self, + instance: &Instance, + fun: impl AsyncFnOnce(StoreContextMut<'_, T>, &mut ComponentInstance) -> R, + ) -> R { + let _state = ResetInstanceThreadLocalState(INSTANCE_STATE.with(|v| match v.get() { + state @ (InstanceThreadLocalState::None | InstanceThreadLocalState::Polling) => state, + InstanceThreadLocalState::Attached { .. } => { + v.replace(InstanceThreadLocalState::Polling) + } + _ => unreachable!(), + })); + let ptr = self.0.hide_instance(*instance); + // SAFETY: We've taken the instance out of the store, so now we own + // it and can take an exclusive reference to it. + let reference = unsafe { &mut *ptr }; + reference.set_store(None); + let result = fun(self.as_context_mut(), reference).await; + reference.set_store(Some(VMStoreRawPtr(self.traitobj()))); + self.0.unhide_instance(*instance); + result + } + + /// Temporarily the operation performed by `with_detached_instance{_async}`. + /// See the docs for those functions for details. + pub(crate) fn with_attached_instance( + &mut self, + instance: &mut ComponentInstance, + fun: impl FnOnce(StoreContextMut<'_, T>, Option) -> R, + ) -> R { + let _state = ResetInstanceThreadLocalState(INSTANCE_STATE.with(|v| match v.get() { + state @ InstanceThreadLocalState::None => state, + state @ InstanceThreadLocalState::Polling => { + if let Some(handle) = instance.instance { + v.replace(InstanceThreadLocalState::Attached { instance: handle }) + } else { + state + } + } + _ => unreachable!(), + })); + if let Some(handle) = instance.instance { + self.0.unhide_instance(handle); + } + instance.set_store(Some(VMStoreRawPtr(self.traitobj()))); + let result = fun(self.as_context_mut(), instance.instance); + instance.set_store(None); + if let Some(handle) = instance.instance { + self.0.hide_instance(handle); + } + result + } +} + impl ComponentInstance { pub(crate) fn instance(&self) -> Option { self.instance @@ -727,40 +888,28 @@ impl ComponentInstance { &mut self.concurrent_state.guest_call } - fn maybe_push_call_context(&mut self, guest_task: TableId) -> Result<()> { + fn maybe_push_call_context( + &mut self, + store: &mut StoreOpaque, + guest_task: TableId, + ) -> Result<()> { let task = self.get_mut(guest_task)?; if task.lift_result.is_some() { log::trace!("push call context for {guest_task:?}"); let call_context = task.call_context.take().unwrap(); - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. Furthermore, - // this function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access to - // both the `ComponentInstance` and the store. - unsafe { &mut (*self.store()) } - .store_opaque_mut() - .component_resource_state() - .0 - .push(call_context); + store.component_resource_state().0.push(call_context); } Ok(()) } - fn maybe_pop_call_context(&mut self, guest_task: TableId) -> Result<()> { + fn maybe_pop_call_context( + &mut self, + store: &mut StoreOpaque, + guest_task: TableId, + ) -> Result<()> { if self.get_mut(guest_task)?.lift_result.is_some() { log::trace!("pop call context for {guest_task:?}"); - let call_context = Some( - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store. - // Furthermore, this function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access - // to both the `ComponentInstance` and the store. - unsafe { &mut (*self.store()) } - .component_resource_state() - .0 - .pop() - .unwrap(), - ); + let call_context = Some(store.component_resource_state().0.pop().unwrap()); self.get_mut(guest_task)?.call_context = call_context; } Ok(()) @@ -919,152 +1068,231 @@ impl ComponentInstance { /// Add the specified guest call to the `Self::high_priority` queue, to be /// started as soon as backpressure and/or reentrance rules allow. /// - /// SAFETY: `self` must belong to a store whose data type parameter is `T`, - /// and the caller must confer exclusive access to that store. Likewise, - /// when the closures queued by this function are run, the same rules apply - /// to their `&mut ComponentInstance` parameters. - // TODO: This should queue `impl UnsafeFnOnce` "closures" (where - // `UnsafeFnOnce` would need to be a trait we define ourselves, since - // there's no standard equivalent) rather than `impl FnOnce` closures. That - // would force the caller to use an unsafe block and (hopefully) uphold the - // contract we've described above. - unsafe fn queue_call( + /// SAFETY: The raw pointer arguments must be valid references to guest + /// functions (with the appropriate signatures) when the closures queued by + /// this function are called. + unsafe fn queue_call( &mut self, + mut store: StoreContextMut, guest_task: TableId, + callee: SendSyncPtr, + param_count: usize, + result_count: usize, + flags: Option, async_: bool, - call: impl FnOnce(&mut ComponentInstance) -> Result<[MaybeUninit; MAX_FLAT_PARAMS]> - + Send - + Sync - + 'static, callback: Option>, post_return: Option>, - result_count: usize, ) -> Result<()> { + /// Return a closure which will call the specified function in the scope + /// of the specified task. + /// + /// This will use `GuestTask::lower_params` to lower the parameters, but + /// will not lift the result; instead, it returns a + /// `[MaybeUninit; MAX_FLAT_PARAMS]` from which the result, if + /// any, may be lifted. Note that an async-lifted export will have + /// returned its result using the `task.return` intrinsic (or not + /// returned a result at all, in the case of `task.cancel`), in which + /// case the "result" of this call will either be a callback code or + /// nothing. + /// + /// SAFETY: `callee` must be a valid `*mut VMFuncRef` at the time when + /// the returned closure is called. + unsafe fn make_call( + store: StoreContextMut, + guest_task: TableId, + callee: SendSyncPtr, + param_count: usize, + result_count: usize, + flags: Option, + ) -> impl FnOnce( + &mut dyn VMStore, + &mut ComponentInstance, + ) -> Result<[MaybeUninit; MAX_FLAT_PARAMS]> + + Send + + Sync + + 'static + + use { + let token = StoreToken::new(store); + move |store: &mut dyn VMStore, instance: &mut ComponentInstance| { + let mut storage = [MaybeUninit::uninit(); MAX_FLAT_PARAMS]; + let lower = instance.get_mut(guest_task)?.lower_params.take().unwrap(); + + lower(store, instance, &mut storage[..param_count])?; + + let mut store = token.as_context_mut(store); + + // SAFETY: Per the contract documented in `make_call's` + // documentation, `callee` must be a valid pointer. + store.with_attached_instance(instance, |mut store, _| unsafe { + if let Some(mut flags) = flags { + flags.set_may_enter(false); + } + crate::Func::call_unchecked_raw( + &mut store, + callee.as_non_null(), + NonNull::new( + &mut storage[..param_count.max(result_count)] + as *mut [MaybeUninit] as _, + ) + .unwrap(), + )?; + if let Some(mut flags) = flags { + flags.set_may_enter(true); + } + Ok::<_, anyhow::Error>(()) + })?; + + Ok(storage) + } + } + + // SAFETY: Per the contract described in this function documentation, + // the `callee` pointer which `call` closes over must be valid when + // called by the closure we queue below. + let call = unsafe { + make_call( + store.as_context_mut(), + guest_task, + callee, + param_count, + result_count, + flags, + ) + }; + let callee_instance = self.get(guest_task)?.instance; let fun = if callback.is_some() { assert!(async_); - Box::new(move |instance: &mut ComponentInstance| { - let old_task = instance.guest_task().replace(guest_task); - log::trace!( - "stackless call: replaced {old_task:?} with {guest_task:?} as current task" - ); + Box::new( + move |store: &mut dyn VMStore, instance: &mut ComponentInstance| { + let old_task = instance.guest_task().replace(guest_task); + log::trace!( + "stackless call: replaced {old_task:?} with {guest_task:?} as current task" + ); - instance.maybe_push_call_context(guest_task)?; + instance.maybe_push_call_context(store.store_opaque_mut(), guest_task)?; - instance.enter_instance(callee_instance); + instance.enter_instance(callee_instance); - // SAFETY: See the documentation for `make_call` to review the - // contract we must uphold for `call` here. - // - // Per the contract described in the `queue_call` documentation, - // we can rely on exclusive access to the store, whose data type - // parameter is `T`. - let storage = call(instance)?; + // SAFETY: See the documentation for `make_call` to review the + // contract we must uphold for `call` here. + // + // Per the contract described in the `queue_call` + // documentation, the `callee` pointer which `call` closes + // over must be valid. + let storage = call(store, instance)?; - instance.exit_instance(callee_instance)?; + instance.exit_instance(callee_instance)?; - instance.maybe_pop_call_context(guest_task)?; + instance.maybe_pop_call_context(store.store_opaque_mut(), guest_task)?; - *instance.guest_task() = old_task; - log::trace!("stackless call: restored {old_task:?} as current task"); + *instance.guest_task() = old_task; + log::trace!("stackless call: restored {old_task:?} as current task"); - // SAFETY: `wasmparser` will have validated that the callback - // function returns a `i32` result. - let code = unsafe { storage[0].assume_init() }.get_i32() as u32; + // SAFETY: `wasmparser` will have validated that the callback + // function returns a `i32` result. + let code = unsafe { storage[0].assume_init() }.get_i32() as u32; - instance.handle_callback_code( - guest_task, - callee_instance, - code, - Event::Subtask { - status: Status::Started, - }, - )?; + instance.handle_callback_code( + guest_task, + callee_instance, + code, + Event::Subtask { + status: Status::Started, + }, + )?; - Ok(()) - }) as Box Result<()> + Send + Sync> + Ok(()) + }, + ) + as Box< + dyn FnOnce(&mut dyn VMStore, &mut ComponentInstance) -> Result<()> + + Send + + Sync, + > } else { - Box::new(move |instance: &mut ComponentInstance| { - let old_task = instance.guest_task().replace(guest_task); - log::trace!( - "stackful call: replaced {old_task:?} with {guest_task:?} as current task", - ); + let token = StoreToken::new(store); + Box::new( + move |store: &mut dyn VMStore, instance: &mut ComponentInstance| { + let old_task = instance.guest_task().replace(guest_task); + log::trace!( + "stackful call: replaced {old_task:?} with {guest_task:?} as current task", + ); - let mut flags = instance.instance_flags(callee_instance); + let mut flags = instance.instance_flags(callee_instance); - instance.maybe_push_call_context(guest_task)?; + instance.maybe_push_call_context(store.store_opaque_mut(), guest_task)?; - if !async_ { - instance.enter_instance(callee_instance); - } + if !async_ { + instance.enter_instance(callee_instance); + } - // SAFETY: Per the contract described in the `queue_call` - // documentation, we can rely on exclusive access to the store, - // whose data type parameter is `T`. - let storage = call(instance)?; + // SAFETY: See the documentation for `make_call` to review the + // contract we must uphold for `call` here. + // + // Per the contract described in the `queue_call` + // documentation, the `callee` pointer which `call` closes + // over must be valid. + let storage = call(store, instance)?; - if async_ { - if instance.get(guest_task)?.lift_result.is_some() { - return Err(anyhow!(crate::Trap::NoAsyncResult)); - } - } else { - instance.exit_instance(callee_instance)?; + if async_ { + if instance.get(guest_task)?.lift_result.is_some() { + return Err(anyhow!(crate::Trap::NoAsyncResult)); + } + } else { + instance.exit_instance(callee_instance)?; - let lift = instance.get_mut(guest_task)?.lift_result.take().unwrap(); + let lift = instance.get_mut(guest_task)?.lift_result.take().unwrap(); - assert!(instance.get(guest_task)?.result.is_none()); + assert!(instance.get(guest_task)?.result.is_none()); - // SAFETY: `result_count` represents the number of core Wasm - // results returned, per `wasmparser`. - let result = (lift.lift)(instance, unsafe { - mem::transmute::<&[MaybeUninit], &[ValRaw]>( - &storage[..result_count], - ) - })?; + // SAFETY: `result_count` represents the number of core Wasm + // results returned, per `wasmparser`. + let result = (lift.lift)(store, instance, unsafe { + mem::transmute::<&[MaybeUninit], &[ValRaw]>( + &storage[..result_count], + ) + })?; - unsafe { flags.set_needs_post_return(false) } + unsafe { flags.set_needs_post_return(false) } - if let Some(func) = post_return { - let arg = match result_count { - 0 => ValRaw::i32(0), - // SAFETY: `result_count` represents the number of - // core Wasm results returned, per `wasmparser`. - 1 => unsafe { storage[0].assume_init() }, - _ => unreachable!(), - }; + if let Some(func) = post_return { + let arg = match result_count { + 0 => ValRaw::i32(0), + // SAFETY: `result_count` represents the number of + // core Wasm results returned, per `wasmparser`. + 1 => unsafe { storage[0].assume_init() }, + _ => unreachable!(), + }; - // SAFETY: Per the contract described in the - // `queue_call` documentation, we can rely on exclusive - // access to the store, whose data type parameter is - // `T`. - let mut store = - unsafe { StoreContextMut::(&mut *instance.store().cast()) }; - - // SAFETY: `func` is a valid `*mut VMFuncRef` from - // either `wasmtime-cranelift`-generated fused adapter - // code or `component::Options`. Per `wasmparser` - // post-return signature validation, we know it takes a - // single parameter. - unsafe { - crate::Func::call_unchecked_raw( - &mut store, - func.as_non_null(), - NonNull::new(ptr::slice_from_raw_parts(&arg, 1).cast_mut()) - .unwrap(), - )?; + let mut store = token.as_context_mut(store); + + // SAFETY: `func` is a valid `*mut VMFuncRef` from + // either `wasmtime-cranelift`-generated fused adapter + // code or `component::Options`. Per `wasmparser` + // post-return signature validation, we know it takes a + // single parameter. + store.with_attached_instance(instance, |mut store, _| unsafe { + crate::Func::call_unchecked_raw( + &mut store, + func.as_non_null(), + NonNull::new(ptr::slice_from_raw_parts(&arg, 1).cast_mut()) + .unwrap(), + ) + })?; } - } - unsafe { flags.set_may_enter(true) } + unsafe { flags.set_may_enter(true) } - instance.task_complete(guest_task, result, Status::Returned)?; - } + instance.task_complete(store, guest_task, result, Status::Returned)?; + } - instance.maybe_pop_call_context(guest_task)?; + instance.maybe_pop_call_context(store.store_opaque_mut(), guest_task)?; - Ok(()) - }) + Ok(()) + }, + ) }; self.push_high_priority(WorkItem::GuestCall(GuestCall { @@ -1078,11 +1306,13 @@ impl ComponentInstance { /// Prepare (but do not start) a guest->guest call. /// /// SAFETY: All the pointer arguments must be valid pointers to guest - /// entities. In addition the caller must confer exclusive access to the - /// store to which the passed `&mut ComponentInstance` belongs, which must - /// have a data type parameter of `T`. - unsafe fn prepare_call( + /// entities (and with the expected signatures for the function references + /// -- see + /// `wasmtime_environ::fact::trampoline::Compiler::compile_async_start_adapter` + /// for details). + unsafe fn prepare_call( &mut self, + store: StoreContextMut, start: *mut VMFuncRef, return_: *mut VMFuncRef, caller_instance: RuntimeComponentInstanceIndex, @@ -1115,23 +1345,11 @@ impl ComponentInstance { let start = SendSyncPtr::new(NonNull::new(start).unwrap()); let return_ = SendSyncPtr::new(NonNull::new(return_).unwrap()); let old_task = self.guest_task().take(); + let token = StoreToken::new(store); let new_task = GuestTask::new( self, - Box::new(move |instance, dst| { - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store. - // Furthermore, this closure is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access - // to both the `ComponentInstance` and the store. - // - // In addition, the store's data type is known to be `T` because - // this closure will have been called with the same - // `ComponentInstance` that was passed to the outer - // `prepare_call` scope. See - // `ComponentInstance::{poll_until,handle_work_item,handle_guest_call}`, - // where we pop the work item containing this closure and pass - // it the same `ComponentInstance`. - let mut store = unsafe { StoreContextMut::(&mut *instance.store().cast()) }; + Box::new(move |store, instance, dst| { + let mut store = token.as_context_mut(store); assert!(dst.len() <= MAX_FLAT_PARAMS); let mut src = [MaybeUninit::uninit(); MAX_FLAT_PARAMS]; let count = match caller_info { @@ -1154,7 +1372,7 @@ impl ComponentInstance { // `wasmtime_environ::fact::trampoline::Compiler::compile_async_start_adapter` // for details) we know it takes count parameters and returns // `dst.len()` results. - unsafe { + store.with_attached_instance(instance, |mut store, _| unsafe { crate::Func::call_unchecked_raw( &mut store, start.as_non_null(), @@ -1162,8 +1380,8 @@ impl ComponentInstance { &mut src[..count.max(dst.len())] as *mut [MaybeUninit] as _, ) .unwrap(), - )?; - } + ) + })?; dst.copy_from_slice(&src[..dst.len()]); let task = instance.guest_task().unwrap(); Waitable::Guest(task).set_event( @@ -1175,10 +1393,10 @@ impl ComponentInstance { Ok(()) }), LiftResult { - lift: Box::new(move |instance, src| { + lift: Box::new(move |store, instance, src| { // SAFETY: See comment in closure passed as `lower_params` // parameter above. - let mut store = unsafe { StoreContextMut::(&mut *instance.store().cast()) }; + let mut store = token.as_context_mut(store); let mut my_src = src.to_owned(); // TODO: use stack to avoid allocation? if let ResultInfo::Heap { results } = &result_info { my_src.push(ValRaw::u32(*results)); @@ -1189,13 +1407,13 @@ impl ComponentInstance { // `wasmtime_environ::fact::trampoline::Compiler::compile_async_return_adapter` // for details) we know it takes `src.len()` parameters and // returns up to 1 result. - unsafe { + store.with_attached_instance(instance, |mut store, _| unsafe { crate::Func::call_unchecked_raw( &mut store, return_.as_non_null(), my_src.as_mut_slice().into(), - )?; - } + ) + })?; let task = instance.guest_task().unwrap(); if sync_caller { instance.get_mut(task)?.sync_result = @@ -1239,28 +1457,18 @@ impl ComponentInstance { Ok(()) } - fn call_callback( + /// Call the specified callback function for an async-lifted export. + /// + /// SAFETY: `function` must be a valid reference to a guest function of the + /// correct signature for a callback. + unsafe fn call_callback( &mut self, + mut store: StoreContextMut, callee_instance: RuntimeComponentInstanceIndex, function: SendSyncPtr, event: Event, handle: u32, ) -> Result { - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. Furthermore, this - // function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access to both - // the `ComponentInstance` and the store. - // - // In addition, the store's data type is known to be `T` because this - // function will have been called with the same `ComponentInstance` that - // was in scope in `ComponentInstance::start_call` or `prepare_call` -- - // the two functions where this function is monomophized and stored as - // an `fn(..)` in `GuestTask::callback`. See - // `ComponentInstance::{poll_until,handle_work_item,handle_guest_call}`, - // where we pop the work item containing the pointer to this function - // and pass it the same `ComponentInstance`. - let mut store = unsafe { StoreContextMut::(&mut *self.store().cast()) }; let mut flags = self.instance_flags(callee_instance); let (ordinal, result) = event.parts(); @@ -1273,7 +1481,7 @@ impl ComponentInstance { // `wasmtime-cranelift`-generated fused adapter code or // `component::Options`. Per `wasmparser` callback signature // validation, we know it takes three parameters and returns one. - unsafe { + store.with_attached_instance(self, |mut store, _| unsafe { flags.set_may_enter(false); crate::Func::call_unchecked_raw( &mut store, @@ -1281,19 +1489,22 @@ impl ComponentInstance { params.as_mut_slice().into(), )?; flags.set_may_enter(true); - } + Ok::<_, anyhow::Error>(()) + })?; Ok(params[0].get_u32()) } /// Start a guest->guest call previously prepared using /// `Self::prepare_call`. /// - /// SAFETY: All the pointer arguments must be valid pointers to guest - /// entities. In addition the caller must confer exclusive access to the - /// store to which the passed `&mut ComponentInstance` belongs, which must - /// have a data type parameter of `T`. - unsafe fn start_call( + /// SAFETY: The `*mut VMFuncRef` arguments must be valid pointers to guest + /// functions with the appropriate signatures for the current guest task. + /// If this is a call to an async-lowered import, the actual call may be + /// deferred and run after this function returns, in which case the pointer + /// arguments must also be valid when the call happens. + unsafe fn start_call( &mut self, + mut store: StoreContextMut, callback: *mut VMFuncRef, post_return: *mut VMFuncRef, callee: *mut VMFuncRef, @@ -1312,10 +1523,22 @@ impl ComponentInstance { let task = self.get_mut(guest_task)?; if !callback.is_null() { - task.callback = Some(Callback { - function: SendSyncPtr::new(NonNull::new(callback).unwrap()), - caller: Self::call_callback::, - }); + let token = StoreToken::new(store.as_context_mut()); + let callback = SendSyncPtr::new(NonNull::new(callback).unwrap()); + task.callback = Some(Box::new( + move |store, instance, runtime_instance, event, handle| { + let store = token.as_context_mut(store); + unsafe { + instance.call_callback::( + store, + runtime_instance, + callback, + event, + handle, + ) + } + }, + )); } let Caller::Guest { @@ -1332,37 +1555,30 @@ impl ComponentInstance { let callee_instance = task.instance; - // SAFETY: Per the contract described in this function's documentation, - // we can rely on exclusive access to the store, whose data type - // parameter is `T`. - unsafe { - let call = make_call::( - guest_task, - callee, - param_count, - result_count, - if callback.is_null() { - None - } else { - Some(self.instance_flags(callee_instance)) - }, - ); - - self.queue_call::( - guest_task, - (flags & EXIT_FLAG_ASYNC_CALLEE) != 0, - call, - NonNull::new(callback).map(SendSyncPtr::new), - NonNull::new(post_return).map(SendSyncPtr::new), - result_count, - )?; - } + self.queue_call( + store.as_context_mut(), + guest_task, + callee, + param_count, + result_count, + if callback.is_null() { + None + } else { + Some(self.instance_flags(callee_instance)) + }, + (flags & EXIT_FLAG_ASYNC_CALLEE) != 0, + NonNull::new(callback).map(SendSyncPtr::new), + NonNull::new(post_return).map(SendSyncPtr::new), + )?; let set = self.get_mut(caller)?.sync_call_set; Waitable::Guest(guest_task).join(self, Some(set))?; let (status, waitable) = loop { - self.suspend(SuspendReason::Waiting { set, task: caller })?; + self.suspend( + store.0.traitobj_mut(), + SuspendReason::Waiting { set, task: caller }, + )?; let event = Waitable::Guest(guest_task).take_event(self)?; let Some(Event::Subtask { status }) = event else { @@ -1402,10 +1618,9 @@ impl ComponentInstance { Ok(status.pack(waitable)) } - /// SAFETY: The returned future must only be polled (directly or - /// transitively) using `ComponentInstance::poll_until`. - pub(crate) unsafe fn wrap_call( + pub(crate) fn wrap_call( &mut self, + store: StoreContextMut, closure: Arc, params: P, ) -> Pin> + Send + 'static>> @@ -1427,44 +1642,21 @@ impl ComponentInstance { // the returned future is polled, respectively. let mut accessor = unsafe { Accessor::new(get_store, |x| x, spawn_task, self.instance()) }; let mut future = Box::pin(async move { closure(&mut accessor, params).await }); - let store = VMStoreRawPtr(NonNull::new(self.store()).unwrap()); - let instance = SendSyncPtr::new(NonNull::new(self).unwrap()); - // SAFETY: `poll_with_state` will populate and reset the thread-local - // state as described above. - // - // This is sound because `ComponentInstance::poll_until` is the only - // place we will poll this future (see the doc comment on this - // function), and it has exclusive access to the store and - // `ComponentInstance` when doing so. - let future = future::poll_fn(move |cx| unsafe { - poll_with_state::(store, instance, cx, future.as_mut()) - }); - - // This `transmute` is to avoid requiring a `T: 'static` bound, which - // should be unnecessary. - // - // SAFETY: We don't store a value of type `T` in the above future, and - // access to the data of type `T` will only happen via the thread-local - // state described above. - unsafe { - mem::transmute::< - Pin> + Send>>, - Pin> + Send + 'static>>, - >(Box::pin(future)) - } + let token = StoreToken::new(store); + Box::pin(future::poll_fn(move |cx| { + poll_with_state(token, cx, future.as_mut()) + })) } /// Poll the specified future once, and if it returns `Pending`, add it to /// the set of futures to be polled as part of this instance's event loop /// until it completes. - /// - /// SAFETY: `self` must belong to a store whose data type parameter is `T`, - /// and the caller must confer exclusive access to that store. - pub(crate) unsafe fn first_poll( + pub(crate) fn first_poll( &mut self, + mut store: StoreContextMut, future: impl Future> + Send + 'static, caller_instance: RuntimeComponentInstanceIndex, - lower: impl FnOnce(StoreContextMut, R) -> Result<()> + Send + 'static, + lower: impl FnOnce(StoreContextMut, &mut ComponentInstance, R) -> Result<()> + Send + 'static, ) -> Result> { let caller = self.guest_task().unwrap(); let wrapped = Arc::new(Mutex::new(AbortWrapper::Unpolled(Box::pin(future)))); @@ -1472,48 +1664,9 @@ impl ComponentInstance { caller_instance, Some(AbortHandle::new(wrapped.clone())), ))?; - - // Here we wrap the future in a `future::poll_fn` to ensure that we restore - // and save the `CallContext` for this task before and after polling it, - // respectively. This involves unsafe shenanigans in order to smuggle the - // store pointer into the wrapping future, alas. - // - // SAFETY: We'll only poll the future in (at most) two places: here in - // this function where we have exclusive access to the store, and (if - // necessary) in `ComponentInstance::poll_until`, where we will again - // have exclusive access to the same store. - // - // Note that we also wrap the future in order to provide cancellation - // support via `AbortWrapper`. - - fn maybe_push( - store: VMStoreRawPtr, - call_context: &mut Option, - task: TableId, - ) { - // SAFETY: See SAFETY comment in above in `first_poll`, as well as - // the precondition documented for that function. - let store = unsafe { StoreContextMut::(&mut *store.0.as_ptr().cast()) }; - if let Some(call_context) = call_context.take() { - log::trace!("push call context for {task:?}"); - store.0.component_resource_state().0.push(call_context); - } - } - - fn pop( - store: VMStoreRawPtr, - call_context: &mut Option, - task: TableId, - ) { - log::trace!("pop call context for {task:?}"); - // SAFETY: See SAFETY comment in above in `first_poll`, as well as - // the precondition documented for that function. - let store = unsafe { StoreContextMut::(&mut *store.0.as_ptr().cast()) }; - *call_context = Some(store.0.component_resource_state().0.pop().unwrap()); - } + let token = StoreToken::new(store.as_context_mut()); let future = future::poll_fn({ - let store = VMStoreRawPtr(NonNull::new(self.store()).unwrap()); let mut call_context = None; move |cx| { let mut wrapped = wrapped.try_lock().unwrap(); @@ -1522,7 +1675,17 @@ impl ComponentInstance { if let AbortWrapper::Unpolled(mut future) | AbortWrapper::Polled { mut future, .. } = inner { - maybe_push::(store, &mut call_context, task); + with_local_instance(|store, _| { + if let Some(call_context) = call_context.take() { + log::trace!("push call context for {task:?}"); + token + .as_context_mut(store) + .0 + .component_resource_state() + .0 + .push(call_context); + } + }); let result = future.as_mut().poll(cx); @@ -1534,7 +1697,18 @@ impl ComponentInstance { match result { Poll::Ready(output) => Poll::Ready(Some(output)), Poll::Pending => { - pop::(store, &mut call_context, task); + with_local_instance(|store, _| { + log::trace!("pop call context for {task:?}"); + call_context = Some( + token + .as_context_mut(store) + .0 + .component_resource_state() + .0 + .pop() + .unwrap(), + ); + }); Poll::Pending } } @@ -1545,13 +1719,12 @@ impl ComponentInstance { }); log::trace!("new host task child of {caller:?}: {task:?}"); + let token = StoreToken::new(store.as_context_mut()); let mut future = Box::pin(future.map(move |result| { if let Some(result) = result { - HostTaskOutput::Function(Box::new(move |instance| { - // SAFETY: See SAFETY comment in above in `first_poll`, as - // well as the precondition documented for that function. - let store = unsafe { StoreContextMut(&mut *instance.store().cast()) }; - lower(store, result?)?; + HostTaskOutput::Function(Box::new(move |store, instance| { + let store = token.as_context_mut(store); + lower(store, instance, result?)?; instance.get_mut(task)?.abort_handle.take(); Waitable::Host(task).set_event( instance, @@ -1568,30 +1741,35 @@ impl ComponentInstance { } })) as HostTaskFuture; - Ok( - match future - .as_mut() - .poll(&mut Context::from_waker(&dummy_waker())) - { - Poll::Ready(output) => { - output.consume(self)?; - log::trace!("delete host task {task:?} (already ready)"); - self.delete(task)?; - None - } - Poll::Pending => { - self.push_future(future); - let handle = self.waitable_tables()[caller_instance] - .insert(task.rep(), WaitableState::HostTask)?; - log::trace!("assign {task:?} handle {handle} for {caller:?} instance {caller_instance:?}"); - Some(handle) - } - }, - ) + let poll = poll_with_local_instance( + store.0.traitobj_mut(), + self, + &mut future.as_mut(), + &mut Context::from_waker(&dummy_waker()), + ); + + Ok(match poll { + Poll::Ready(output) => { + output.consume(store.0.traitobj_mut(), self)?; + log::trace!("delete host task {task:?} (already ready)"); + self.delete(task)?; + None + } + Poll::Pending => { + self.push_future(future); + let handle = self.waitable_tables()[caller_instance] + .insert(task.rep(), WaitableState::HostTask)?; + log::trace!( + "assign {task:?} handle {handle} for {caller:?} instance {caller_instance:?}" + ); + Some(handle) + } + }) } pub(crate) fn poll_and_block( &mut self, + store: &mut dyn VMStore, future: impl Future> + Send + 'static, caller_instance: RuntimeComponentInstanceIndex, ) -> Result { @@ -1612,7 +1790,7 @@ impl ComponentInstance { log::trace!("new host task child of {caller:?}: {task:?}"); let mut future = Box::pin(future.map(move |result| { - HostTaskOutput::Function(Box::new(move |instance| { + HostTaskOutput::Function(Box::new(move |_, instance| { instance.get_mut(caller)?.result = Some(Box::new(result?) as _); Waitable::Host(task).set_event( @@ -1626,78 +1804,70 @@ impl ComponentInstance { })) })) as HostTaskFuture; - Ok( - match future - .as_mut() - .poll(&mut Context::from_waker(&dummy_waker())) - { - Poll::Ready(output) => { - output.consume(self)?; - log::trace!("delete host task {task:?} (already ready)"); - self.delete(task)?; - let result = *mem::replace(&mut self.get_mut(caller)?.result, old_result) - .unwrap() - .downcast() - .unwrap(); - result - } - Poll::Pending => { - self.push_future(future); + let poll = poll_with_local_instance( + store.traitobj_mut(), + self, + &mut future.as_mut(), + &mut Context::from_waker(&dummy_waker()), + ); - let set = self.get_mut(caller)?.sync_call_set; - Waitable::Host(task).join(self, Some(set))?; + Ok(match poll { + Poll::Ready(output) => { + output.consume(store, self)?; + log::trace!("delete host task {task:?} (already ready)"); + self.delete(task)?; + let result = *mem::replace(&mut self.get_mut(caller)?.result, old_result) + .unwrap() + .downcast() + .unwrap(); + result + } + Poll::Pending => { + self.push_future(future); - self.suspend(SuspendReason::Waiting { set, task: caller })?; + let set = self.get_mut(caller)?.sync_call_set; + Waitable::Host(task).join(self, Some(set))?; - let result = self.get_mut(caller)?.result.take().unwrap(); - self.get_mut(caller)?.result = old_result; - *result.downcast().unwrap() - } - }, - ) + self.suspend(store, SuspendReason::Waiting { set, task: caller })?; + + let result = self.get_mut(caller)?.result.take().unwrap(); + self.get_mut(caller)?.result = old_result; + *result.downcast().unwrap() + } + }) } - async fn poll_until( + async fn poll_until( &mut self, + store: StoreContextMut<'_, T>, future: impl Future + Send, ) -> Result { - fn poll_with( - instance: SendSyncPtr, - future: &mut Pin<&mut F>, - cx: &mut Context, - ) -> Poll { - let old = INSTANCE.with(|v| v.replace(instance.as_ptr())); - let _reset_instance = ResetInstance(NonNull::new(old).map(SendSyncPtr::new)); - future.as_mut().poll(cx) - } - - // Here we smuggle the `ComponentInstance` pointer into the future so we - // can use it while polling without upsetting the borrow checker given - // that we're also mutably borrowing `ConcurrentState::futures` to poll - // it. - // - // SAFETY: This is morally equivalent to a split borrow, since we are - // careful not to touch `ConcurrentState::futures` at any time while - // polling. See `ComponentInstance::push_future` which, explicitly - // defers touching `futures` by queuing a work item which we'll run only - // _after_ polling. - let instance = SendSyncPtr::new(NonNull::new(self).unwrap()); let mut future = pin!(future); loop { - let result = { - let mut next = pin!(self.concurrent_state.futures.get_mut().unwrap().next()); + // Take `ConcurrentState::futures` out of `self` so we can poll it + // while also safely giving any of the futures inside access to + // `self`. + let mut futures = self + .concurrent_state + .futures + .get_mut() + .unwrap() + .take() + .unwrap(); + let mut next = pin!(futures.next()); - future::poll_fn(|cx| { - if let Poll::Ready(value) = poll_with(instance, &mut future, cx) { - return Poll::Ready(Ok(Either::Left(value))); - } + let result = future::poll_fn(|cx| { + if let Poll::Ready(value) = + poll_with_local_instance(store.0.traitobj_mut(), self, &mut future, cx) + { + return Poll::Ready(Ok(Either::Left(value))); + } - let next = match poll_with(instance, &mut next, cx) { + let next = + match poll_with_local_instance(store.0.traitobj_mut(), self, &mut next, cx) { Poll::Ready(Some(output)) => { - // SAFETY: See SAFETY comment in outer scope above. - let me = unsafe { &mut *instance.as_ptr() }; - if let Err(e) = output.consume(me) { + if let Err(e) = output.consume(store.0.traitobj_mut(), self) { return Poll::Ready(Err(e)); } Poll::Ready(true) @@ -1706,60 +1876,63 @@ impl ComponentInstance { Poll::Pending => Poll::Pending, }; - // SAFETY: See SAFETY comment in outer scope above. - let me = unsafe { &mut *instance.as_ptr() }; - let ready = mem::take(&mut me.concurrent_state.high_priority); - let ready = if ready.is_empty() { - let ready = mem::take(&mut me.concurrent_state.low_priority); - if ready.is_empty() { - return match next { - Poll::Ready(true) => Poll::Ready(Ok(Either::Right(Vec::new()))), - // Here we return an error indicating we can't - // make further progress. The underlying - // assumption is that `future` depends on this - // component instance making such progress, and - // thus there's no point in continuing to poll - // it given we've run out of work to do. - // - // Note that we'd also reach this point if the - // host embedder passed e.g. a - // `std::future::Pending` to `Instance::run`, in - // which case we'd return a "deadlock" error - // even when any and all tasks have completed - // normally. However, that's not how - // `Instance::run` is intended (and documented) - // to be used, so it seems reasonable to lump - // that case in with "real" deadlocks. - // - // TODO: Once we've added host APIs for - // cancelling in-progress tasks, we can return - // some other, non-error value here, treating it - // as "normal" and giving the host embedder a - // chance to intervene by cancelling one or more - // tasks and/or starting new tasks capable of - // waking the existing ones. - Poll::Ready(false) => { - Poll::Ready(Err(anyhow!(crate::Trap::AsyncDeadlock))) - } - Poll::Pending => Poll::Pending, - }; - } else { - ready - } + let ready = mem::take(&mut self.concurrent_state.high_priority); + let ready = if ready.is_empty() { + let ready = mem::take(&mut self.concurrent_state.low_priority); + if ready.is_empty() { + return match next { + Poll::Ready(true) => Poll::Ready(Ok(Either::Right(Vec::new()))), + // Here we return an error indicating we can't make + // further progress. The underlying assumption is + // that `future` depends on this component instance + // making such progress, and thus there's no point + // in continuing to poll it given we've run out of + // work to do. + // + // Note that we'd also reach this point if the host + // embedder passed e.g. a `std::future::Pending` to + // `Instance::run`, in which case we'd return a + // "deadlock" error even when any and all tasks have + // completed normally. However, that's not how + // `Instance::run` is intended (and documented) to + // be used, so it seems reasonable to lump that case + // in with "real" deadlocks. + // + // TODO: Once we've added host APIs for cancelling + // in-progress tasks, we can return some other, + // non-error value here, treating it as "normal" and + // giving the host embedder a chance to intervene by + // cancelling one or more tasks and/or starting new + // tasks capable of waking the existing ones. + Poll::Ready(false) => { + Poll::Ready(Err(anyhow!(crate::Trap::AsyncDeadlock))) + } + Poll::Pending => Poll::Pending, + }; } else { ready - }; + } + } else { + ready + }; - Poll::Ready(Ok(Either::Right(ready))) - }) - .await - }; + Poll::Ready(Ok(Either::Right(ready))) + }) + .await; + + *self.concurrent_state.futures.get_mut().unwrap() = Some(futures); match result? { Either::Left(value) => break Ok(value), Either::Right(ready) => { for item in ready { - self.handle_work_item(item).await?; + // SAFETY: We have exclusive access to the store and may + // grant it to the `handle_work_item` future until it + // completes. + unsafe { + self.handle_work_item(VMStoreRawPtr(store.0.traitobj()), item) + .await + }?; } } } @@ -1812,19 +1985,17 @@ impl ComponentInstance { ) } - fn handle_guest_call(&mut self, call: GuestCall) -> Result<()> { + fn handle_guest_call(&mut self, store: &mut dyn VMStore, call: GuestCall) -> Result<()> { match call.kind { GuestCallKind::DeliverEvent { instance, set } => { let (event, waitable) = self.get_event(call.task, instance, set)?.unwrap(); let task = self.get_mut(call.task)?; - let callback = task.callback.unwrap(); let instance = task.instance; let handle = waitable.map(|(_, v)| v).unwrap_or(0); log::trace!( - "use callback to deliver event {event:?} to {:?} for {waitable:?}: {:?}", + "use callback to deliver event {event:?} to {:?} for {waitable:?}", call.task, - callback.function, ); let old_task = self.guest_task().replace(call.task); @@ -1833,15 +2004,19 @@ impl ComponentInstance { call.task ); - self.maybe_push_call_context(call.task)?; + self.maybe_push_call_context(store.store_opaque_mut(), call.task)?; self.enter_instance(instance); - let code = (callback.caller)(self, instance, callback.function, event, handle)?; + let callback = self.get_mut(call.task)?.callback.take().unwrap(); + + let code = callback(store, self, instance, event, handle)?; + + self.get_mut(call.task)?.callback = Some(callback); self.exit_instance(instance)?; - self.maybe_pop_call_context(call.task)?; + self.maybe_pop_call_context(store.store_opaque_mut(), call.task)?; self.handle_callback_code(call.task, instance, code, Event::None)?; @@ -1849,14 +2024,23 @@ impl ComponentInstance { log::trace!("GuestCallKind::DeliverEvent: restored {old_task:?} as current task"); } GuestCallKind::Start(fun) => { - fun(self)?; + fun(store, self)?; } } Ok(()) } - async fn resume_fiber(&mut self, fiber: StoreFiber<'static>) -> Result<()> { + /// Resume the specified fiber, giving it exclusive access to the specified + /// store. + /// + /// SAFETY: The caller must confer exclusive access to the store until the + /// returned future completes. + async unsafe fn resume_fiber( + &mut self, + store: VMStoreRawPtr, + fiber: StoreFiber<'static>, + ) -> Result<()> { let old_task = *self.guest_task(); log::trace!("resume_fiber: save current task {old_task:?}"); let guard_range = fiber.guard_range(); @@ -1867,21 +2051,12 @@ impl ComponentInstance { // // By the time the future returned by `poll_fn` completes, we'll have // exclusive access to it again. - // - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. Furthermore, this - // function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access to both - // the `ComponentInstance` and the store. + + // SAFETY: Per the documented contract for this function, we have + // exclusive access to the store. let fiber = unsafe { - poll_fn( - VMStoreRawPtr(NonNull::new(self.store()).unwrap()), - guard_range, - move |_, mut store| match resume_fiber( - fiber.as_mut().unwrap(), - store.take(), - Ok(()), - ) { + poll_fn(store, guard_range, move |_, mut store| { + match resume_fiber(fiber.as_mut().unwrap(), store.take(), Ok(())) { Ok(Ok((_, result))) => Ok(result.map(|()| None)), Ok(Err(store)) => { if store.is_some() { @@ -1891,8 +2066,8 @@ impl ComponentInstance { } } Err(error) => Ok(Err(error)), - }, - ) + } + }) } .await?; @@ -1922,7 +2097,15 @@ impl ComponentInstance { Ok(()) } - async fn handle_work_item(&mut self, item: WorkItem) -> Result<()> { + /// Handle the specified work item, possibly resuming a fiber if applicable. + /// + /// SAFETY: The caller must confer exclusive access to the store until the + /// returned future completes. + async unsafe fn handle_work_item( + &mut self, + store: VMStoreRawPtr, + item: WorkItem, + ) -> Result<()> { log::trace!("handle work item {item:?}"); match item { WorkItem::PushFuture(future) => { @@ -1930,14 +2113,20 @@ impl ComponentInstance { .futures .get_mut() .unwrap() + .as_mut() + .unwrap() .push(future.into_inner().unwrap()); } WorkItem::ResumeFiber(fiber) => { - self.resume_fiber(fiber).await?; + // SAFETY: Per the documented contract for this function, we have + // exclusive access to the store. + unsafe { self.resume_fiber(store, fiber).await }?; } WorkItem::GuestCall(call) => { if call.is_ready(self)? { - self.run_on_worker(call).await?; + // SAFETY: Per the documented contract for this function, we + // have exclusive access to the store. + unsafe { self.run_on_worker(store, call).await }?; } else { let task = self.get_mut(call.task)?; if !task.starting_sent { @@ -1985,7 +2174,11 @@ impl ComponentInstance { Ok(()) } - async fn run_on_worker(&mut self, call: GuestCall) -> Result<()> { + /// Execute the specified guest call on a worker fiber. + /// + /// SAFETY: The caller must confer exclusive access to the store until the + /// returned future completes. + async unsafe fn run_on_worker(&mut self, store: VMStoreRawPtr, call: GuestCall) -> Result<()> { let worker = if let Some(fiber) = self.worker().take() { fiber } else { @@ -1995,22 +2188,22 @@ impl ComponentInstance { // // SAFETY: We will only resume this fiber in either // `ComponentInstance::handle_work_item` or - // `ComponentInstnace::run_on_worker`, where we'll have exclusive + // `ComponentInstance::run_on_worker`, where we'll have exclusive // access to the same `ComponentInstance` and thus be able to grant // the same access to the fiber we're resuming. // // TODO: Consider adding `*mut ComponentInstance` parameters to // `StoreFiber`'s `suspend` and `resume` signatures to make this - // handoff more explicit. + // handoff explicit. let instance = self as *mut Self; unsafe { - make_fiber(self.store(), move |_| { + make_fiber(store, move |store| { let instance = &mut *instance; loop { let call = instance.guest_call().take().unwrap(); - instance.handle_guest_call(call)?; + instance.handle_guest_call(&mut *store, call)?; - instance.suspend(SuspendReason::NeedWork)?; + instance.suspend(&mut *store, SuspendReason::NeedWork)?; } })? } @@ -2019,10 +2212,12 @@ impl ComponentInstance { assert!(self.guest_call().is_none()); *self.guest_call() = Some(call); - self.resume_fiber(worker).await + // SAFETY: Per the documented contract for this function, we have + // exclusive access to the store. + unsafe { self.resume_fiber(store, worker).await } } - fn suspend(&mut self, reason: SuspendReason) -> Result<()> { + fn suspend(&mut self, store: &mut dyn VMStore, reason: SuspendReason) -> Result<()> { log::trace!("suspend fiber: {reason:?}"); let task = match &reason { @@ -2031,7 +2226,7 @@ impl ComponentInstance { }; let old_guest_task = if let Some(task) = task { - self.maybe_pop_call_context(task)?; + self.maybe_pop_call_context(store.store_opaque_mut(), task)?; *self.guest_task() } else { None @@ -2040,19 +2235,16 @@ impl ComponentInstance { assert!(self.suspend_reason().is_none()); *self.suspend_reason() = Some(reason); - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. In addition, this - // is only ever called from a fiber that belongs (via the - // `ComponentInstance`) to that store (and would in any case panic if - // called from outside any fiber). + let async_cx = AsyncCx::new(store.store_opaque_mut()); + // SAFETY: This is only ever called from a fiber that belongs to this + // store (and would in any case panic if called from outside any fiber). unsafe { - let async_cx = AsyncCx::new((*self.store()).store_opaque_mut()); - async_cx.suspend(Some(self.store()))?; + async_cx.suspend(Some(store))?; } if let Some(task) = task { *self.guest_task() = old_guest_task; - self.maybe_push_call_context(task)?; + self.maybe_push_call_context(store.store_opaque_mut(), task)?; } Ok(()) @@ -2060,6 +2252,7 @@ impl ComponentInstance { pub(crate) fn task_return( &mut self, + store: &mut dyn VMStore, ty: TypeTupleIndex, memory: *mut VMMemoryDefinition, string_encoding: u8, @@ -2091,13 +2284,14 @@ impl ComponentInstance { log::trace!("task.return for {guest_task:?}"); - let result = (lift.lift)(self, storage)?; + let result = (lift.lift)(store, self, storage)?; - self.task_complete(guest_task, result, Status::Returned) + self.task_complete(store, guest_task, result, Status::Returned) } pub(crate) fn task_cancel( &mut self, + store: &mut dyn VMStore, _caller_instance: RuntimeComponentInstanceIndex, ) -> Result<()> { let guest_task = self.guest_task().unwrap(); @@ -2113,23 +2307,22 @@ impl ComponentInstance { log::trace!("task.cancel for {guest_task:?}"); - self.task_complete(guest_task, Box::new(DummyResult), Status::ReturnCancelled) + self.task_complete( + store, + guest_task, + Box::new(DummyResult), + Status::ReturnCancelled, + ) } fn task_complete( &mut self, + store: &mut dyn VMStore, guest_task: TableId, result: Box, status: Status, ) -> Result<()> { - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. Furthermore, this - // function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access to both - // the `ComponentInstance` and the store. - let (calls, host_table, _) = unsafe { &mut *self.store() } - .store_opaque_mut() - .component_resource_state(); + let (calls, host_table, _) = store.store_opaque_mut().component_resource_state(); ResourceTables { calls, host_table: Some(host_table), @@ -2184,6 +2377,7 @@ impl ComponentInstance { pub(crate) fn waitable_set_wait( &mut self, + store: &mut dyn VMStore, caller_instance: RuntimeComponentInstanceIndex, async_: bool, memory: *mut VMMemoryDefinition, @@ -2197,6 +2391,7 @@ impl ComponentInstance { }; self.waitable_check( + store, async_, WaitableCheck::Wait(WaitableCheckParams { set: TableId::new(rep), @@ -2209,6 +2404,7 @@ impl ComponentInstance { pub(crate) fn waitable_set_poll( &mut self, + store: &mut dyn VMStore, caller_instance: RuntimeComponentInstanceIndex, async_: bool, memory: *mut VMMemoryDefinition, @@ -2222,6 +2418,7 @@ impl ComponentInstance { }; self.waitable_check( + store, async_, WaitableCheck::Poll(WaitableCheckParams { set: TableId::new(rep), @@ -2232,15 +2429,20 @@ impl ComponentInstance { ) } - pub(crate) fn yield_(&mut self, async_: bool) -> Result { - self.waitable_check(async_, WaitableCheck::Yield) + pub(crate) fn yield_(&mut self, store: &mut dyn VMStore, async_: bool) -> Result { + self.waitable_check(store, async_, WaitableCheck::Yield) .map(|_code| { // TODO: plumb cancellation to here false }) } - pub(crate) fn waitable_check(&mut self, async_: bool, check: WaitableCheck) -> Result { + pub(crate) fn waitable_check( + &mut self, + store: &mut dyn VMStore, + async_: bool, + check: WaitableCheck, + ) -> Result { if async_ { bail!( "todo: async `waitable-set.wait`, `waitable-set.poll`, and `yield` not yet implemented" @@ -2255,7 +2457,7 @@ impl ComponentInstance { WaitableCheck::Yield => (false, None), }; - self.suspend(SuspendReason::Yielding { task: guest_task })?; + self.suspend(store, SuspendReason::Yielding { task: guest_task })?; log::trace!("waitable check for {guest_task:?}; set {set:?}"); @@ -2272,10 +2474,13 @@ impl ComponentInstance { let old = self.get_mut(guest_task)?.waiting_on.replace(set); assert!(old.is_none()); - self.suspend(SuspendReason::Waiting { - set, - task: guest_task, - })?; + self.suspend( + store, + SuspendReason::Waiting { + set, + task: guest_task, + }, + )?; } } @@ -2285,28 +2490,6 @@ impl ComponentInstance { WaitableCheck::Wait(params) | WaitableCheck::Poll(params) => { let event = self.get_event(guest_task, params.caller_instance, Some(params.set))?; - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store. - // Furthermore, this function is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access - // to both the `ComponentInstance` and the store. - // - // In addition, `params.memory` is a valid `*mut - // VMMemoryDefinition` passed to this intrinsic via - // `wasmtime_cranelift`-generated code. - let store_and_options = |me: &mut Self| unsafe { - let store = (*me.store()).store_opaque_mut(); - let options = Options::new( - store.id(), - NonNull::new(params.memory), - None, - StringEncoding::Utf8, - true, - None, - ); - (store, options) - }; - let (ordinal, handle, result) = if wait { let (event, waitable) = event.unwrap(); let handle = waitable.map(|(_, v)| v).unwrap_or(0); @@ -2326,7 +2509,17 @@ impl ComponentInstance { (ordinal, 0, result) } }; - let (store, options) = store_and_options(self); + let store = store.store_opaque_mut(); + let options = unsafe { + Options::new( + store.id(), + NonNull::new(params.memory), + None, + StringEncoding::Utf8, + true, + None, + ) + }; let ptr = func::validate_inbounds::<(u32, u32)>( options.memory_mut(store), &ValRaw::u32(params.payload), @@ -2409,6 +2602,9 @@ impl ComponentInstance { } _ => bail!("invalid task handle: {task_id}"), }; + // Since waitables can neither be passed between instances nor forged, + // this should never fail unless there's a bug in Wasmtime, but we check + // here to be sure: assert_eq!(expected_caller_instance, caller_instance); log::trace!("subtask_drop {waitable:?} (handle {task_id})"); Ok(()) @@ -2416,6 +2612,7 @@ impl ComponentInstance { pub(crate) fn subtask_cancel( &mut self, + store: &mut dyn VMStore, caller_instance: RuntimeComponentInstanceIndex, async_: bool, task_id: u32, @@ -2436,6 +2633,9 @@ impl ComponentInstance { } _ => bail!("invalid task handle: {task_id}"), }; + // Since waitables can neither be passed between instances nor forged, + // this should never fail unless there's a bug in Wasmtime, but we check + // here to be sure: assert_eq!(expected_caller_instance, caller_instance); log::trace!("subtask_cancel {waitable:?} (handle {task_id})"); @@ -2485,7 +2685,7 @@ impl ComponentInstance { }; self.push_high_priority(item); - self.suspend(SuspendReason::Yielding { task: caller })?; + self.suspend(store, SuspendReason::Yielding { task: caller })?; } let task = self.get_mut(guest_task)?; @@ -2498,7 +2698,7 @@ impl ComponentInstance { let set = self.get_mut(caller)?.sync_call_set; Waitable::Guest(guest_task).join(self, Some(set))?; - self.suspend(SuspendReason::Waiting { set, task: caller })?; + self.suspend(store, SuspendReason::Waiting { set, task: caller })?; } } } @@ -2620,12 +2820,12 @@ impl Instance { fut: impl Future + Send, ) -> Result { check_recursive_run(); - let store = store.as_context_mut(); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store. - let instance = unsafe { &mut *store.0[self.0].as_ref().unwrap().instance_ptr() }; - instance.poll_until(fut).await + store + .as_context_mut() + .with_detached_instance_async(self, async |store, instance| { + instance.poll_until(store, fut).await + }) + .await } /// Run the specified task as part of this instance's event loop. @@ -2714,7 +2914,7 @@ impl Instance { /// # Ok(()) /// # } /// ``` - pub async fn run_with( + pub async fn run_with( &self, mut store: impl AsContextMut, fun: F, @@ -2730,7 +2930,7 @@ impl Instance { self.run(store, future).await } - fn run_with_raw( + fn run_with_raw( &self, mut store: impl AsContextMut, fun: F, @@ -2741,30 +2941,18 @@ impl Instance { + Send + 'static, { - let store = store.as_context_mut(); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store. - let instance = unsafe { &mut *store.0[self.0].as_ref().unwrap().instance_ptr() }; - - // SAFETY: See corresponding comment in `ComponentInstance::wrap_call`. - let mut accessor = - unsafe { Accessor::new(get_store, |x| x, spawn_task, instance.instance()) }; - let mut future = Box::pin(async move { fun(&mut accessor).await }); - let store = VMStoreRawPtr(store.traitobj()); - let instance = SendSyncPtr::new(NonNull::new(instance).unwrap()); - // SAFETY: See corresponding comment in `ComponentInstance::wrap_call`. - let future = future::poll_fn(move |cx| unsafe { - poll_with_state::(store, instance, cx, future.as_mut()) - }); - - // SAFETY: See corresponding comment in `ComponentInstance::wrap_call`. - unsafe { - mem::transmute::< - Pin + Send>>, - Pin + Send + 'static>>, - >(Box::pin(future)) - } + store + .as_context_mut() + .with_detached_instance(self, |store, instance| { + // SAFETY: See corresponding comment in `ComponentInstance::wrap_call`. + let mut accessor = + unsafe { Accessor::new(get_store, |x| x, spawn_task, instance.instance()) }; + let mut future = Box::pin(async move { fun(&mut accessor).await }); + let token = StoreToken::new(store); + Box::pin(future::poll_fn(move |cx| { + poll_with_state::(token, cx, future.as_mut()) + })) + }) } /// Spawn a background task to run as part of this instance's event loop. @@ -2778,16 +2966,24 @@ impl Instance { /// The returned [`SpawnHandle`] may be used to cancel the task. pub fn spawn( &self, - store: impl AsContextMut, + mut store: impl AsContextMut, task: impl AccessorTask, Result<()>>, ) -> AbortHandle { - let mut future = self.run_with_raw(store, move |accessor| { + let mut store = store.as_context_mut(); + let mut future = self.run_with_raw(store.as_context_mut(), move |accessor| { Box::pin(future::ready(accessor.spawn(task))) }); - match future - .as_mut() - .poll(&mut Context::from_waker(&dummy_waker())) - { + + let poll = store.with_detached_instance(self, |store, instance| { + poll_with_local_instance( + store.0.traitobj_mut(), + instance, + &mut future.as_mut(), + &mut Context::from_waker(&dummy_waker()), + ) + }); + + match poll { Poll::Ready(handle) => handle, Poll::Pending => unreachable!(), } @@ -2799,16 +2995,9 @@ impl Instance { mut store: impl AsContextMut, task: impl std::future::Future> + Send + 'static, ) { - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store. - let instance = unsafe { - &mut *store.as_context_mut().0[self.0] - .as_ref() - .unwrap() - .instance_ptr() - }; - instance.spawn(task) + store + .as_context_mut() + .with_detached_instance(self, |_, instance| instance.spawn(task)) } } @@ -2816,16 +3005,10 @@ impl Instance { /// helper functions. /// /// SAFETY (callers): Most of the methods in this trait accept raw pointers, -/// which must be valid for at least the duration of the call. In addition, the -/// `&mut ComponentInstance` parameter must point to a `ComponentInstance` that -/// belongs to `self` (i.e. both should have been derived from the same -/// `VMComponentContext`). -/// -/// SAFETY (implementors): Care must be taken to treat the `&mut Self` and `&mut -/// ComponentInstance` parameters as if they were disjoint borrows and not -/// create aliases by retrieving a `*mut ComponentInstance` from `self` and -/// converting it to a `&mut ComponentInstance`. -pub unsafe trait VMComponentAsyncStore { +/// which must be valid for at least the duration of the call (and possibly for +/// as long as the relevant guest task exists, in the case of `*mut VMFuncRef` +/// pointers used for async calls). +pub trait VMComponentAsyncStore { /// A helper function for fused adapter modules involving calls where the /// caller is sync-lowered but the callee is async-lifted. unsafe fn sync_enter( @@ -2984,7 +3167,7 @@ pub unsafe trait VMComponentAsyncStore { } /// SAFETY: See trait docs. -unsafe impl VMComponentAsyncStore for StoreInner { +impl VMComponentAsyncStore for StoreInner { unsafe fn sync_enter( &mut self, instance: &mut ComponentInstance, @@ -2999,7 +3182,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { storage: *mut ValRaw, storage_len: usize, ) -> Result<()> { - instance.prepare_call::( + instance.prepare_call( + StoreContextMut(self), start, return_, caller_instance, @@ -3027,7 +3211,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { storage_len: usize, ) -> Result<()> { instance - .start_call::( + .start_call( + StoreContextMut(self), callback, ptr::null_mut(), callee, @@ -3055,7 +3240,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { params: u32, results: u32, ) -> Result<()> { - instance.prepare_call::( + instance.prepare_call( + StoreContextMut(self), start, return_, caller_instance, @@ -3077,7 +3263,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { result_count: u32, flags: u32, ) -> Result { - instance.start_call::( + instance.start_call( + StoreContextMut(self), callback, post_return, callee, @@ -3099,13 +3286,13 @@ unsafe impl VMComponentAsyncStore for StoreInner { future: u32, address: u32, ) -> Result { - // SAFETY: This function is only called from - // `wasmtime-cranelift`-generated guest code, which ensures that - // `instance` belongs to `self`, to which we have (and may confer) - // exclusive access in the following call. + // SAFETY: Per the trait-level documentation for + // `VMComponentAsyncStore`, all raw pointers passed to this function + // must be valid. unsafe { instance - .guest_write::( + .guest_write( + StoreContextMut(self), memory, realloc, string_encoding, @@ -3134,7 +3321,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { instance - .guest_read::( + .guest_read( + StoreContextMut(self), memory, realloc, string_encoding, @@ -3164,7 +3352,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { instance - .guest_write::( + .guest_write( + StoreContextMut(self), memory, realloc, string_encoding, @@ -3194,7 +3383,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { instance - .guest_read::( + .guest_read( + StoreContextMut(self), memory, realloc, string_encoding, @@ -3225,7 +3415,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { instance - .guest_write::( + .guest_write( + StoreContextMut(self), memory, realloc, StringEncoding::Utf8 as u8, @@ -3259,7 +3450,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { instance - .guest_read::( + .guest_read( + StoreContextMut(self), memory, realloc, StringEncoding::Utf8 as u8, @@ -3289,7 +3481,8 @@ unsafe impl VMComponentAsyncStore for StoreInner { ) -> Result<()> { // SAFETY: See corresponding comment in `Self::future_write`. unsafe { - instance.error_context_debug_message::( + instance.error_context_debug_message( + StoreContextMut(self), memory, realloc, string_encoding, @@ -3303,13 +3496,13 @@ unsafe impl VMComponentAsyncStore for StoreInner { enum HostTaskOutput { Result(Result<()>), - Function(Box Result<()> + Send>), + Function(Box Result<()> + Send>), } impl HostTaskOutput { - fn consume(self, instance: &mut ComponentInstance) -> Result<()> { + fn consume(self, store: &mut dyn VMStore, instance: &mut ComponentInstance) -> Result<()> { match self { - Self::Function(fun) => fun(instance), + Self::Function(fun) => fun(store, instance), Self::Result(result) => result, } } @@ -3342,17 +3535,18 @@ impl TableDebug for HostTask { } } -#[derive(Copy, Clone)] -struct Callback { - function: SendSyncPtr, - caller: fn( - &mut ComponentInstance, - RuntimeComponentInstanceIndex, - SendSyncPtr, - Event, - u32, - ) -> Result, -} +type CallbackFn = Box< + dyn Fn( + &mut dyn VMStore, + &mut ComponentInstance, + RuntimeComponentInstanceIndex, + Event, + u32, + ) -> Result + + Send + + Sync + + 'static, +>; enum Caller { Host(Option>), @@ -3374,7 +3568,7 @@ struct GuestTask { lower_params: Option, lift_result: Option, result: Option, - callback: Option, + callback: Option, caller: Caller, call_context: Option, sync_result: Option>, @@ -3394,7 +3588,7 @@ impl GuestTask { lower_params: RawLower, lift_result: LiftResult, caller: Caller, - callback: Option, + callback: Option, component_instance: RuntimeComponentInstanceIndex, ) -> Result { let sync_call_set = instance.push(WaitableSet::default())?; @@ -3675,20 +3869,36 @@ impl TableDebug for WaitableSet { } } -type RawLower = - Box]) -> Result<()> + Send + Sync>; +type RawLower = Box< + dyn FnOnce(&mut dyn VMStore, &mut ComponentInstance, &mut [MaybeUninit]) -> Result<()> + + Send + + Sync, +>; -pub type LowerFn = - unsafe fn(Func, *mut dyn VMStore, *mut u8, &mut [MaybeUninit]) -> Result<()>; +pub type LowerFn = unsafe fn( + Func, + StoreContextMut, + &mut ComponentInstance, + *mut u8, + &mut [MaybeUninit], +) -> Result<()>; type RawLift = Box< - dyn FnOnce(&mut ComponentInstance, &[ValRaw]) -> Result> + dyn FnOnce( + &mut dyn VMStore, + &mut ComponentInstance, + &[ValRaw], + ) -> Result> + Send + Sync, >; -pub type LiftFn = - unsafe fn(Func, *mut dyn VMStore, &[ValRaw]) -> Result>; +pub type LiftFn = fn( + Func, + StoreContextMut, + &mut ComponentInstance, + &[ValRaw], +) -> Result>; type LiftedResult = Box; @@ -3829,7 +4039,7 @@ struct InstanceState { pub struct ConcurrentState { guest_task: Option>, - futures: Mutex>, + futures: Mutex>>, table: Table, // TODO: this can and should be a `PrimaryMap` instance_states: HashMap, @@ -3887,7 +4097,7 @@ impl ConcurrentState { Self { guest_task: None, table: Table::new(), - futures: Mutex::new(FuturesUnordered::new()), + futures: Mutex::new(Some(FuturesUnordered::new())), instance_states: HashMap::new(), waitable_tables, high_priority: Vec::new(), @@ -3921,7 +4131,9 @@ fn dummy_waker() -> Waker { } fn for_any_lower< - F: FnOnce(&mut ComponentInstance, &mut [MaybeUninit]) -> Result<()> + Send + Sync, + F: FnOnce(&mut dyn VMStore, &mut ComponentInstance, &mut [MaybeUninit]) -> Result<()> + + Send + + Sync, >( fun: F, ) -> F { @@ -3929,7 +4141,13 @@ fn for_any_lower< } fn for_any_lift< - F: FnOnce(&mut ComponentInstance, &[ValRaw]) -> Result> + Send + Sync, + F: FnOnce( + &mut dyn VMStore, + &mut ComponentInstance, + &[ValRaw], + ) -> Result> + + Send + + Sync, >( fun: F, ) -> F { @@ -3948,8 +4166,19 @@ fn checked( instance from which they originated. Please use \ `Instance::{run,run_with,spawn}` to poll or await them.\ "; - INSTANCE.with(|v| { - if v.get() != instance.as_ptr() { + INSTANCE_STATE.with(|v| { + let matched = match v.get() { + InstanceThreadLocalState::Detached { + instance: local, .. + } => local.as_ptr() == instance.as_ptr(), + InstanceThreadLocalState::Attached { instance: local } => { + local.0 == unsafe { (*instance.as_ptr()).instance.unwrap().0 } + } + InstanceThreadLocalState::None => false, + InstanceThreadLocalState::Polling => unreachable!(), + }; + + if !matched { panic!("{message}") } }); @@ -3958,8 +4187,8 @@ fn checked( } fn check_recursive_run() { - INSTANCE.with(|v| { - if !v.get().is_null() { + INSTANCE_STATE.with(|v| { + if !matches!(v.get(), InstanceThreadLocalState::None) { panic!("Recursive `Instance::run{{_with}}` calls not supported") } }); @@ -3968,14 +4197,15 @@ fn check_recursive_run() { /// Run the specified function on a newly-created fiber and `.await` its /// completion. pub(crate) async fn on_fiber( - store: StoreContextMut<'_, T>, + mut store: StoreContextMut<'_, T>, func: impl FnOnce(&mut StoreContextMut) -> R + Send, ) -> Result { // SAFETY: The returned future closes over `store`, so the borrow checker // will ensure the requirements of `on_fiber_raw` are met. + let token = StoreToken::new(store.as_context_mut()); unsafe { on_fiber_raw(VMStoreRawPtr(store.traitobj()), move |store| { - func(&mut StoreContextMut(&mut *store.cast())) + func(&mut token.as_context_mut(&mut *store)) }) .await } @@ -4009,7 +4239,7 @@ unsafe fn prepare_fiber<'a, R: Send + 'static>( func: impl FnOnce(*mut dyn VMStore) -> R + Send + 'a, ) -> Result<(StoreFiber<'a>, oneshot::Receiver)> { let (tx, rx) = oneshot::channel(); - let fiber = make_fiber(store.0.as_ptr(), { + let fiber = make_fiber(store, { move |store| { _ = tx.send(func(store)); Ok(()) @@ -4087,9 +4317,9 @@ impl StoreFiber<'_> { impl Drop for StoreFiber<'_> { fn drop(&mut self) { if !self.fiber.as_ref().unwrap().done() { - // Safety: `self` is a valid pointer and we pass a `store` - // parameter of `None` to inform the resumed fiber that it does - // _not_ have access to the store. + // SAFETY: `self` is a valid pointer and we pass a `store` parameter + // of `None` to inform the resumed fiber that it does _not_ have + // access to the store. let result = unsafe { resume_fiber_raw(self, None, Err(anyhow!("future dropped"))) }; debug_assert!(result.is_ok()); } @@ -4108,10 +4338,10 @@ unsafe impl Send for StoreFiber<'_> {} unsafe impl Sync for StoreFiber<'_> {} unsafe fn make_fiber<'a>( - store: *mut dyn VMStore, + store: VMStoreRawPtr, fun: impl FnOnce(*mut dyn VMStore) -> Result<()> + 'a, ) -> Result> { - let engine = (*store).engine().clone(); + let engine = (*store.0.as_ptr()).engine().clone(); let stack = engine.allocator().allocate_fiber_stack()?; Ok(StoreFiber { fiber: Some(Fiber::new( @@ -4134,12 +4364,12 @@ unsafe fn make_fiber<'a>( )?), state: Some(AsyncWasmCallState::new()), engine, - suspend: (*store) + suspend: (*store.0.as_ptr()) .store_opaque_mut() .concurrent_async_state() .current_suspend .get(), - stack_limit: (*store).vm_store_context().stack_limit.get(), + stack_limit: (*store.0.as_ptr()).vm_store_context().stack_limit.get(), }) } @@ -4219,67 +4449,6 @@ pub(crate) enum WaitableCheck { Yield, } -/// Return a closure which will call the specified function in the scope of the -/// specified task. -/// -/// This will use `GuestTask::lower_params` to lower the parameters, but will -/// not lift the result; instead, it returns a `[MaybeUninit; -/// MAX_FLAT_PARAMS]` from which the result, if any, may be lifted. Note that -/// an async-lifted export will have returned its result using the `task.return` -/// intrinsic (or not returned a result at all, in the case of `task.cancel`), -/// in which case the "result" of this call will either be a callback code or -/// nothing. -/// -/// SAFETY: `callee` must be a valid `*mut VMFuncRef` at the time when the -/// returned closure is called. In addition the caller must confer exclusive -/// access to the store to which the passed `&mut ComponentInstance` belongs, -/// which must have a data type parameter of `T`. -// TODO: This should return a `impl UnsafeFnOnce` (where `UnsafeFnOnce` would -// need to be a trait we define ourselves, since there's no standard equivalent) -// rather than a `impl FnOnce`. That would force the caller to use an unsafe -// block and (hopefully) uphold the contract we've described above. -unsafe fn make_call( - guest_task: TableId, - callee: SendSyncPtr, - param_count: usize, - result_count: usize, - flags: Option, -) -> impl FnOnce(&mut ComponentInstance) -> Result<[MaybeUninit; MAX_FLAT_PARAMS]> - + Send - + Sync - + 'static { - move |instance: &mut ComponentInstance| { - let mut storage = [MaybeUninit::uninit(); MAX_FLAT_PARAMS]; - let lower = instance.get_mut(guest_task)?.lower_params.take().unwrap(); - - lower(instance, &mut storage[..param_count])?; - - // SAFETY: Per the contract documented above, `callee` is a valid - // pointer and we have exclusive access to the store this instance - // belongs to, which has a data type parameter of `T`. - unsafe { - let mut store = StoreContextMut::(&mut *instance.store().cast()); - if let Some(mut flags) = flags { - flags.set_may_enter(false); - } - crate::Func::call_unchecked_raw( - &mut store, - callee.as_non_null(), - NonNull::new( - &mut storage[..param_count.max(result_count)] as *mut [MaybeUninit] - as _, - ) - .unwrap(), - )?; - if let Some(mut flags) = flags { - flags.set_may_enter(true); - } - } - - Ok(storage) - } -} - pub(crate) struct ResetPtr<'a>(pub(crate) &'a AtomicPtr); impl<'a> Drop for ResetPtr<'a> { @@ -4338,11 +4507,14 @@ impl PreparedCall { /// long as it is stored in that field. Also, the `lower_params` and /// `lift_result` functions must both use their other pointer arguments safely /// or not at all. -pub(crate) unsafe fn prepare_call( - store: StoreContextMut, - lower_params: LowerFn, +/// +/// In addition, the pointers in the `FuncData` for `handle` must be valid for +/// as long as the guest task we create here exists. +pub(crate) unsafe fn prepare_call( + mut store: StoreContextMut, + lower_params: LowerFn, drop_params: unsafe fn(*mut u8), - lift_result: LiftFn, + lift_result: LiftFn, handle: Func, param_count: usize, ) -> Result> { @@ -4353,104 +4525,109 @@ pub(crate) unsafe fn prepare_call( let callback = func_data.options.callback; let memory = func_data.options.memory.map(SendSyncPtr::new); let string_encoding = func_data.options.string_encoding(); + let token = StoreToken::new(store.as_context_mut()); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the store. - let instance = unsafe { &mut *store.0[instance.0].as_ref().unwrap().instance_ptr() }; + store.with_detached_instance(&instance, |_, instance| { + let params = Arc::new(AtomicPtr::new(ptr::null_mut())); - let params = Arc::new(AtomicPtr::new(ptr::null_mut())); + assert!(instance.guest_task().is_none()); - assert!(instance.guest_task().is_none()); + let (tx, rx) = oneshot::channel(); - let (tx, rx) = oneshot::channel(); - - struct DropParams { - params: Arc>, - dropper: unsafe fn(*mut u8), - } + struct DropParams { + params: Arc>, + dropper: unsafe fn(*mut u8), + } - impl Drop for DropParams { - fn drop(&mut self) { - let ptr = self.params.swap(ptr::null_mut(), Relaxed); - if !ptr.is_null() { - // SAFETY: Per the contract of the `prepare_call`, `ptr` must be - // valid and `self.dropper` must either use it safely or not at - // all. - unsafe { - (self.dropper)(ptr); + impl Drop for DropParams { + fn drop(&mut self) { + let ptr = self.params.swap(ptr::null_mut(), Relaxed); + if !ptr.is_null() { + // SAFETY: Per the contract of the `prepare_call`, `ptr` + // must be valid and `self.dropper` must either use it + // safely or not at all. + unsafe { + (self.dropper)(ptr); + } } } } - } - let drop_params = DropParams { - params: params.clone(), - dropper: drop_params, - }; + let drop_params = DropParams { + params: params.clone(), + dropper: drop_params, + }; - let task = GuestTask::new( - instance, - Box::new(for_any_lower({ - let param_ptr = params.clone(); - move |instance, params| { - let ptr = param_ptr.load(Relaxed); - let result = if ptr.is_null() { - // If we've reached here, it presumably means we were called - // via `TypedFunc::call_async` and the future was dropped or - // `mem::forget`ed by the caller, meaning we no longer have - // access to the parameters. In that case, we should - // gracefully cancel the call without trapping or panicking. - todo!("gracefully cancel `call_async` tasks when future is dropped") - } else { - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store. - // Furthermore, this closure is only called (transitively) - // from `ComponentInstance::poll_until`, which has exclusive - // access to both the `ComponentInstance` and the store. - // - // Also, per the contract of `prepare_call`, `ptr` must be - // valid and `lower_params` must either use it safely or not at - // all. - unsafe { lower_params(handle, instance.store(), ptr, params) } - }; - drop(drop_params); - result - } - })), - LiftResult { - lift: Box::new(for_any_lift(move |instance, result| { - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store. - // Furthermore, this closure is only called (transitively) from - // `ComponentInstance::poll_until`, which has exclusive access - // to both the `ComponentInstance` and the store. - unsafe { lift_result(handle, instance.store(), result) } + let task = GuestTask::new( + instance, + Box::new(for_any_lower({ + let param_ptr = params.clone(); + move |store, instance, params| { + let ptr = param_ptr.load(Relaxed); + let result = if ptr.is_null() { + // If we've reached here, it presumably means we were + // called via `TypedFunc::call_async` and the future was + // dropped or `mem::forget`ed by the caller, meaning we + // no longer have access to the parameters. In that + // case, we should gracefully cancel the call without + // trapping or panicking. + todo!("gracefully cancel `call_async` tasks when future is dropped") + } else { + // SAFETY: Per the contract of `prepare_call`, `ptr` + // must be valid and `lower_params` must either use it + // safely or not at all. + unsafe { + lower_params(handle, token.as_context_mut(store), instance, ptr, params) + } + }; + drop(drop_params); + result + } })), - ty: task_return_type, - memory, - string_encoding, - }, - Caller::Host(Some(tx)), - callback.map(|v| Callback { - function: SendSyncPtr::new(v), - caller: ComponentInstance::call_callback::, - }), - component_instance, - )?; + LiftResult { + lift: Box::new(for_any_lift(move |store, instance, result| { + lift_result(handle, token.as_context_mut(store), instance, result) + })), + ty: task_return_type, + memory, + string_encoding, + }, + Caller::Host(Some(tx)), + callback.map(|callback| { + let callback = SendSyncPtr::new(callback); + Box::new( + move |store: &mut dyn VMStore, + instance: &mut ComponentInstance, + runtime_instance, + event, + handle| { + let store = token.as_context_mut(store); + // SAFETY: Per the contract of `prepare_call`, the + // callback will remain valid at least as long is this + // task exists. + unsafe { + instance.call_callback(store, runtime_instance, callback, event, handle) + } + }, + ) as CallbackFn + }), + component_instance, + )?; - let task = instance.push(task)?; + let task = instance.push(task)?; - Ok(PreparedCall { - handle, - task, - param_count, - rx, - params, - _phantom: PhantomData, + Ok(PreparedCall { + handle, + task, + param_count, + rx, + params, + _phantom: PhantomData, + }) }) } -pub(crate) fn queue_call( +pub(crate) fn queue_call( mut store: StoreContextMut, prepared: PreparedCall, ) -> Result> + Send + 'static + use> { @@ -4478,8 +4655,8 @@ pub(crate) fn queue_call( )) } -fn start_call( - store: StoreContextMut, +fn start_call( + mut store: StoreContextMut, handle: Func, guest_task: TableId, param_count: usize, @@ -4492,46 +4669,40 @@ fn start_call( let callback = func_data.options.callback; let post_return = func_data.post_return; - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the store. - let instance = unsafe { &mut *store.0[instance.0].as_ref().unwrap().instance_ptr() }; + store.with_detached_instance(&instance, |store, instance| { + log::trace!("starting call {guest_task:?}"); - log::trace!("starting call {guest_task:?}"); - - *instance.guest_task() = Some(guest_task); - log::trace!("pushed {guest_task:?} as current task; old task was None"); - - // SAFETY: We have exclusive access to the store, whose data type parameter - // is `T`, and `instance` was extracted from it above. - unsafe { - let call = make_call::( - guest_task, - SendSyncPtr::new(callee), - param_count, - 1, - if callback.is_none() { - None - } else { - Some(instance.instance_flags(component_instance)) - }, - ); + *instance.guest_task() = Some(guest_task); + log::trace!("pushed {guest_task:?} as current task; old task was None"); - instance.queue_call::( - guest_task, - is_concurrent, - call, - callback.map(SendSyncPtr::new), - post_return.map(|f| SendSyncPtr::new(f.func_ref)), - 1, - )?; - } + // SAFETY: `callee`, `callback`, and `post_return` are valid pointers + // (with signatures appropriate for this call) and will remain valid as + // long as this instance is valid. + unsafe { + instance.queue_call( + store, + guest_task, + SendSyncPtr::new(callee), + param_count, + 1, + if callback.is_none() { + None + } else { + Some(instance.instance_flags(component_instance)) + }, + is_concurrent, + callback.map(SendSyncPtr::new), + post_return.map(|f| SendSyncPtr::new(f.func_ref)), + )?; + } - *instance.guest_task() = None; - log::trace!("popped current task {guest_task:?}; new task is None"); + *instance.guest_task() = None; + log::trace!("popped current task {guest_task:?}; new task is None"); - log::trace!("started call {guest_task:?}"); + log::trace!("started call {guest_task:?}"); - Ok(()) + Ok(()) + }) } /// Wrap the specified function in a future which, when polled, will store a diff --git a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs index 76ac785a61..cfa213b29d 100644 --- a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs +++ b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs @@ -11,9 +11,9 @@ use { values::{ErrorContextAny, FutureAny, StreamAny}, Instance, Lower, Val, WasmList, WasmStr, }, - store::StoreId, + store::{StoreId, StoreToken}, vm::{component::ComponentInstance, SendSyncPtr, VMFuncRef, VMMemoryDefinition}, - AsContextMut, StoreContextMut, ValRaw, + AsContextMut, StoreContextMut, VMStore, ValRaw, }, anyhow::{anyhow, bail, Context, Result}, buffers::Extender, @@ -42,7 +42,7 @@ use { }, }; -pub use buffers::{ReadBuffer, VecBuffer, WriteBuffer}; +pub use buffers::{ReadBuffer, TakeBuffer, VecBuffer, WriteBuffer}; mod buffers; @@ -144,16 +144,17 @@ fn waitable_state(ty: TableIndex, state: StreamFutureState) -> WaitableState { /// Return a closure which matches a host write operation to a read (or close) /// operation. -/// -/// SAFETY: The `ComponentInstance` passed to the returned closure must, when -/// paired with a `Reader::Guest { .. }`, match the one the stream or future -/// belongs to, and must itself belong to a store with a data type parameter of -/// `U`. Finally, the caller must confer exclusive access to that store. -unsafe fn accept_reader, U>( +fn accept_reader, U: 'static>( + store: StoreContextMut, mut buffer: B, tx: oneshot::Sender>, -) -> impl FnOnce(&mut ComponentInstance, Reader) -> Result + Send + Sync + 'static { - move |instance, reader| { +) -> impl FnOnce(&mut dyn VMStore, &mut ComponentInstance, Reader) -> Result + + Send + + Sync + + 'static + + use { + let token = StoreToken::new(store); + move |store, instance, reader| { let count = match reader { Reader::Guest { lower: RawLowerContext { options }, @@ -161,38 +162,34 @@ unsafe fn accept_reader, U>( address, count, } => { - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store, and - // per this function's contract, the caller has conferred - // exclusive access to that store. - // - // Finally, per the contract documented above for - // `accept_reader`, the data type of the store must be `U`. - let mut store = unsafe { StoreContextMut::(&mut *instance.store().cast()) }; + let mut store = token.as_context_mut(store); let ptr = instance as *mut _; - let types = instance.component_types(); - // SAFETY: The instance pointer is valid and belongs to the - // store given that both were derived from the `&mut - // ComponentInstance` we received. - let lower = - unsafe { &mut LowerContext::new(store.as_context_mut(), options, types, ptr) }; - if address % usize::try_from(T::ALIGN32)? != 0 { - bail!("read pointer not aligned"); - } - lower - .as_slice_mut() - .get_mut(address..) - .and_then(|b| b.get_mut(..T::SIZE32 * count)) - .ok_or_else(|| anyhow::anyhow!("read pointer out of bounds of memory"))?; - + let types = instance.component_types().clone(); let count = buffer .remaining() .len() .min(usize::try_from(count).unwrap()); - if let Some(ty) = payload(ty, types) { - T::store_list(lower, ty, address, &buffer.remaining()[..count])?; - } + store.with_attached_instance(instance, |mut store, _| { + // SAFETY: `ptr` is derived from `interface` and thus known + // to be valid. + let lower = unsafe { + &mut LowerContext::new(store.as_context_mut(), options, &types, ptr) + }; + if address % usize::try_from(T::ALIGN32)? != 0 { + bail!("read pointer not aligned"); + } + lower + .as_slice_mut() + .get_mut(address..) + .and_then(|b| b.get_mut(..T::SIZE32 * count)) + .ok_or_else(|| anyhow::anyhow!("read pointer out of bounds of memory"))?; + + if let Some(ty) = payload(ty, &types) { + T::store_list(lower, ty, address, &buffer.remaining()[..count])?; + } + Ok(()) + })?; buffer.skip(count); _ = tx.send(HostResult { @@ -202,11 +199,8 @@ unsafe fn accept_reader, U>( ReturnCode::Completed(count.try_into().unwrap()) } Reader::Host { accept } => { - // SAFETY: Per the requirements described in `host_read`'s - // documentation, we give up ownership of the items by calling - // `buffer.forget` immediately after the following call. - let count = accept(buffer.remaining().as_ptr().cast(), buffer.remaining().len()); - buffer.forget(count); + let count = buffer.remaining().len(); + let count = accept(&mut buffer, count); _ = tx.send(HostResult { buffer, closed: false, @@ -228,17 +222,7 @@ unsafe fn accept_reader, U>( /// Return a closure which matches a host read operation to a write (or close) /// operation. -/// -/// SAFETY: If and when a `Writer::Host { .. }` is passed to the returned -/// closure, the `pointer` field must be a valid `*mut T` array of `count` -/// elements, and those elements must be forgotten using e.g. `mem::forget` -/// after the call to the closure returns since they will have been moved into -/// another buffer (i.e. the destination buffer will take ownership of them). -// TODO: This should return a `impl UnsafeFnOnce` (where `UnsafeFnOnce` would -// need to be a trait we define ourselves, since there's no standard equivalent) -// rather than a `impl FnOnce`. That would force the caller to use an unsafe -// block and (hopefully) uphold the contract we've described above. -unsafe fn accept_writer, U>( +fn accept_writer, U>( mut buffer: B, tx: oneshot::Sender>, ) -> impl FnOnce(Writer) -> Result + Send + Sync + 'static { @@ -278,12 +262,12 @@ unsafe fn accept_writer, U>( }); ReturnCode::Completed(count.try_into().unwrap()) } - Writer::Host { pointer, count } => { + Writer::Host { + buffer: input, + count, + } => { let count = count.min(buffer.remaining_capacity()); - // SAFETY: Per the contact of `accept_writer`, `pointer` is a - // valid `*mut T` array of `count` elements which we may move - // (i.e. transfer ownership) into the destination buffer. - unsafe { buffer.copy_from(pointer.cast(), count) }; + buffer.move_from(input, count); _ = tx.send(HostResult { buffer, closed: false, @@ -533,19 +517,20 @@ pub struct HostFuture { } impl HostFuture { - fn new(rep: u32, instance: &mut ComponentInstance) -> Self { + /// Create a new `HostFuture`. + /// + /// SAFETY: `id` must match the store to which `instance` belongs. + unsafe fn new(rep: u32, id: StoreId, instance: &mut ComponentInstance) -> Self { Self { instance: SendSyncPtr::new(NonNull::new(instance).unwrap()), - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. - id: unsafe { (*instance.store()).store_opaque().id() }, + id, rep, _phantom: PhantomData, } } /// Convert this object into a [`FutureReader`]. - pub fn into_reader>(self, mut store: S) -> FutureReader + pub fn into_reader>(self, mut store: S) -> FutureReader where T: func::Lower + func::Lift + Send + Sync + 'static, { @@ -560,7 +545,7 @@ impl HostFuture { instance: self.instance, id: self.id, rep: self.rep, - tx: Some(instance.start_read_event_loop::<_, _, U>(self.rep)), + tx: Some(instance.start_read_event_loop::<_, _, U>(store, self.rep)), } } @@ -585,7 +570,7 @@ impl HostFuture { // store. let instance = unsafe { &mut *store.0[instance.0].as_ref().unwrap().instance_ptr() }; instance.get(TableId::::new(*rep))?; // Just make sure it's present - Ok(Self::new(*rep, instance)) + Ok(unsafe { Self::new(*rep, store.0.id(), instance) }) } fn lift_from_index(cx: &mut LiftContext<'_>, ty: InterfaceType, index: u32) -> Result { @@ -607,7 +592,7 @@ impl HostFuture { StreamFutureState::Busy => bail!("cannot transfer busy future"), } - Ok(Self::new(rep, instance)) + Ok(unsafe { Self::new(rep, cx.store_id(), instance) }) } _ => func::bad_type_info(), } @@ -711,16 +696,15 @@ pub struct FutureReader { } impl FutureReader { - fn new( + fn new( rep: u32, tx: Option>>>, instance: &mut ComponentInstance, + store: StoreContextMut, ) -> Self { Self { instance: SendSyncPtr::new(NonNull::new(instance).unwrap()), - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. - id: unsafe { (*instance.store()).store_opaque().id() }, + id: store.0.id(), rep, tx, } @@ -936,19 +920,23 @@ pub struct HostStream { } impl HostStream { - fn new(rep: u32, instance: &mut ComponentInstance) -> Self { + /// Create a new `HostStream`. + /// + /// SAFETY: `id` must match the store to which `instance` belongs. + unsafe fn new(rep: u32, id: StoreId, instance: &mut ComponentInstance) -> Self { Self { instance: SendSyncPtr::new(NonNull::new(instance).unwrap()), - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. - id: unsafe { (*instance.store()).store_opaque().id() }, + id, rep, _phantom: PhantomData, } } /// Convert this object into a [`StreamReader`]. - pub fn into_reader>(self, mut store: S) -> StreamReader + pub fn into_reader>( + self, + mut store: S, + ) -> StreamReader where T: func::Lower + func::Lift + Send + 'static, B: ReadBuffer, @@ -964,7 +952,7 @@ impl HostStream { instance: self.instance, id: self.id, rep: self.rep, - tx: Some(instance.start_read_event_loop::<_, _, U>(self.rep)), + tx: Some(instance.start_read_event_loop::<_, _, U>(store, self.rep)), } } @@ -989,7 +977,7 @@ impl HostStream { // store. let instance = unsafe { &mut *store.0[instance.0].as_ref().unwrap().instance_ptr() }; instance.get(TableId::::new(*rep))?; // Just make sure it's present - Ok(Self::new(*rep, instance)) + Ok(unsafe { Self::new(*rep, store.0.id(), instance) }) } fn lift_from_index(cx: &mut LiftContext<'_>, ty: InterfaceType, index: u32) -> Result { @@ -1011,7 +999,7 @@ impl HostStream { StreamFutureState::Busy => bail!("cannot transfer busy stream"), } - Ok(Self::new(rep, instance)) + Ok(unsafe { Self::new(rep, cx.store_id(), instance) }) } _ => func::bad_type_info(), } @@ -1115,16 +1103,15 @@ pub struct StreamReader { } impl StreamReader { - fn new( + fn new( rep: u32, tx: Option>>, instance: &mut ComponentInstance, + store: StoreContextMut, ) -> Self { Self { instance: SendSyncPtr::new(NonNull::new(instance).unwrap()), - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store. - id: unsafe { (*instance.store()).store_opaque().id() }, + id: store.0.id(), rep, tx, } @@ -1378,7 +1365,11 @@ enum WriteState { post_write: PostWrite, }, HostReady { - accept: Box Result + Send + Sync>, + accept: Box< + dyn FnOnce(&mut dyn VMStore, &mut ComponentInstance, Reader) -> Result + + Send + + Sync, + >, post_write: PostWrite, }, Closed, @@ -1415,7 +1406,7 @@ enum Writer<'a> { count: usize, }, Host { - pointer: *const u8, + buffer: &'a mut dyn TakeBuffer, count: usize, }, End, @@ -1433,7 +1424,7 @@ enum Reader<'a> { count: usize, }, Host { - accept: Box usize>, + accept: Box usize>, }, End, } @@ -1443,30 +1434,38 @@ impl Instance { /// the latter of which may be passed to guest code. pub fn future< T: func::Lower + func::Lift + Send + Sync + 'static, - U, + U: 'static, S: AsContextMut, >( &self, mut store: S, ) -> Result<(FutureWriter, FutureReader)> { - let store = store.as_context_mut(); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store. - let instance = unsafe { &mut *store.0[self.0].as_ref().unwrap().instance_ptr() }; - let (write, read) = instance.new_transmit()?; - - Ok(( - FutureWriter::new( - Some(instance.start_write_event_loop::<_, _, U>(write.rep())), - instance, - ), - FutureReader::new( - read.rep(), - Some(instance.start_read_event_loop::<_, _, U>(read.rep())), - instance, - ), - )) + store + .as_context_mut() + .with_detached_instance(self, |mut store, instance| { + let (write, read) = instance.new_transmit()?; + + Ok(( + FutureWriter::new( + Some(instance.start_write_event_loop::<_, _, U>( + store.as_context_mut(), + write.rep(), + )), + instance, + ), + FutureReader::new( + read.rep(), + Some( + instance.start_read_event_loop::<_, _, U>( + store.as_context_mut(), + read.rep(), + ), + ), + instance, + store, + ), + )) + }) } /// Create a new Component Model `stream` as pair of writable and readable ends, @@ -1475,47 +1474,51 @@ impl Instance { T: func::Lower + func::Lift + Send + 'static, W: WriteBuffer, R: ReadBuffer, - U, + U: 'static, S: AsContextMut, >( &self, mut store: S, ) -> Result<(StreamWriter, StreamReader)> { - let store = store.as_context_mut(); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store. - let instance = unsafe { &mut *store.0[self.0].as_ref().unwrap().instance_ptr() }; - let (write, read) = instance.new_transmit()?; - - Ok(( - StreamWriter::new( - Some(instance.start_write_event_loop::<_, _, U>(write.rep())), - instance, - ), - StreamReader::new( - read.rep(), - Some(instance.start_read_event_loop::<_, _, U>(read.rep())), - instance, - ), - )) + store + .as_context_mut() + .with_detached_instance(self, |mut store, instance| { + let (write, read) = instance.new_transmit()?; + + Ok(( + StreamWriter::new( + Some(instance.start_write_event_loop::<_, _, U>( + store.as_context_mut(), + write.rep(), + )), + instance, + ), + StreamReader::new( + read.rep(), + Some( + instance.start_read_event_loop::<_, _, U>( + store.as_context_mut(), + read.rep(), + ), + ), + instance, + store, + ), + )) + }) } } /// Retrieve the `TransmitState` rep for the specified `TransmitHandle` rep. -/// -/// SAFETY: `instance` must point to a valid `ComponentInstance` to which the -/// caller may confer exclusive access. -unsafe fn get_state_rep(instance: SendSyncPtr, rep: u32) -> Result { - // SAFETY: Per the precondition for this function, the pointer is valid and - // we have exclusive access to the instance it points to. - let instance = unsafe { &mut *instance.as_ptr() }; - let transmit_handle = TableId::::new(rep); - Ok(instance - .get(transmit_handle) - .with_context(|| format!("stream or future {transmit_handle:?} not found"))? - .state - .rep()) +fn get_state_rep(rep: u32) -> Result { + super::with_local_instance(|_, instance| { + let transmit_handle = TableId::::new(rep); + Ok(instance + .get(transmit_handle) + .with_context(|| format!("stream or future {transmit_handle:?} not found"))? + .state + .rep()) + }) } struct RunOnDrop(Option); @@ -1542,78 +1545,51 @@ impl ComponentInstance { fn start_write_event_loop< T: func::Lower + func::Lift + Send + 'static, B: WriteBuffer, - U, + U: 'static, >( &mut self, + store: StoreContextMut, rep: u32, ) -> mpsc::Sender> { - // SAFETY: `instance` must point to a valid `ComponentInstance` to which - // the caller may confer exclusive access. - unsafe fn write, U>( - instance: SendSyncPtr, - rep: u32, - buffer: B, - tx: oneshot::Sender>, - ) -> Result<()> { - // SAFETY: Per the precondition for this function, the pointer is - // valid and we have exclusive access to the instance it points to. - let instance = unsafe { &mut *instance.as_ptr() }; - instance.host_write::<_, _, U>(rep, buffer, PostWrite::Continue, tx) - } - - // SAFETY: See corresponding comment for `write` above. - unsafe fn close(instance: SendSyncPtr, rep: u32) -> Result<()> { - // SAFETY: See corresponding comment in `write` above. - let instance = unsafe { &mut *instance.as_ptr() }; - instance.host_close_writer(rep) - } - - // SAFETY: See corresponding comment for `write` above. - unsafe fn watch( - instance: SendSyncPtr, - rep: u32, - tx: oneshot::Sender<()>, - ) -> Result<()> { - // SAFETY: See corresponding comment in `write` above. - let instance = unsafe { &mut *instance.as_ptr() }; - let state = instance.get_mut(TableId::::new(rep))?; - if !matches!(&state.read, ReadState::Closed) { - state.reader_watcher = Some(tx); - } - Ok(()) - } - let (tx, mut rx) = mpsc::channel(1); let id = TableId::::new(rep); let run_on_drop = RunOnDrop::new(move || log::trace!("write event loop for {id:?} dropped")); + let token = StoreToken::new(store); let task = Box::pin( - { - let instance = SendSyncPtr::new(NonNull::new(self).unwrap()); - async move { - log::trace!("write event loop for {id:?} started"); - let mut my_rep = None; - while let Some(event) = rx.next().await { - // SAFETY: This future is only polled from - // `ComponentInstance::poll_until`, which has exclusive - // access to both the same `ComponentInstance` pointed - // to by `instance` and the store to which it belongs. - unsafe { - if my_rep.is_none() { - my_rep = Some(get_state_rep(instance, rep)?); - } - let rep = my_rep.unwrap(); - match event { - WriteEvent::Write { buffer, tx } => { - write::(instance, rep, buffer, tx)? - } - WriteEvent::Close => close(instance, rep)?, - WriteEvent::Watch { tx } => watch(instance, rep, tx)?, - } + async move { + log::trace!("write event loop for {id:?} started"); + let mut my_rep = None; + while let Some(event) = rx.next().await { + if my_rep.is_none() { + my_rep = Some(get_state_rep(rep)?); + } + let rep = my_rep.unwrap(); + match event { + WriteEvent::Write { buffer, tx } => { + super::with_local_instance(|store, instance| { + instance.host_write::<_, _, U>( + token.as_context_mut(store), + rep, + buffer, + PostWrite::Continue, + tx, + ) + })? } + WriteEvent::Close => super::with_local_instance(|_, instance| { + instance.host_close_writer(rep) + })?, + WriteEvent::Watch { tx } => super::with_local_instance(|_, instance| { + let state = instance.get_mut(TableId::::new(rep))?; + if !matches!(&state.read, ReadState::Closed) { + state.reader_watcher = Some(tx); + } + Ok::<_, anyhow::Error>(()) + })?, } - Ok(()) } + Ok(()) } .map(move |v| { run_on_drop.cancel(); @@ -1625,81 +1601,52 @@ impl ComponentInstance { tx } - fn start_read_event_loop, U>( + fn start_read_event_loop< + T: func::Lower + func::Lift + Send + 'static, + B: ReadBuffer, + U: 'static, + >( &mut self, + store: StoreContextMut, rep: u32, ) -> mpsc::Sender> { - // SAFETY: `instance` must point to a valid `ComponentInstance` to which - // the caller may confer exclusive access. In addition, the caller must - // also confer exclusive access to the store to which the - // `ComponentInstance` belongs, and the data type parameter for that - // store must be `U`. - unsafe fn read, U>( - instance: SendSyncPtr, - rep: u32, - buffer: B, - tx: oneshot::Sender>, - ) -> Result<()> { - // SAFETY: Per the precondition for this function, the pointer is - // valid and we have exclusive access to the instance it points to. - unsafe { - let instance = &mut *instance.as_ptr(); - instance.host_read::(rep, buffer, tx) - } - } - - // SAFETY: See corresponding comment for `read` above. - unsafe fn close(instance: SendSyncPtr, rep: u32) -> Result<()> { - // SAFETY: See corresponding comment in `read` above. - let instance = unsafe { &mut *instance.as_ptr() }; - instance.host_close_reader(rep) - } - - // SAFETY: See corresponding comment for `read` above. - unsafe fn watch( - instance: SendSyncPtr, - rep: u32, - tx: oneshot::Sender<()>, - ) -> Result<()> { - // SAFETY: See corresponding comment in `read` above. - let instance = unsafe { &mut *instance.as_ptr() }; - let state = instance.get_mut(TableId::::new(rep))?; - if !matches!(&state.write, WriteState::Closed) { - state.writer_watcher = Some(tx); - } - Ok(()) - } - let (tx, mut rx) = mpsc::channel(1); let id = TableId::::new(rep); let run_on_drop = RunOnDrop::new(move || log::trace!("read event loop for {id:?} dropped")); + let token = StoreToken::new(store); let task = Box::pin( - { - let instance = SendSyncPtr::new(NonNull::new(self).unwrap()); - async move { - log::trace!("read event loop for {id:?} started"); - let mut my_rep = None; - while let Some(event) = rx.next().await { - // SAFETY: This future is only polled from - // `ComponentInstance::poll_until`, which has exclusive - // access to both the same `ComponentInstance` pointed - // to by `instance` and the store to which it belongs. - unsafe { - if my_rep.is_none() { - my_rep = Some(get_state_rep(instance, rep)?); - } - let rep = my_rep.unwrap(); - match event { - ReadEvent::Read { buffer, tx } => { - read::(instance, rep, buffer, tx)? - } - ReadEvent::Close => close(instance, rep)?, - ReadEvent::Watch { tx } => watch(instance, rep, tx)?, - } + async move { + log::trace!("read event loop for {id:?} started"); + let mut my_rep = None; + while let Some(event) = rx.next().await { + if my_rep.is_none() { + my_rep = Some(get_state_rep(rep)?); + } + let rep = my_rep.unwrap(); + match event { + ReadEvent::Read { buffer, tx } => { + super::with_local_instance(|store, instance| { + instance.host_read::<_, _, U>( + token.as_context_mut(store), + rep, + buffer, + tx, + ) + })? } + ReadEvent::Close => super::with_local_instance(|store, instance| { + instance.host_close_reader(store, rep) + })?, + ReadEvent::Watch { tx } => super::with_local_instance(|_, instance| { + let state = instance.get_mut(TableId::::new(rep))?; + if !matches!(&state.write, WriteState::Closed) { + state.writer_watcher = Some(tx); + } + Ok::<_, anyhow::Error>(()) + })?, } - Ok(()) } + Ok(()) } .map(move |v| { run_on_drop.cancel(); @@ -1781,11 +1728,9 @@ impl ComponentInstance { /// * `values` - List of values that should be written /// * `post_write` - Whether the transmit should be closed after write, possibly with an error context /// * `tx` - Oneshot channel to notify when operation completes (or drop on error) - /// - /// SAFETY: `self` must belong to a store whose data type parameter is `U`, - /// and the caller must confer exclusive access to that store. - unsafe fn host_write, U>( + fn host_write, U: 'static>( &mut self, + mut store: StoreContextMut, transmit_rep: u32, mut buffer: B, mut post_write: PostWrite, @@ -1808,11 +1753,7 @@ impl ComponentInstance { assert!(matches!(&transmit.write, WriteState::Open)); transmit.write = WriteState::HostReady { - // SAFETY: The closure we store here will only be called - // with a `Reader::Guest { .. }` parameter from - // `guest_read`, which upholds the requirements in - // `accept_reader`'s documentation. - accept: Box::new(unsafe { accept_reader::(buffer, tx) }), + accept: Box::new(accept_reader::(store, buffer, tx)), post_write, }; post_write = PostWrite::Continue; @@ -1828,10 +1769,8 @@ impl ComponentInstance { .. } => { let read_handle = transmit.read_handle; - // SAFETY: See the contract documented for this function and - // note that it covers the requirements specified in - // `accept_reader`'s documentation. - let code = unsafe { accept_reader::(buffer, tx) }( + let code = accept_reader::(store.as_context_mut(), buffer, tx)( + store.0.traitobj_mut(), self, Reader::Guest { lower: RawLowerContext { options: &options }, @@ -1851,17 +1790,14 @@ impl ComponentInstance { } ReadState::HostReady { accept } => { - // SAFETY: Per the requirements described in `accept_writer`'s - // documentation, we give up ownership of the items by calling - // `buffer.forget` immediately after the following call. + let count = buffer.remaining().len(); let code = accept(Writer::Host { - pointer: buffer.remaining().as_ptr().cast(), - count: buffer.remaining().len(), + buffer: &mut buffer, + count, })?; - let ReturnCode::Completed(n) = code else { + let ReturnCode::Completed(_) = code else { unreachable!() }; - buffer.forget(n.try_into().unwrap()); _ = tx.send(HostResult { buffer, @@ -1885,24 +1821,9 @@ impl ComponentInstance { } /// Attempt to read items from the specified stream or future. - /// - /// SAFETY: `self` must belong to a store whose data type parameter is `U`, - /// and the caller must confer exclusive access to that store. - /// - /// Also, note that when the `TransmitState::write` field of the state to - /// which the stream or future belongs is `WriteState::HostReady`, its - /// `accept` callback will be passed a `Reader::Host` whose `accept` closure - /// requries a valid `*mut T` array of `count` elements, and those elements - /// must be forgotten using e.g. `mem::forget` after the call to that - /// closure returns since they will have been moved into another buffer - /// (i.e. the destination buffer will take ownership of them). - // TODO: `Reader::Host::accept` should really be a `Box` - // (where `UnsafeFnOnce` would need to be a trait we define ourselves, since - // there's no standard equivalent) rather than a `Box`. That - // would force the caller to use an unsafe block and (hopefully) uphold the - // contract described above. - unsafe fn host_read, U>( + fn host_read, U: 'static>( &mut self, + store: StoreContextMut, rep: u32, mut buffer: B, tx: oneshot::Sender>, @@ -1938,17 +1859,9 @@ impl ComponentInstance { let write_handle = transmit.write_handle; let instance = self as *mut _; let types = self.component_types(); - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store, and - // per this function's contract, the caller has conferred - // exclusive access to that store. + // SAFETY: `instance` is derived from `self` and thus known to be valid. let lift = unsafe { - &mut LiftContext::new( - (*self.store()).store_opaque_mut(), - &options, - types, - instance, - ) + &mut LiftContext::new(store.0.store_opaque_mut(), &options, types, instance) }; let code = accept_writer::(buffer, tx)(Writer::Guest { lift, @@ -1981,15 +1894,12 @@ impl ComponentInstance { WriteState::HostReady { accept, post_write } => { accept( + store.0.traitobj_mut(), self, Reader::Host { - accept: Box::new(move |pointer, count| { + accept: Box::new(move |input, count| { let count = count.min(buffer.remaining_capacity()); - // SAFETY: Per the contact of `host_read`, `pointer` - // is a valid `*mut T` array of `count` elements - // which we may move (i.e. transfer ownership) into - // the destination buffer. - unsafe { buffer.copy_from(pointer.cast(), count) }; + buffer.move_from(input, count); _ = tx.send(HostResult { buffer, closed: false, @@ -2150,7 +2060,7 @@ impl ComponentInstance { /// /// * `transmit_rep` - A global-component-level representation of the transmit state for the reader that should be closed /// - fn host_close_reader(&mut self, transmit_rep: u32) -> Result<()> { + fn host_close_reader(&mut self, store: &mut dyn VMStore, transmit_rep: u32) -> Result<()> { let transmit_id = TableId::::new(transmit_rep); let transmit = self .get_mut(transmit_id) @@ -2202,7 +2112,7 @@ impl ComponentInstance { } WriteState::HostReady { accept, .. } => { - accept(self, Reader::End)?; + accept(store, self, Reader::End)?; } WriteState::Open => {} @@ -2217,11 +2127,9 @@ impl ComponentInstance { /// Copy `count` items from `read_address` to `write_address` for the /// specified stream or future. - /// - /// SAFETY: The caller must confer exclusive access to the store to which - /// `self` belongs, and the data type parameter for that store must be `T`. - unsafe fn copy( + fn copy( &mut self, + mut store: StoreContextMut, flat_abi: Option, write_ty: TableIndex, write_options: &Options, @@ -2237,7 +2145,7 @@ impl ComponentInstance { assert_eq!(count, 1); let instance = self as *mut _; - let types = self.component_types(); + let types = self.component_types().clone(); let val = types[types[write_ty].ty] .payload .map(|ty| { @@ -2247,15 +2155,13 @@ impl ComponentInstance { bail!("write pointer not aligned"); } - // SAFETY: This `ComponentInstance` belongs to the store - // in which it resides, so if it is valid then so is its - // store, and per this function's contract, the caller - // has conferred exclusive access to that store. + // SAFETY: `instance` is derived from `self` and thus + // known to be valid. let lift = unsafe { &mut LiftContext::new( - (*self.store()).store_opaque_mut(), + store.0.store_opaque_mut(), write_options, - types, + &types, instance, ) }; @@ -2272,40 +2178,35 @@ impl ComponentInstance { .transpose()?; if let Some(val) = val { - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store, - // and per this function's contract, the caller has - // conferred exclusive access to that store. - // - // Finally, per this function's contract, the data type of - // the store must be `T`. - let mut store = unsafe { StoreContextMut::(&mut *self.store().cast()) }; - // SAFETY: The instance pointer is valid and belongs to the - // store given that both were derived from `self`. - let lower = unsafe { - &mut LowerContext::new( - store.as_context_mut(), - read_options, - types, - instance, - ) - }; - let ty = types[types[read_ty].ty].payload.unwrap(); - let ptr = func::validate_inbounds_dynamic( - types.canonical_abi(&ty), - lower.as_slice_mut(), - &ValRaw::u32(read_address.try_into().unwrap()), - )?; - val.store(lower, ty, ptr)?; + store.with_attached_instance(self, |mut store, _| { + // SAFETY: `instance` is derived from `self` and thus + // known to be valid. + let lower = unsafe { + &mut LowerContext::new( + store.as_context_mut(), + read_options, + &types, + instance, + ) + }; + let ty = types[types[read_ty].ty].payload.unwrap(); + let ptr = func::validate_inbounds_dynamic( + types.canonical_abi(&ty), + lower.as_slice_mut(), + &ValRaw::u32(read_address.try_into().unwrap()), + )?; + val.store(lower, ty, ptr) + })?; } } (TableIndex::Stream(write_ty), TableIndex::Stream(read_ty)) => { let instance = self as *mut _; let types = self.component_types(); - // SAFETY: See the corresponding comment for the - // `TableIndex::Future` case above. - let store = (*self.store()).store_opaque_mut(); - let lift = unsafe { &mut LiftContext::new(store, write_options, types, instance) }; + let store_opaque = store.0.store_opaque_mut(); + // SAFETY: `instance` is derived from `self` and thus known to + // be valid. + let lift = + unsafe { &mut LiftContext::new(store_opaque, write_options, types, instance) }; if let Some(flat_abi) = flat_abi { // Fast path memcpy for "flat" (i.e. no pointers or handles) payloads: let length_in_bytes = usize::try_from(flat_abi.size).unwrap() * count; @@ -2319,7 +2220,7 @@ impl ComponentInstance { { let src = write_options - .memory(store) + .memory(store_opaque) .get(write_address..) .and_then(|b| b.get(..length_in_bytes)) .ok_or_else(|| { @@ -2327,7 +2228,7 @@ impl ComponentInstance { })? .as_ptr(); let dst = read_options - .memory_mut(store) + .memory_mut(store_opaque) .get_mut(read_address..) .and_then(|b| b.get_mut(..length_in_bytes)) .ok_or_else(|| { @@ -2359,35 +2260,38 @@ impl ComponentInstance { let id = TableId::::new(rep); log::trace!("copy values {values:?} for {id:?}"); - // SAFETY: See the corresponding comment for the - // `TableIndex::Future` case above. - let mut store = unsafe { StoreContextMut::(&mut *self.store().cast()) }; - // SAFETY: See the corresponding comment for the - // `TableIndex::Future` case above. - let lower = unsafe { - &mut LowerContext::new( - store.as_context_mut(), - read_options, - types, - instance, - ) - }; - let ty = types[types[read_ty].ty].payload.unwrap(); - let abi = lower.types.canonical_abi(&ty); - if read_address % usize::try_from(abi.align32)? != 0 { - bail!("read pointer not aligned"); - } - let size = usize::try_from(abi.size32).unwrap(); - lower - .as_slice_mut() - .get_mut(read_address..) - .and_then(|b| b.get_mut(..size * count)) - .ok_or_else(|| anyhow::anyhow!("read pointer out of bounds of memory"))?; - let mut ptr = read_address; - for value in values { - value.store(lower, ty, ptr)?; - ptr += size - } + let types = types.clone(); + store.with_attached_instance(self, |mut store, _| { + // SAFETY: `instance` is derived from `self` and thus + // known to be valid. + let lower = unsafe { + &mut LowerContext::new( + store.as_context_mut(), + read_options, + &types, + instance, + ) + }; + let ty = types[types[read_ty].ty].payload.unwrap(); + let abi = lower.types.canonical_abi(&ty); + if read_address % usize::try_from(abi.align32)? != 0 { + bail!("read pointer not aligned"); + } + let size = usize::try_from(abi.size32).unwrap(); + lower + .as_slice_mut() + .get_mut(read_address..) + .and_then(|b| b.get_mut(..size * count)) + .ok_or_else(|| { + anyhow::anyhow!("read pointer out of bounds of memory") + })?; + let mut ptr = read_address; + for value in values { + value.store(lower, ty, ptr)?; + ptr += size + } + Ok(()) + })?; } } _ => unreachable!(), @@ -2398,13 +2302,11 @@ impl ComponentInstance { /// Write to the specified stream or future from the guest. /// - /// SAFETY: The caller must confer exclusive access to the store to which - /// `self` belongs, and the data type parameter for that store must be `T`. - /// - /// Also, `memory` and `realloc` must be valid pointers to their respective - /// guest entities. - pub(super) unsafe fn guest_write( + /// SAFETY: `memory` and `realloc` must be valid pointers to their + /// respective guest entities. + pub(super) unsafe fn guest_write( &mut self, + store: StoreContextMut, memory: *mut VMMemoryDefinition, realloc: *mut VMFuncRef, string_encoding: u8, @@ -2421,16 +2323,11 @@ impl ComponentInstance { let address = usize::try_from(address).unwrap(); let count = usize::try_from(count).unwrap(); - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. - // - // Also see the function's contract concerning the validity of `memory` - // and `realloc`. + // SAFETY: Per this function's contract, `memory` and `realloc` are + // valid. let options = unsafe { Options::new( - (*self.store()).store_opaque().id(), + store.0.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), StringEncoding::from_u8(string_encoding).unwrap(), @@ -2490,7 +2387,8 @@ impl ComponentInstance { let count = count.min(read_count); - self.copy::( + self.copy( + store, flat_abi, ty, &options, @@ -2543,17 +2441,10 @@ impl ComponentInstance { ReadState::HostReady { accept } => { let instance = self as *mut _; let types = self.component_types(); - // SAFETY: This `ComponentInstance` belongs to the store in - // which it resides, so if it is valid then so is its store, and - // per this function's contract, the caller has conferred - // exclusive access to that store. + // SAFETY: `instance` is derived from `self` and thus known to + // be valid. let lift = unsafe { - &mut LiftContext::new( - (*self.store()).store_opaque_mut(), - &options, - types, - instance, - ) + &mut LiftContext::new(store.0.store_opaque_mut(), &options, types, instance) }; accept(Writer::Guest { lift, @@ -2580,13 +2471,11 @@ impl ComponentInstance { /// Read from the specified stream or future from the guest. /// - /// SAFETY: The caller must confer exclusive access to the store to which - /// `self` belongs, and the data type parameter for that store must be `T`. - /// - /// Also, `memory` and `realloc` must be valid pointers to their respective - /// guest entities. - pub(super) unsafe fn guest_read( + /// SAFETY: `memory` and `realloc` must be valid pointers to their + /// respective guest entities. + pub(super) unsafe fn guest_read( &mut self, + store: StoreContextMut, memory: *mut VMMemoryDefinition, realloc: *mut VMFuncRef, string_encoding: u8, @@ -2602,16 +2491,11 @@ impl ComponentInstance { } let address = usize::try_from(address).unwrap(); - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. - // - // Also see the function's contract concerning the validity of `memory` - // and `realloc`. + // SAFETY: Per this function's contract, `memory` and `realloc` must be + // valid. let options = unsafe { Options::new( - (*self.store()).store_opaque().id(), + store.0.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), StringEncoding::from_u8(string_encoding).unwrap(), @@ -2671,7 +2555,8 @@ impl ComponentInstance { let count = usize::try_from(count).unwrap().min(write_count); - self.copy::( + self.copy( + store, flat_abi, write_ty, &write_options, @@ -2729,6 +2614,7 @@ impl ComponentInstance { WriteState::HostReady { accept, post_write } => { let code = accept( + store.0.traitobj_mut(), self, Reader::Guest { lower: RawLowerContext { options: &options }, @@ -2839,7 +2725,12 @@ impl ComponentInstance { self.host_close_writer(transmit_rep) } - fn guest_close_readable(&mut self, ty: TableIndex, reader: u32) -> Result<()> { + fn guest_close_readable( + &mut self, + store: &mut dyn VMStore, + ty: TableIndex, + reader: u32, + ) -> Result<()> { let (rep, WaitableState::Stream(_, state) | WaitableState::Future(_, state)) = self.state_table(ty).remove_by_index(reader)? else { @@ -2855,18 +2746,16 @@ impl ComponentInstance { let id = TableId::::new(rep); let rep = self.get(id)?.state.rep(); log::trace!("guest_close_readable: close reader {id:?}"); - self.host_close_reader(rep) + self.host_close_reader(store, rep) } /// Create a new error context for the given component. /// - /// SAFETY: The caller must confer exclusive access to the store to which - /// `self` belongs, and the data type parameter for that store must be `T`. - /// - /// Also, `memory` and `realloc` must be valid pointers to their respective - /// guest entities. + /// SAFETY: `memory` and `realloc` must be valid pointers to their + /// respective guest entities. pub(crate) unsafe fn error_context_new( &mut self, + store: &mut dyn VMStore, memory: *mut VMMemoryDefinition, realloc: *mut VMFuncRef, string_encoding: u8, @@ -2874,16 +2763,11 @@ impl ComponentInstance { debug_msg_address: u32, debug_msg_len: u32, ) -> Result { - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. - // - // Also see the function's contract concerning the validity of `memory` - // and `realloc`. + // SAFETY: Per this function's contract, `memory` and `realloc` must be + // valid. let options = unsafe { Options::new( - (*self.store()).store_opaque().id(), + store.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), StringEncoding::from_u8(string_encoding).ok_or_else(|| { @@ -2894,13 +2778,10 @@ impl ComponentInstance { ) }; let interface = self as *mut _; - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. + // SAFETY: `instance` is derived from `self` and thus known to be valid. let lift_ctx = unsafe { &mut LiftContext::new( - (*self.store()).store_opaque_mut(), + store.store_opaque_mut(), &options, self.component_types(), interface, @@ -2928,12 +2809,8 @@ impl ComponentInstance { // Create a new ErrorContext that is tracked along with other concurrent state let err_ctx = ErrorContextState { - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. debug_msg: s - .to_str_from_memory(options.memory(unsafe { (*self.store()).store_opaque() }))? + .to_str_from_memory(options.memory(store.store_opaque()))? .to_string(), }; let table_id = self.push(err_ctx)?; @@ -2966,13 +2843,11 @@ impl ComponentInstance { /// Retrieve the debug message from the specified error context. /// - /// SAFETY: The caller must confer exclusive access to the store to which - /// `self` belongs, and the data type parameter for that store must be `T`. - /// - /// Also, `memory` and `realloc` must be valid pointers to their respective - /// guest entities. - pub(super) unsafe fn error_context_debug_message( + /// SAFETY: `memory` and `realloc` must be valid pointers to their + /// respective guest entities. + pub(super) unsafe fn error_context_debug_message( &mut self, + mut store: StoreContextMut, memory: *mut VMMemoryDefinition, realloc: *mut VMFuncRef, string_encoding: u8, @@ -2992,16 +2867,11 @@ impl ComponentInstance { self.get_mut(TableId::::new(state_table_id_rep))?; let debug_msg = debug_msg.clone(); - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. - // - // Also see the function's contract concerning the validity of `memory` - // and `realloc`. + // SAFETY: Per this function's contract, `memory` and `realloc` are + // valid. let options = unsafe { Options::new( - (*self.store()).store_opaque().id(), + store.0.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), StringEncoding::from_u8(string_encoding).ok_or_else(|| { @@ -3011,30 +2881,23 @@ impl ComponentInstance { None, ) }; - // SAFETY: This `ComponentInstance` belongs to the store in which it - // resides, so if it is valid then so is its store, and per this - // function's contract, the caller has conferred exclusive access to - // that store. - // - // Finally, per this function's contract, the data type of the store - // must be `T`. - let store = unsafe { StoreContextMut::(&mut *self.store().cast()) }; let interface = self as *mut _; - // SAFETY: The instance pointer is valid and belongs to the store given - // that both were derived from `self`. - let lower_cx = - unsafe { &mut LowerContext::new(store, &options, self.component_types(), interface) }; - let debug_msg_address = usize::try_from(debug_msg_address)?; - // Lower the string into the component's memory - let offset = lower_cx - .as_slice_mut() - .get(debug_msg_address..) - .and_then(|b| b.get(..debug_msg.bytes().len())) - .map(|_| debug_msg_address) - .ok_or_else(|| anyhow::anyhow!("invalid debug message pointer: out of bounds"))?; - debug_msg - .as_str() - .store(lower_cx, InterfaceType::String, offset)?; + let types = self.component_types().clone(); + store.with_attached_instance(self, |store, _| { + // SAFETY: `instance` is derived from `self` and thus known to be valid. + let lower_cx = unsafe { &mut LowerContext::new(store, &options, &types, interface) }; + let debug_msg_address = usize::try_from(debug_msg_address)?; + // Lower the string into the component's memory + let offset = lower_cx + .as_slice_mut() + .get(debug_msg_address..) + .and_then(|b| b.get(..debug_msg.bytes().len())) + .map(|_| debug_msg_address) + .ok_or_else(|| anyhow::anyhow!("invalid debug message pointer: out of bounds"))?; + debug_msg + .as_str() + .store(lower_cx, InterfaceType::String, offset) + })?; Ok(()) } @@ -3155,10 +3018,11 @@ impl ComponentInstance { pub(crate) fn future_close_readable( &mut self, + store: &mut dyn VMStore, ty: TypeFutureTableIndex, reader: u32, ) -> Result<()> { - self.guest_close_readable(TableIndex::Future(ty), reader) + self.guest_close_readable(store, TableIndex::Future(ty), reader) } pub(crate) fn stream_new(&mut self, ty: TypeStreamTableIndex) -> Result { @@ -3195,10 +3059,11 @@ impl ComponentInstance { pub(crate) fn stream_close_readable( &mut self, + store: &mut dyn VMStore, ty: TypeStreamTableIndex, reader: u32, ) -> Result<()> { - self.guest_close_readable(TableIndex::Stream(ty), reader) + self.guest_close_readable(store, TableIndex::Stream(ty), reader) } pub(crate) fn future_transfer( diff --git a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs index f3cda4dac8..9d6fde4cd6 100644 --- a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs +++ b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs @@ -1,6 +1,7 @@ use { bytes::{Bytes, BytesMut}, std::{ + any::TypeId, io::Cursor, mem::{self, MaybeUninit}, ptr, slice, @@ -8,15 +9,27 @@ use { }, }; +/// Trait representing a buffer from which items may be moved (i.e. ownership +/// transferred). +/// +/// SAFETY: `Self::take` must verify the requested number of items are +/// available, must pass a `TypeId` corresponding to the type of items being +/// taken, and must `mem::forget` those items after the call to `fun` returns. +pub unsafe trait TakeBuffer { + /// Take ownership of the specified number of items. + /// + /// The items are passed to `fun` as a raw pointer which may be cast to the + /// type indicated by the specified `TypeId`. + fn take(&mut self, count: usize, fun: &mut dyn FnMut(TypeId, *const u8)); +} + /// Trait representing a buffer which may be written to a `StreamWriter`. #[doc(hidden)] -pub trait WriteBuffer: Send + Sync + 'static { +pub trait WriteBuffer: TakeBuffer + Send + Sync + 'static { /// Slice of items remaining to be read. fn remaining(&self) -> &[T]; /// Skip and drop the specified number of items. fn skip(&mut self, count: usize); - /// Skip and forget (i.e. do _not_ drop) the specified number of items. - fn forget(&mut self, count: usize); } /// Trait representing a buffer which may be used to read from a `StreamReader`. @@ -28,10 +41,8 @@ pub trait ReadBuffer: Send + Sync + 'static { fn remaining_capacity(&self) -> usize; /// Move (i.e. take ownership of) the specified items into this buffer. /// - /// SAFETY: `input` must be a valid `*const T` array of `count` items on - /// entry. Those items will be invalidated on exit and must be forgotten - /// using e.g. `mem::forget` to avoid unsoundness. - unsafe fn copy_from(&mut self, input: *const T, count: usize); + /// This will panic if the specified `input` item type does not match `T`. + fn move_from(&mut self, input: &mut dyn TakeBuffer, count: usize); } pub(super) struct Extender<'a, B>(pub(super) &'a mut B); @@ -42,6 +53,20 @@ impl> Extend for Extender<'_, B> { } } +unsafe impl TakeBuffer for Option { + fn take(&mut self, count: usize, fun: &mut dyn FnMut(TypeId, *const u8)) { + match count { + 0 => fun(TypeId::of::(), ptr::null_mut()), + 1 => { + assert!(self.is_some()); + fun(TypeId::of::(), self.remaining().as_ptr().cast()); + mem::forget(self.take()); + } + _ => panic!("cannot forget more than {} item(s)", self.remaining().len()), + } + } +} + impl WriteBuffer for Option { fn remaining(&self) -> &[T] { if let Some(me) = self { @@ -63,17 +88,6 @@ impl WriteBuffer for Option { _ => panic!("cannot skip more than {} item(s)", self.remaining().len()), } } - - fn forget(&mut self, count: usize) { - match count { - 0 => {} - 1 => { - assert!(self.is_some()); - mem::forget(self.take()); - } - _ => panic!("cannot forget more than {} item(s)", self.remaining().len()), - } - } } impl ReadBuffer for Option { @@ -93,13 +107,18 @@ impl ReadBuffer for Option { } } - /// SAFETY: See trait docs. - unsafe fn copy_from(&mut self, input: *const T, count: usize) { + fn move_from(&mut self, input: &mut dyn TakeBuffer, count: usize) { match count { 0 => {} 1 => { assert!(self.is_none()); - *self = Some(input.read()); + input.take(1, &mut |id, ptr| { + assert_eq!(TypeId::of::(), id); + // SAFETY: Per the `TakeBuffer` implementation contract and + // the above assertion, the types match and we have been + // given ownership of the item. + unsafe { *self = Some(ptr.cast::().read()) }; + }); } _ => panic!( "cannot take more than {} item(s)", @@ -149,6 +168,14 @@ impl VecBuffer { } } +unsafe impl TakeBuffer for VecBuffer { + fn take(&mut self, count: usize, fun: &mut dyn FnMut(TypeId, *const u8)) { + assert!(count <= self.remaining().len()); + fun(TypeId::of::(), self.remaining().as_ptr().cast()); + self.offset = self.offset.checked_add(count).unwrap(); + } +} + impl WriteBuffer for VecBuffer { fn remaining(&self) -> &[T] { self.remaining_() @@ -157,11 +184,6 @@ impl WriteBuffer for VecBuffer { fn skip(&mut self, count: usize) { self.skip_(count) } - - fn forget(&mut self, count: usize) { - assert!(count <= self.remaining().len()); - self.offset = self.offset.checked_add(count).unwrap(); - } } impl From> for VecBuffer { @@ -190,11 +212,26 @@ impl ReadBuffer for Vec { self.capacity().checked_sub(self.len()).unwrap() } - /// SAFETY: See trait docs. - unsafe fn copy_from(&mut self, input: *const T, count: usize) { + fn move_from(&mut self, input: &mut dyn TakeBuffer, count: usize) { assert!(count <= self.remaining_capacity()); - ptr::copy(input, self.as_mut_ptr().add(self.len()), count); - self.set_len(self.len() + count); + input.take(count, &mut |id, ptr| { + assert_eq!(TypeId::of::(), id); + // SAFETY: Per the `TakeBuffer` implementation contract and the + // above assertion, the types match and we have been given ownership + // of the items. + unsafe { + ptr::copy(ptr.cast::(), self.as_mut_ptr().add(self.len()), count); + self.set_len(self.len() + count); + } + }); + } +} + +unsafe impl TakeBuffer for Cursor { + fn take(&mut self, count: usize, fun: &mut dyn FnMut(TypeId, *const u8)) { + assert!(count <= self.remaining().len()); + fun(TypeId::of::(), self.remaining().as_ptr().cast()); + self.skip(count); } } @@ -204,16 +241,24 @@ impl WriteBuffer for Cursor { } fn skip(&mut self, count: usize) { - assert!(count <= self.remaining().len()); + assert!( + count <= self.remaining().len(), + "tried to skip {count} with {} remaining", + self.remaining().len() + ); self.set_position( self.position() .checked_add(u64::try_from(count).unwrap()) .unwrap(), ); } +} - fn forget(&mut self, count: usize) { - self.skip(count) +unsafe impl TakeBuffer for Cursor { + fn take(&mut self, count: usize, fun: &mut dyn FnMut(TypeId, *const u8)) { + assert!(count <= self.remaining().len()); + fun(TypeId::of::(), self.remaining().as_ptr().cast()); + self.skip(count); } } @@ -230,10 +275,6 @@ impl WriteBuffer for Cursor { .unwrap(), ); } - - fn forget(&mut self, count: usize) { - self.skip(count) - } } impl ReadBuffer for BytesMut { @@ -245,10 +286,16 @@ impl ReadBuffer for BytesMut { self.capacity().checked_sub(self.len()).unwrap() } - /// SAFETY: See trait docs. - unsafe fn copy_from(&mut self, input: *const u8, count: usize) { + fn move_from(&mut self, input: &mut dyn TakeBuffer, count: usize) { assert!(count <= self.remaining_capacity()); - ptr::copy(input, self.as_mut_ptr().add(self.len()), count); - self.set_len(self.len() + count); + input.take(count, &mut |id, ptr| { + assert_eq!(TypeId::of::(), id); + // SAFETY: Per the `TakeBuffer` implementation contract and the + // above assertion, the types match. + unsafe { + ptr::copy(ptr, self.as_mut_ptr().add(self.len()), count); + self.set_len(self.len() + count); + } + }); } } diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rs index 2d93857333..9b5cd94fcb 100644 --- a/crates/wasmtime/src/runtime/component/func.rs +++ b/crates/wasmtime/src/runtime/component/func.rs @@ -18,7 +18,7 @@ use wasmtime_environ::component::{ #[cfg(feature = "component-model-async")] use crate::component::concurrent::{self, PreparedCall}; #[cfg(feature = "component-model-async")] -use crate::VMStore; +use crate::runtime::vm::component::ComponentInstance; #[cfg(feature = "component-model-async")] use core::any::Any; #[cfg(feature = "component-model-async")] @@ -319,7 +319,7 @@ impl Func { /// only works with functions defined within an asynchronous store. Also /// panics if `store` does not own this function. #[cfg(feature = "async")] - pub async fn call_async( + pub async fn call_async( &self, mut store: impl AsContextMut, params: &[Val], @@ -374,7 +374,7 @@ impl Func { /// `Instance::spawn` to poll it from within the event loop. See /// [`Instance::run`] for examples. #[cfg(feature = "component-model-async")] - pub fn call_concurrent( + pub fn call_concurrent( self, mut store: impl AsContextMut, params: Vec, @@ -415,7 +415,7 @@ impl Func { /// /// SAFETY: See `concurrent::prepare_call`. #[cfg(feature = "component-model-async")] - unsafe fn prepare_call_dynamic<'a, T: Send>( + unsafe fn prepare_call_dynamic<'a, T: Send + 'static>( self, mut store: StoreContextMut<'a, T>, drop_params: unsafe fn(*mut u8), @@ -782,23 +782,23 @@ impl Func { /// Equivalent to `lower_args`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. Also, `params_in` must be a valid pointer to a - /// `MaybeUninit<[ValRaw; MAX_FLAT_PARAMS]>`. + /// SAFETY: `params_in` must be a valid pointer to a `MaybeUninit<[ValRaw; + /// MAX_FLAT_PARAMS]>`. #[cfg(feature = "component-model-async")] unsafe fn lower_args_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, params_in: *mut u8, params_out: &mut [MaybeUninit], ) -> Result<()> { lower_params( store, + instance, params_out, func, // SAFETY: Per this function's precondition, `params_in` is a valid - // pointer to a `Self::Params`. + // pointer to a `MaybeUninit<[ValRaw; MAX_FLAT_PARAMS]>`. unsafe { &*params_in.cast() }, Self::lower_args::, ) @@ -833,17 +833,14 @@ impl Func { /// Equivalent to `lift_results_sync`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. - /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. #[cfg(feature = "component-model-async")] - unsafe fn lift_results_sync_fn( + fn lift_results_sync_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, results: &[ValRaw], ) -> Result> { - lift_results::<_, T, _>(store, results, func, Self::lift_results_sync) + lift_results(store, instance, results, func, Self::lift_results_sync) } #[cfg(feature = "component-model-async")] @@ -857,17 +854,14 @@ impl Func { /// Equivalent to `lift_results_async`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. - /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. #[cfg(feature = "component-model-async")] - unsafe fn lift_results_async_fn( + fn lift_results_async_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, results: &[ValRaw], ) -> Result> { - lift_results::<_, T, _>(store, results, func, Self::lift_results_async) + lift_results(store, instance, results, func, Self::lift_results_async) } fn lift_results( @@ -928,11 +922,8 @@ impl Func { } /// Lower parameters of the specified type using the specified function. -/// -/// SAFETY: `store` must be a valid pointer to a store with data type parameter -/// `T`, and the caller must confer exclusive access to that store. #[cfg(feature = "component-model-async")] -unsafe fn lower_params< +fn lower_params< Params, LowerParams, T, @@ -945,7 +936,8 @@ unsafe fn lower_params< + Send + Sync, >( - store: *mut dyn crate::vm::VMStore, + mut store: StoreContextMut, + instance: &mut ComponentInstance, lowered: &mut [MaybeUninit], me: Func, params: &Params, @@ -953,26 +945,20 @@ unsafe fn lower_params< ) -> Result<()> { use crate::component::storage::slice_to_storage_mut; - // SAFETY: Per the function contract documented above, we have exclusive - // access to the store and the data type parameters is `T`. - let mut store = unsafe { StoreContextMut::(&mut *store.cast()) }; let FuncData { options, - instance, component_instance, ty, .. } = store.0[me.0]; - let instance = store.0[instance.0].as_ref().unwrap(); let types = instance.component_types().clone(); - let instance_ptr = instance.instance_ptr(); - let mut flags = instance.instance().instance_flags(component_instance); + let instance_ptr = instance as *mut _; + let mut flags = instance.instance_flags(component_instance); - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the - // store, including the one we pass to `LowerContext::new` below. - unsafe { + // SAFETY: `instance_ptr` is derived from `instance` and thus known to be + // valid. + store.with_attached_instance(instance, |mut store, _| unsafe { if !flags.may_enter() { bail!(crate::Trap::CannotEnterComponent); } @@ -994,41 +980,29 @@ unsafe fn lower_params< } Ok(()) - } + }) } /// Lift results of the specified type using the specified function. -/// -/// SAFETY: `store` must be a valid pointer to a store with data type parameter -/// `T`, and the caller must confer exclusive access to that store. #[cfg(feature = "component-model-async")] -unsafe fn lift_results< +fn lift_results< Return: Send + Sync + 'static, T, F: FnOnce(&mut LiftContext, InterfaceType, &[ValRaw]) -> Result + Send + Sync, >( - store: *mut dyn crate::vm::VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, lowered: &[ValRaw], me: Func, lift: F, ) -> Result> { - // SAFETY: Per the function contract documented above, we have exclusive - // access to the store and the data type parameters is `T`. - let store = unsafe { StoreContextMut::(&mut *store.cast()) }; - let FuncData { - options, - instance, - ty, - .. - } = store.0[me.0]; + let FuncData { options, ty, .. } = store.0[me.0]; - let instance = store.0[instance.0].as_ref().unwrap(); let types = instance.component_types().clone(); - let instance_ptr = instance.instance_ptr(); + let instance_ptr = instance as *mut _; - // SAFETY: We have exclusive access to the store, which we means we have - // exclusive access to any `ComponentInstance` which resides in the store, - // including the one we pass to `LiftContext::new` below. + // SAFETY: `instance_ptr` is derived from `instance` and thus known to be + // valid. unsafe { Ok(Box::new(lift( &mut LiftContext::new(store.0, &options, &types, instance_ptr), diff --git a/crates/wasmtime/src/runtime/component/func/host.rs b/crates/wasmtime/src/runtime/component/func/host.rs index 526c43cb45..818ac47a24 100644 --- a/crates/wasmtime/src/runtime/component/func/host.rs +++ b/crates/wasmtime/src/runtime/component/func/host.rs @@ -10,7 +10,7 @@ use crate::runtime::vm::component::{ }; use crate::runtime::vm::SendSyncPtr; use crate::runtime::vm::{VMFuncRef, VMGlobalDefinition, VMMemoryDefinition, VMOpaqueContext}; -use crate::{CallHook, StoreContextMut, ValRaw}; +use crate::{AsContextMut, CallHook, StoreContextMut, VMStore, ValRaw}; use alloc::sync::Arc; use core::any::Any; use core::future::Future; @@ -36,9 +36,10 @@ impl core::fmt::Debug for HostFunc { } impl HostFunc { - fn from_canonical(func: F) -> Arc + fn from_canonical(func: F) -> Arc where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, P, ) -> Pin> + Send + 'static>> @@ -56,27 +57,20 @@ impl HostFunc { }) } - pub(crate) fn from_closure(func: F) -> Arc + pub(crate) fn from_closure(func: F) -> Arc where F: Fn(StoreContextMut, P) -> Result + Send + Sync + 'static, P: ComponentNamedList + Lift + Send + Sync + 'static, R: ComponentNamedList + Lower + Send + Sync + 'static, { - Self::from_canonical::(move |instance, params| { - // SAFETY: This relies on `from_closure` being called from - // `LinkerInstance::<'_, T>::func_wrap`, ensuring it is only used - // with a store with a data type parameter of `T`. In addition, - // this closure will only be called via `Self::entrypoint`, which - // confers exclusive access to the store via its `VMOpaqueContext` - // parameter. - let store = unsafe { StoreContextMut(&mut *instance.store().cast()) }; - let result = func(store, params); + Self::from_canonical::(move |mut store, instance, params| { + let result = store.with_attached_instance(instance, |store, _| func(store, params)); Box::pin(async move { result }) }) } #[cfg(feature = "component-model-async")] - pub(crate) fn from_concurrent(func: F) -> Arc + pub(crate) fn from_concurrent(func: F) -> Arc where T: 'static, F: for<'a> Fn( @@ -90,18 +84,12 @@ impl HostFunc { R: ComponentNamedList + Lower + Send + Sync + 'static, { let func = Arc::new(func); - Self::from_canonical::(move |instance, params| { - // SAFETY: This relies on `from_closure` being called from - // `LinkerInstance::<'_, T>::func_wrap_concurrent`, ensuring it is - // only used with a store with a data type parameter of `T`. In - // addition, this closure will only be called via - // `Self::entrypoint`, which confers exclusive access to the store - // via its `VMOpaqueContext` parameter. - unsafe { instance.wrap_call(func.clone(), params) } + Self::from_canonical::(move |store, instance, params| { + instance.wrap_call(store, func.clone(), params) }) } - extern "C" fn entrypoint( + extern "C" fn entrypoint( cx: NonNull, data: NonNull, ty: u32, @@ -116,6 +104,7 @@ impl HostFunc { ) -> bool where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, P, ) -> Pin> + Send + 'static>> @@ -127,8 +116,9 @@ impl HostFunc { { let data = SendSyncPtr::new(NonNull::new(data.as_ptr() as *mut F).unwrap()); unsafe { - call_host_and_handle_result::(cx, |instance, types| { + call_host_and_handle_result::(cx, |store, instance, types| { call_host::( + store, instance, types, TypeFuncIndex::from_u32(ty), @@ -139,15 +129,16 @@ impl HostFunc { StringEncoding::from_u8(string_encoding).unwrap(), async_ != 0, NonNull::slice_from_raw_parts(storage, storage_len).as_mut(), - move |instance, args| (*data.as_ptr())(instance, args), + move |store, instance, args| (*data.as_ptr())(store, instance, args), ) }) } } - fn new_dynamic_canonical(func: F) -> Arc + fn new_dynamic_canonical(func: F) -> Arc where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, Vec, usize, @@ -167,29 +158,26 @@ impl HostFunc { }) } - pub(crate) fn new_dynamic(func: F) -> Arc + pub(crate) fn new_dynamic(func: F) -> Arc where F: Fn(StoreContextMut<'_, T>, &[Val], &mut [Val]) -> Result<()> + Send + Sync + 'static, { - Self::new_dynamic_canonical::(move |instance, params: Vec, result_count| { - let mut results = iter::repeat(Val::Bool(false)) - .take(result_count) - .collect::>(); - // SAFETY: This relies on `new_dynamic` being called from - // `LinkerInstance::<'_, T>::func_new`, ensuring it is only used - // with a store with a data type parameter of `T`. In addition, - // this closure will only be called via `dynamic_entrypoint`, which - // confers exclusive access to the store via its `VMOpaqueContext` - // parameter. - let store = unsafe { StoreContextMut(&mut *instance.store().cast()) }; - let result = func(store, ¶ms, &mut results); - let result = result.map(move |()| results); - Box::pin(async move { result }) - }) + Self::new_dynamic_canonical::( + move |mut store, instance, params: Vec, result_count| { + let mut results = iter::repeat(Val::Bool(false)) + .take(result_count) + .collect::>(); + let result = store.with_attached_instance(instance, |store, _| { + func(store, ¶ms, &mut results) + }); + let result = result.map(move |()| results); + Box::pin(async move { result }) + }, + ) } #[cfg(feature = "component-model-async")] - pub(crate) fn new_dynamic_concurrent(func: F) -> Arc + pub(crate) fn new_dynamic_concurrent(func: F) -> Arc where T: 'static, F: for<'a> Fn( @@ -201,8 +189,8 @@ impl HostFunc { + 'static, { let func = Arc::new(func); - Self::new_dynamic_canonical::(move |instance, params, _| unsafe { - (*instance).wrap_call(func.clone(), params) + Self::new_dynamic_canonical::(move |store, instance, params, _| { + instance.wrap_call(store, func.clone(), params) }) } @@ -252,7 +240,8 @@ where /// This function is in general `unsafe` as the validity of all the parameters /// must be upheld. Generally that's done by ensuring this is only called from /// the select few places it's intended to be called from. -unsafe fn call_host( +unsafe fn call_host( + mut store: StoreContextMut, instance: &mut ComponentInstance, types: &Arc, ty: TypeFuncIndex, @@ -267,6 +256,7 @@ unsafe fn call_host( ) -> Result<()> where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, Params, ) -> Pin> + Send + 'static>> @@ -295,7 +285,7 @@ where } let options = Options::new( - (*instance.store()).store_opaque().id(), + store.0.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), string_encoding, @@ -321,30 +311,31 @@ where let retptr = storage[1].assume_init(); let params = { - let lift = &mut LiftContext::new( - (*instance.store()).store_opaque_mut(), - &options, - types, - instance, - ); + let lift = + &mut LiftContext::new(store.0.store_opaque_mut(), &options, types, instance); lift.enter_call(); let ptr = validate_inbounds::(lift.memory(), ¶mptr)?; Params::load(lift, param_tys, &lift.memory()[ptr..][..Params::SIZE32])? }; - let future = closure(instance, params); + let future = closure(store.as_context_mut(), instance, params); let instance_ptr = SendSyncPtr::new(NonNull::new(instance).unwrap()); - let task = instance.first_poll(future, caller_instance, { + let task = instance.first_poll(store, future, caller_instance, { let types = types.clone(); - move |cx: StoreContextMut, ret: Return| { - flags.set_may_leave(false); - let mut lower = LowerContext::new(cx, &options, &types, instance_ptr.as_ptr()); - let ptr = validate_inbounds::(lower.as_slice_mut(), &retptr)?; - ret.store(&mut lower, result_tys, ptr)?; - flags.set_may_leave(true); - lower.exit_call()?; - Ok(()) + move |mut store: StoreContextMut, + instance: &mut ComponentInstance, + ret: Return| { + store.with_attached_instance(instance, |store, _| unsafe { + flags.set_may_leave(false); + let mut lower = + LowerContext::new(store, &options, &types, instance_ptr.as_ptr()); + let ptr = validate_inbounds::(lower.as_slice_mut(), &retptr)?; + ret.store(&mut lower, result_tys, ptr)?; + flags.set_may_leave(true); + lower.exit_call()?; + Ok(()) + }) } })?; @@ -387,29 +378,22 @@ where Storage::Indirect(slice_to_storage_mut(storage).assume_init_ref()) } }; - let mut lift = LiftContext::new( - (*instance.store()).store_opaque_mut(), - &options, - types, - instance, - ); + let mut lift = LiftContext::new(store.0.store_opaque_mut(), &options, types, instance); lift.enter_call(); let params = storage.lift_params(&mut lift, param_tys)?; - let future = closure(instance, params); + let future = closure(store.as_context_mut(), instance, params); - let ret = (*instance).poll_and_block(future, caller_instance)?; + let ret = instance.poll_and_block(store.0.traitobj_mut(), future, caller_instance)?; - flags.set_may_leave(false); - let mut lower = LowerContext::new( - StoreContextMut::(&mut *instance.store().cast()), - &options, - types, - instance, - ); - storage.lower_results(&mut lower, result_tys, ret)?; - flags.set_may_leave(true); - lower.exit_call()?; + let instance_ptr = instance as *mut _; + store.with_attached_instance(instance, |store, _| unsafe { + flags.set_may_leave(false); + let mut lower = LowerContext::new(store, &options, types, instance_ptr); + storage.lower_results(&mut lower, result_tys, ret)?; + flags.set_may_leave(true); + lower.exit_call() + })?; } return Ok(()); @@ -483,23 +467,22 @@ pub(crate) fn validate_inbounds(memory: &[u8], ptr: &ValRaw) - unsafe fn call_host_and_handle_result( cx: NonNull, - func: impl FnOnce(&mut ComponentInstance, &Arc) -> Result<()>, + func: impl FnOnce(StoreContextMut, &mut ComponentInstance, &Arc) -> Result<()>, ) -> bool { - let cx = VMComponentContext::from_opaque(cx); - let instance_ptr = cx.as_ref().instance(); - let types = (*instance_ptr).component_types(); - let instance = &mut *instance_ptr; - let store = unsafe { StoreContextMut::(&mut *instance.store().cast()) }; - - crate::runtime::vm::catch_unwind_and_record_trap(|| { - store.0.call_hook(CallHook::CallingHost)?; - let res = func(instance, types); - store.0.call_hook(CallHook::ReturningFromHost)?; - res + ComponentInstance::from_vmctx(VMComponentContext::from_opaque(cx), |store, instance| { + crate::runtime::vm::catch_unwind_and_record_trap(|| { + let mut store = StoreContextMut::(&mut *(store as *mut dyn VMStore).cast()); + store.0.call_hook(CallHook::CallingHost)?; + let types = instance.component_types().clone(); + let res = func(store.as_context_mut(), instance, &types); + store.0.call_hook(CallHook::ReturningFromHost)?; + res + }) }) } -unsafe fn call_host_dynamic( +unsafe fn call_host_dynamic( + mut store: StoreContextMut, instance: &mut ComponentInstance, types: &Arc, ty: TypeFuncIndex, @@ -514,6 +497,7 @@ unsafe fn call_host_dynamic( ) -> Result<()> where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, Vec, usize, @@ -523,7 +507,7 @@ where + 'static, { let options = Options::new( - (*instance.store()).store_opaque().id(), + store.0.store_opaque().id(), NonNull::new(memory), NonNull::new(realloc), string_encoding, @@ -552,12 +536,8 @@ where let retptr = storage[1].assume_init(); let params = { - let mut lift = &mut LiftContext::new( - (*instance.store()).store_opaque_mut(), - &options, - types, - instance, - ); + let mut lift = + &mut LiftContext::new(store.0.store_opaque_mut(), &options, types, instance); lift.enter_call(); let mut offset = validate_inbounds_dynamic(¶m_tys.abi, lift.memory(), ¶mptr)?; @@ -573,34 +553,46 @@ where .collect::>>()? }; - let future = closure(instance, params, result_tys.types.len()); + let future = closure( + store.as_context_mut(), + instance, + params, + result_tys.types.len(), + ); let instance_ptr = SendSyncPtr::new(NonNull::new(instance).unwrap()); - let task = instance.first_poll(future, caller_instance, { + let task = instance.first_poll(store, future, caller_instance, { let types = types.clone(); let result_tys = func_ty.results; - move |store: StoreContextMut, result_vals: Vec| { + move |mut store: StoreContextMut, + instance: &mut ComponentInstance, + result_vals: Vec| { let result_tys = &types[result_tys]; if result_vals.len() != result_tys.types.len() { bail!("result length mismatch"); } - flags.set_may_leave(false); + store.with_attached_instance(instance, |store, _| unsafe { + flags.set_may_leave(false); - let mut lower = - LowerContext::new(store, &options, &types, instance_ptr.as_ptr()); - let mut ptr = - validate_inbounds_dynamic(&result_tys.abi, lower.as_slice_mut(), &retptr)?; - for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { - let offset = types.canonical_abi(ty).next_field32_size(&mut ptr); - val.store(&mut lower, *ty, offset)?; - } + let mut lower = + LowerContext::new(store, &options, &types, instance_ptr.as_ptr()); + let mut ptr = validate_inbounds_dynamic( + &result_tys.abi, + lower.as_slice_mut(), + &retptr, + )?; + for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { + let offset = types.canonical_abi(ty).next_field32_size(&mut ptr); + val.store(&mut lower, *ty, offset)?; + } - flags.set_may_leave(true); + flags.set_may_leave(true); - lower.exit_call()?; + lower.exit_call()?; - Ok(()) + Ok(()) + }) } })?; @@ -620,12 +612,7 @@ where ); } } else { - let mut cx = LiftContext::new( - (*instance.store()).store_opaque_mut(), - &options, - types, - instance, - ); + let mut cx = LiftContext::new(store.0.store_opaque_mut(), &options, types, instance); cx.enter_call(); if let Some(param_count) = param_tys.abi.flat_count(MAX_FLAT_PARAMS) { // NB: can use `MaybeUninit::slice_assume_init_ref` when that's stable @@ -657,35 +644,40 @@ where ret_index = 1; }; - let future = closure(instance, args, result_tys.types.len()); - let result_vals = (*instance).poll_and_block(future, caller_instance)?; - - flags.set_may_leave(false); - - let mut cx = LowerContext::new( - StoreContextMut::(&mut *instance.store().cast()), - &options, - types, + let future = closure( + store.as_context_mut(), instance, + args, + result_tys.types.len(), ); - if let Some(cnt) = result_tys.abi.flat_count(MAX_FLAT_RESULTS) { - let mut dst = storage[..cnt].iter_mut(); - for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { - val.lower(&mut cx, *ty, &mut dst)?; - } - assert!(dst.next().is_none()); - } else { - let ret_ptr = storage[ret_index].assume_init_ref(); - let mut ptr = validate_inbounds_dynamic(&result_tys.abi, cx.as_slice_mut(), ret_ptr)?; - for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { - let offset = types.canonical_abi(ty).next_field32_size(&mut ptr); - val.store(&mut cx, *ty, offset)?; + let result_vals = + (*instance).poll_and_block(store.0.traitobj_mut(), future, caller_instance)?; + + let instance_ptr = instance as *mut _; + store.with_attached_instance(instance, |store, _| unsafe { + flags.set_may_leave(false); + + let mut cx = LowerContext::new(store, &options, types, instance_ptr); + if let Some(cnt) = result_tys.abi.flat_count(MAX_FLAT_RESULTS) { + let mut dst = storage[..cnt].iter_mut(); + for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { + val.lower(&mut cx, *ty, &mut dst)?; + } + assert!(dst.next().is_none()); + } else { + let ret_ptr = storage[ret_index].assume_init_ref(); + let mut ptr = + validate_inbounds_dynamic(&result_tys.abi, cx.as_slice_mut(), ret_ptr)?; + for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) { + let offset = types.canonical_abi(ty).next_field32_size(&mut ptr); + val.store(&mut cx, *ty, offset)?; + } } - } - flags.set_may_leave(true); + flags.set_may_leave(true); - cx.exit_call()?; + cx.exit_call() + })?; } return Ok(()); @@ -711,7 +703,7 @@ pub(crate) fn validate_inbounds_dynamic( Ok(ptr) } -extern "C" fn dynamic_entrypoint( +extern "C" fn dynamic_entrypoint( cx: NonNull, data: NonNull, ty: u32, @@ -726,6 +718,7 @@ extern "C" fn dynamic_entrypoint( ) -> bool where F: for<'a> Fn( + StoreContextMut<'a, T>, &mut ComponentInstance, Vec, usize, @@ -736,8 +729,9 @@ where { let data = SendSyncPtr::new(NonNull::new(data.as_ptr() as *mut F).unwrap()); unsafe { - call_host_and_handle_result::(cx, |instance, types| { + call_host_and_handle_result::(cx, |store, instance, types| { call_host_dynamic::( + store, instance, types, TypeFuncIndex::from_u32(ty), @@ -748,7 +742,9 @@ where StringEncoding::from_u8(string_encoding).unwrap(), async_ != 0, NonNull::slice_from_raw_parts(storage, storage_len).as_mut(), - move |instance, params, results| (*data.as_ptr())(instance, params, results), + move |store, instance, params, results| { + (*data.as_ptr())(store, instance, params, results) + }, ) }) } diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index 8af79c9109..2d5c781b96 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -21,8 +21,6 @@ use wasmtime_environ::component::{ #[cfg(feature = "component-model-async")] use crate::component::concurrent::{self, PreparedCall, ResetPtr}; #[cfg(feature = "component-model-async")] -use crate::VMStore; -#[cfg(feature = "component-model-async")] use core::any::Any; #[cfg(feature = "component-model-async")] use core::future::{self, Future}; @@ -191,7 +189,7 @@ where /// only works with functions defined within an asynchronous store. Also /// panics if `store` does not own this function. #[cfg(feature = "async")] - pub async fn call_async( + pub async fn call_async( self, mut store: impl AsContextMut, params: Params, @@ -249,7 +247,7 @@ where /// `Instance::spawn` to poll it from within the event loop. See /// [`Instance::run`] for examples. #[cfg(feature = "component-model-async")] - pub fn call_concurrent( + pub fn call_concurrent( self, mut store: impl AsContextMut, params: Params, @@ -292,7 +290,7 @@ where /// /// SAFETY: See `concurrent::prepare_call`. #[cfg(feature = "component-model-async")] - unsafe fn prepare_call<'a, T: Send>( + unsafe fn prepare_call<'a, T: Send + 'static>( self, store: StoreContextMut<'a, T>, drop_params: unsafe fn(*mut u8), @@ -307,18 +305,18 @@ where if Return::flatten_count() <= MAX_FLAT_PARAMS { concurrent::prepare_call( store, - Self::lower_stack_args_fn::, + Self::lower_stack_args_fn, drop_params, - Self::lift_stack_result_fn::, + Self::lift_stack_result_fn, self.func, param_count, ) } else { concurrent::prepare_call( store, - Self::lower_stack_args_fn::, + Self::lower_stack_args_fn, drop_params, - Self::lift_heap_result_fn::, + Self::lift_heap_result_fn, self.func, param_count, ) @@ -327,18 +325,18 @@ where if Return::flatten_count() <= MAX_FLAT_PARAMS { concurrent::prepare_call( store, - Self::lower_heap_args_fn::, + Self::lower_heap_args_fn, drop_params, - Self::lift_stack_result_fn::, + Self::lift_stack_result_fn, self.func, 1, ) } else { concurrent::prepare_call( store, - Self::lower_heap_args_fn::, + Self::lower_heap_args_fn, drop_params, - Self::lift_heap_result_fn::, + Self::lift_heap_result_fn, self.func, 1, ) @@ -348,18 +346,18 @@ where if Return::flatten_count() <= MAX_FLAT_RESULTS { concurrent::prepare_call( store, - Self::lower_stack_args_fn::, + Self::lower_stack_args_fn, drop_params, - Self::lift_stack_result_fn::, + Self::lift_stack_result_fn, self.func, param_count, ) } else { concurrent::prepare_call( store, - Self::lower_stack_args_fn::, + Self::lower_stack_args_fn, drop_params, - Self::lift_heap_result_fn::, + Self::lift_heap_result_fn, self.func, param_count, ) @@ -368,18 +366,18 @@ where if Return::flatten_count() <= MAX_FLAT_RESULTS { concurrent::prepare_call( store, - Self::lower_heap_args_fn::, + Self::lower_heap_args_fn, drop_params, - Self::lift_stack_result_fn::, + Self::lift_stack_result_fn, self.func, 1, ) } else { concurrent::prepare_call( store, - Self::lower_heap_args_fn::, + Self::lower_heap_args_fn, drop_params, - Self::lift_heap_result_fn::, + Self::lift_heap_result_fn, self.func, 1, ) @@ -466,24 +464,24 @@ where /// Equivalent to `lower_stack_args`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. Also, `params_in` must be a valid pointer to a `Self::Params`. + /// SAFETY: `params_in` must be a valid pointer to a `Self::Params`. #[cfg(feature = "component-model-async")] unsafe fn lower_stack_args_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, params_in: *mut u8, params_out: &mut [MaybeUninit], ) -> Result<()> { super::lower_params( store, + instance, params_out, func, // SAFETY: Per this function's precondition, `params_in` is a valid // pointer to a `Self::Params`. unsafe { &*params_in.cast() }, - Self::lower_stack_args::, + Self::lower_stack_args, ) } @@ -527,24 +525,24 @@ where /// Equivalent to `lower_heap_args`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. Also, `params_in` must be a valid pointer to a `Self::Params`. + /// SAFETY: `params_in` must be a valid pointer to a `Self::Params`. #[cfg(feature = "component-model-async")] unsafe fn lower_heap_args_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, params_in: *mut u8, params_out: &mut [MaybeUninit], ) -> Result<()> { super::lower_params( store, + instance, params_out, func, // SAFETY: Per this function's precondition, `params_in` is a valid // pointer to a `Self::Params`. unsafe { &*params_in.cast() }, - Self::lower_heap_args::, + Self::lower_heap_args, ) } @@ -588,20 +586,17 @@ where /// Equivalent to `lift_stack_result`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. - /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. #[cfg(feature = "component-model-async")] - unsafe fn lift_stack_result_fn( + fn lift_stack_result_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, results: &[ValRaw], ) -> Result> where Return: Send + Sync + 'static, { - super::lift_results::<_, T, _>(store, results, func, Self::lift_stack_result_raw) + super::lift_results(store, instance, results, func, Self::lift_stack_result_raw) } /// Lift the result of a function where the result is stored indirectly on @@ -639,20 +634,17 @@ where /// Equivalent to `lift_heap_result`, but with a monomorphic signature /// suitable for use with `concurrent::prepare_call`. - /// - /// SAFETY: `store` must be a valid pointer to a store with data type - /// parameter `T`, and the caller must confer exclusive access to that - /// store. #[cfg(feature = "component-model-async")] - unsafe fn lift_heap_result_fn( + fn lift_heap_result_fn( func: Func, - store: *mut dyn VMStore, + store: StoreContextMut, + instance: &mut ComponentInstance, results: &[ValRaw], ) -> Result> where Return: Send + Sync + 'static, { - super::lift_results::<_, T, _>(store, results, func, Self::lift_heap_result_raw) + super::lift_results(store, instance, results, func, Self::lift_heap_result_raw) } /// See [`Func::post_return`] diff --git a/crates/wasmtime/src/runtime/component/linker.rs b/crates/wasmtime/src/runtime/component/linker.rs index 13c0826e50..0d282491bb 100644 --- a/crates/wasmtime/src/runtime/component/linker.rs +++ b/crates/wasmtime/src/runtime/component/linker.rs @@ -109,7 +109,7 @@ pub(crate) enum Definition { Resource(ResourceType, Arc), } -impl Linker { +impl Linker { /// Creates a new linker for the [`Engine`] specified with no items defined /// within it. pub fn new(engine: &Engine) -> Linker { @@ -319,7 +319,7 @@ impl Linker { use wasmtime_environ::component::ComponentTypes; use wasmtime_environ::component::TypeDef; // Recursively stub out all imports of the component with a function that traps. - fn stub_item( + fn stub_item( linker: &mut LinkerInstance, item_name: &str, item_def: &TypeDef, @@ -379,7 +379,7 @@ impl Linker { } } -impl LinkerInstance<'_, T> { +impl LinkerInstance<'_, T> { fn as_mut(&mut self) -> LinkerInstance<'_, T> { LinkerInstance { engine: self.engine, diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs index c53dc15038..2a0126df12 100644 --- a/crates/wasmtime/src/runtime/component/mod.rs +++ b/crates/wasmtime/src/runtime/component/mod.rs @@ -132,6 +132,7 @@ pub use self::resources::{Resource, ResourceAny}; pub use self::types::{ResourceType, Type}; pub use self::values::Val; +pub(crate) use self::instance::InstanceData; pub(crate) use self::resources::HostResourceData; // Re-export wasm_wave crate so the compatible version of this dep doesn't have to be @@ -704,9 +705,10 @@ pub(crate) mod concurrent { crate::{ component::{ func::{ComponentType, LiftContext, LowerContext}, - Val, + Instance, Val, }, vm::component::ComponentInstance, + AsContextMut, StoreContextMut, VMStore, }, alloc::{sync::Arc, task::Wake}, anyhow::Result, @@ -719,6 +721,16 @@ pub(crate) mod concurrent { wasmtime_environ::component::{InterfaceType, RuntimeComponentInstanceIndex}, }; + impl StoreContextMut<'_, T> { + pub(crate) fn with_attached_instance( + &mut self, + instance: &mut ComponentInstance, + fun: impl FnOnce(StoreContextMut<'_, T>, Option) -> R, + ) -> R { + fun(self.as_context_mut(), instance.instance) + } + } + fn dummy_waker() -> Waker { struct DummyWaker; @@ -732,6 +744,7 @@ pub(crate) mod concurrent { impl ComponentInstance { pub(crate) fn poll_and_block( &mut self, + _store: &mut dyn VMStore, future: impl Future> + Send + 'static, _caller_instance: RuntimeComponentInstanceIndex, ) -> Result { diff --git a/crates/wasmtime/src/runtime/externals/table.rs b/crates/wasmtime/src/runtime/externals/table.rs index 5a79d53cfc..7d6c776358 100644 --- a/crates/wasmtime/src/runtime/externals/table.rs +++ b/crates/wasmtime/src/runtime/externals/table.rs @@ -262,7 +262,12 @@ impl Table { /// (see also: [`Store::limiter_async`](`crate::Store::limiter_async`)). /// When using an async resource limiter, use [`Table::grow_async`] /// instead. - pub fn grow(&self, mut store: impl AsContextMut, delta: u64, init: Ref) -> Result { + pub fn grow( + &self, + mut store: impl AsContextMut, + delta: u64, + init: Ref, + ) -> Result { let store = store.as_context_mut().0; let ty = self.ty(&store); let init = init.into_table_element(store, ty.element())?; @@ -296,7 +301,7 @@ impl Table { init: Ref, ) -> Result where - T: Send, + T: Send + 'static, { let store = store.as_context_mut(); assert!( diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs index 4d6fa0f6ca..1d0c42ed79 100644 --- a/crates/wasmtime/src/runtime/memory.rs +++ b/crates/wasmtime/src/runtime/memory.rs @@ -590,7 +590,11 @@ impl Memory { /// # Ok(()) /// # } /// ``` - pub fn grow(&self, mut store: impl AsContextMut, delta: u64) -> Result { + pub fn grow( + &self, + mut store: impl AsContextMut, + delta: u64, + ) -> Result { let store = store.as_context_mut().0; let mem = self.wasmtime_memory(store); unsafe { @@ -620,7 +624,7 @@ impl Memory { delta: u64, ) -> Result where - T: Send, + T: Send + 'static, { let store = store.as_context_mut(); assert!( diff --git a/crates/wasmtime/src/runtime/store.rs b/crates/wasmtime/src/runtime/store.rs index e80db1b837..db2343f053 100644 --- a/crates/wasmtime/src/runtime/store.rs +++ b/crates/wasmtime/src/runtime/store.rs @@ -109,6 +109,10 @@ mod data; pub use self::data::*; mod func_refs; use func_refs::FuncRefs; +#[cfg(feature = "component-model-async")] +mod token; +#[cfg(feature = "component-model-async")] +pub(crate) use token::StoreToken; #[cfg(feature = "async")] mod async_; #[cfg(all(feature = "async", feature = "call-hook"))] @@ -406,6 +410,9 @@ pub struct StoreOpaque { #[cfg(feature = "component-model-async")] concurrent_async_state: concurrent::AsyncState, + #[cfg(feature = "component-model")] + hidden_instances: Vec>>, + /// State related to the executor of wasm code. /// /// For example if Pulley is enabled and configured then this will store a @@ -527,7 +534,7 @@ enum StoreInstanceKind { Dummy, } -impl Store { +impl Store { /// Creates a new [`Store`] to be associated with the given [`Engine`] and /// `data` provided. /// @@ -583,6 +590,8 @@ impl Store { component_calls: Default::default(), #[cfg(feature = "component-model")] host_resource_data: Default::default(), + #[cfg(feature = "component-model")] + hidden_instances: Default::default(), #[cfg(feature = "component-model-async")] concurrent_async_state: Default::default(), #[cfg(has_host_compiler_backend)] @@ -606,16 +615,7 @@ impl Store { data: ManuallyDrop::new(data), }); - // Note the erasure of the lifetime here into `'static`, so in general - // usage of this trait object must be strictly bounded to the `Store` - // itself, and this is an invariant that we have to maintain throughout - // Wasmtime. - inner.traitobj = StorePtr::new(unsafe { - mem::transmute::< - NonNull, - NonNull, - >(NonNull::from(&mut *inner)) - }); + inner.traitobj = StorePtr::new(NonNull::from(&mut *inner)); // Wasmtime uses the callee argument to host functions to learn about // the original pointer to the `Store` itself, allowing it to @@ -1188,6 +1188,29 @@ impl StoreOpaque { self.store_data.id() } + #[cfg(feature = "component-model")] + pub(crate) fn hide_instance( + &mut self, + handle: crate::component::Instance, + ) -> *mut crate::vm::component::ComponentInstance { + if self.hidden_instances.len() <= handle.0.index() { + self.hidden_instances + .resize_with(handle.0.index() + 1, || None); + } + let data = self[handle.0].take().unwrap(); + let ptr = data.instance_ptr(); + self.hidden_instances[handle.0.index()] = Some(data); + ptr + } + + #[cfg(feature = "component-model")] + pub(crate) fn unhide_instance(&mut self, handle: crate::component::Instance) { + if let Some(data) = self.hidden_instances[handle.0.index()].take() { + assert!(self[handle.0].is_none()); + self[handle.0] = Some(data); + } + } + pub fn bump_resource_counts(&mut self, module: &Module) -> Result<()> { fn bump(slot: &mut usize, max: usize, amt: usize, desc: &str) -> Result<()> { let new = slot.saturating_add(amt); @@ -1996,7 +2019,7 @@ at https://bytecodealliance.org/security. } } -unsafe impl crate::runtime::vm::VMStore for StoreInner { +unsafe impl crate::runtime::vm::VMStore for StoreInner { #[cfg(feature = "component-model-async")] fn component_async_store( &mut self, @@ -2221,7 +2244,7 @@ impl StoreInner { } } -impl Default for Store { +impl Default for Store { fn default() -> Store { Store::new(&Engine::default(), T::default()) } diff --git a/crates/wasmtime/src/runtime/store/data.rs b/crates/wasmtime/src/runtime/store/data.rs index a76538b591..c57bad27cb 100644 --- a/crates/wasmtime/src/runtime/store/data.rs +++ b/crates/wasmtime/src/runtime/store/data.rs @@ -296,7 +296,7 @@ impl Stored { self.store_id.assert_belongs_to(store) } - fn index(&self) -> usize { + pub(crate) fn index(&self) -> usize { self.index } } diff --git a/crates/wasmtime/src/runtime/store/token.rs b/crates/wasmtime/src/runtime/store/token.rs new file mode 100644 index 0000000000..0db8044cc3 --- /dev/null +++ b/crates/wasmtime/src/runtime/store/token.rs @@ -0,0 +1,35 @@ +use crate::{store::StoreId, StoreContextMut, VMStore}; +use core::marker::PhantomData; + +pub struct StoreToken { + id: StoreId, + _phantom: PhantomData T>, +} + +impl Clone for StoreToken { + fn clone(&self) -> Self { + Self { + id: self.id, + _phantom: PhantomData, + } + } +} + +impl Copy for StoreToken {} + +impl StoreToken { + pub fn new(store: StoreContextMut) -> Self { + Self { + id: store.0.id(), + _phantom: PhantomData, + } + } + + pub fn as_context_mut<'a>(&self, store: &'a mut dyn VMStore) -> StoreContextMut<'a, T> { + assert_eq!(store.store_opaque().id(), self.id); + // We know the store with this ID has data type parameter `T` because + // we witnessed that in `Self::new`, which is the only way `self` could + // have been safely created: + unsafe { StoreContextMut::(&mut *(store as *mut dyn VMStore).cast()) } + } +} diff --git a/crates/wasmtime/src/runtime/vm.rs b/crates/wasmtime/src/runtime/vm.rs index 4799b3fda5..fb1aab8e79 100644 --- a/crates/wasmtime/src/runtime/vm.rs +++ b/crates/wasmtime/src/runtime/vm.rs @@ -172,7 +172,7 @@ cfg_if::cfg_if! { /// be respected by embedders (e.g. the `wasmtime::Store` structure). The theory /// is that `wasmtime::Store` handles all this correctly. #[doc(hidden)] -pub unsafe trait VMStore { +pub unsafe trait VMStore: 'static { /// Get a shared borrow of this store's `StoreOpaque`. fn store_opaque(&self) -> &StoreOpaque; diff --git a/crates/wasmtime/src/runtime/vm/component.rs b/crates/wasmtime/src/runtime/vm/component.rs index 7445123c52..fdb21ea9cb 100644 --- a/crates/wasmtime/src/runtime/vm/component.rs +++ b/crates/wasmtime/src/runtime/vm/component.rs @@ -6,7 +6,7 @@ //! Eventually it's intended that module-to-module calls, which would be //! cranelift-compiled adapters, will use this `VMComponentContext` as well. -use crate::component::ResourceType; +use crate::component::{Instance, ResourceType}; use crate::prelude::*; use crate::runtime::vm::{ SendSyncPtr, VMArrayCallFunction, VMContext, VMFuncRef, VMGlobalDefinition, VMMemoryDefinition, @@ -40,8 +40,6 @@ pub use self::resources::{ pub use self::resources::CallContext; #[cfg(feature = "component-model-async")] use crate::component::concurrent; -#[cfg(feature = "component-model-async")] -use crate::component::Instance; /// Runtime representation of a component instance and all state necessary for /// the instance itself. @@ -76,9 +74,8 @@ pub struct ComponentInstance { resource_types: Arc>, /// Self-pointer back to `Store` and its functions. - store: VMStoreRawPtr, + store: Option, - #[cfg(feature = "component-model-async")] pub(crate) instance: Option, /// A zero-sized field which represents the end of the struct for the actual @@ -182,12 +179,23 @@ impl ComponentInstance { /// mutable reference at this time to the instance from `vmctx`. pub unsafe fn from_vmctx( vmctx: NonNull, - f: impl FnOnce(&mut ComponentInstance) -> R, + f: impl FnOnce(&mut dyn VMStore, &mut ComponentInstance) -> R, ) -> R { let mut ptr = vmctx .byte_sub(mem::size_of::()) .cast::(); - f(ptr.as_mut()) + let reference = ptr.as_mut(); + let store = &mut *reference.store(); + if let Some(instance) = reference.instance { + store.hide_instance(instance); + } + reference.set_store(None); + let result = f(store, reference); + reference.set_store(Some(VMStoreRawPtr(store.traitobj()))); + if let Some(instance) = reference.instance { + store.unhide_instance(instance); + } + result } /// Returns the layout corresponding to what would be an allocation of a @@ -248,11 +256,10 @@ impl ComponentInstance { instance_resource_tables, runtime_info, resource_types, - store: VMStoreRawPtr(store), + store: Some(VMStoreRawPtr(store)), vmctx: VMComponentContext { _marker: marker::PhantomPinned, }, - #[cfg(feature = "component-model-async")] instance: None, #[cfg(feature = "component-model-async")] concurrent_state, @@ -295,8 +302,14 @@ impl ComponentInstance { } /// Returns the store that this component was created with. + /// + /// This will panic if this instance has been removed from its store. pub fn store(&self) -> *mut dyn VMStore { - self.store.0.as_ptr() + self.store.unwrap().0.as_ptr() + } + + pub(crate) fn set_store(&mut self, store: Option) { + self.store = store; } /// Returns the runtime memory definition corresponding to the index of the @@ -546,7 +559,7 @@ impl ComponentInstance { *self.vmctx_plus_offset_mut(self.offsets.builtins()) = VmPtr::from(NonNull::from(&libcalls::VMComponentBuiltins::INIT)); *self.vmctx_plus_offset_mut(self.offsets.vm_store_context()) = - VmPtr::from(self.store.0.as_ref().vm_store_context_ptr()); + VmPtr::from(self.store.unwrap().0.as_ref().vm_store_context_ptr()); for i in 0..self.offsets.num_runtime_component_instances { let i = RuntimeComponentInstanceIndex::from_u32(i); @@ -642,21 +655,36 @@ impl ComponentInstance { /// Implementation of the `resource.new` intrinsic for `i32` /// representations. - pub fn resource_new32(&mut self, ty: TypeResourceTableIndex, rep: u32) -> Result { - self.resource_tables() + pub fn resource_new32( + &mut self, + store: &mut dyn VMStore, + ty: TypeResourceTableIndex, + rep: u32, + ) -> Result { + self.resource_tables(store) .resource_new(TypedResource::Component { ty, rep }) } /// Implementation of the `resource.rep` intrinsic for `i32` /// representations. - pub fn resource_rep32(&mut self, ty: TypeResourceTableIndex, index: u32) -> Result { - self.resource_tables() + pub fn resource_rep32( + &mut self, + store: &mut dyn VMStore, + ty: TypeResourceTableIndex, + index: u32, + ) -> Result { + self.resource_tables(store) .resource_rep(TypedResourceIndex::Component { ty, index }) } /// Implementation of the `resource.drop` intrinsic. - pub fn resource_drop(&mut self, ty: TypeResourceTableIndex, index: u32) -> Result> { - self.resource_tables() + pub fn resource_drop( + &mut self, + store: &mut dyn VMStore, + ty: TypeResourceTableIndex, + index: u32, + ) -> Result> { + self.resource_tables(store) .resource_drop(TypedResourceIndex::Component { ty, index }) } @@ -667,10 +695,10 @@ impl ComponentInstance { /// /// If necessary though it's possible to enhance the `Store` trait to thread /// through the relevant information and get `host_table` to be `Some` here. - fn resource_tables(&mut self) -> ResourceTables<'_> { + fn resource_tables<'a>(&'a mut self, store: &'a mut dyn VMStore) -> ResourceTables<'a> { ResourceTables { host_table: None, - calls: unsafe { (&mut *self.store()).component_calls() }, + calls: store.component_calls(), guest: Some(( &mut self.instance_resource_tables, self.runtime_info.component_types(), @@ -713,23 +741,25 @@ impl ComponentInstance { pub(crate) fn resource_transfer_own( &mut self, + store: &mut dyn VMStore, index: u32, src: TypeResourceTableIndex, dst: TypeResourceTableIndex, ) -> Result { - let mut tables = self.resource_tables(); + let mut tables = self.resource_tables(store); let rep = tables.resource_lift_own(TypedResourceIndex::Component { ty: src, index })?; tables.resource_lower_own(TypedResource::Component { ty: dst, rep }) } pub(crate) fn resource_transfer_borrow( &mut self, + store: &mut dyn VMStore, index: u32, src: TypeResourceTableIndex, dst: TypeResourceTableIndex, ) -> Result { let dst_owns_resource = self.resource_owned_by_own_instance(dst); - let mut tables = self.resource_tables(); + let mut tables = self.resource_tables(store); let rep = tables.resource_lift_borrow(TypedResourceIndex::Component { ty: src, index })?; // Implement `lower_borrow`'s special case here where if a borrow's // resource type is owned by `dst` then the destination receives the @@ -745,12 +775,12 @@ impl ComponentInstance { tables.resource_lower_borrow(TypedResource::Component { ty: dst, rep }) } - pub(crate) fn resource_enter_call(&mut self) { - self.resource_tables().enter_call() + pub(crate) fn resource_enter_call(&mut self, store: &mut dyn VMStore) { + self.resource_tables(store).enter_call() } - pub(crate) fn resource_exit_call(&mut self) -> Result<()> { - self.resource_tables().exit_call() + pub(crate) fn resource_exit_call(&mut self, store: &mut dyn VMStore) -> Result<()> { + self.resource_tables(store).exit_call() } } diff --git a/crates/wasmtime/src/runtime/vm/component/libcalls.rs b/crates/wasmtime/src/runtime/vm/component/libcalls.rs index 8f047ed012..d625f9cf77 100644 --- a/crates/wasmtime/src/runtime/vm/component/libcalls.rs +++ b/crates/wasmtime/src/runtime/vm/component/libcalls.rs @@ -507,7 +507,9 @@ unsafe fn resource_new32( rep: u32, ) -> Result { let resource = TypeResourceTableIndex::from_u32(resource); - ComponentInstance::from_vmctx(vmctx, |instance| instance.resource_new32(resource, rep)) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + instance.resource_new32(store, resource, rep) + }) } unsafe fn resource_rep32( @@ -516,7 +518,9 @@ unsafe fn resource_rep32( idx: u32, ) -> Result { let resource = TypeResourceTableIndex::from_u32(resource); - ComponentInstance::from_vmctx(vmctx, |instance| instance.resource_rep32(resource, idx)) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + instance.resource_rep32(store, resource, idx) + }) } unsafe fn resource_drop( @@ -525,8 +529,10 @@ unsafe fn resource_drop( idx: u32, ) -> Result { let resource = TypeResourceTableIndex::from_u32(resource); - ComponentInstance::from_vmctx(vmctx, |instance| { - Ok(ResourceDropRet(instance.resource_drop(resource, idx)?)) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + Ok(ResourceDropRet( + instance.resource_drop(store, resource, idx)?, + )) }) } @@ -551,8 +557,8 @@ unsafe fn resource_transfer_own( ) -> Result { let src_table = TypeResourceTableIndex::from_u32(src_table); let dst_table = TypeResourceTableIndex::from_u32(dst_table); - ComponentInstance::from_vmctx(vmctx, |instance| { - instance.resource_transfer_own(src_idx, src_table, dst_table) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + instance.resource_transfer_own(store, src_idx, src_table, dst_table) }) } @@ -564,17 +570,17 @@ unsafe fn resource_transfer_borrow( ) -> Result { let src_table = TypeResourceTableIndex::from_u32(src_table); let dst_table = TypeResourceTableIndex::from_u32(dst_table); - ComponentInstance::from_vmctx(vmctx, |instance| { - instance.resource_transfer_borrow(src_idx, src_table, dst_table) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + instance.resource_transfer_borrow(store, src_idx, src_table, dst_table) }) } unsafe fn resource_enter_call(vmctx: NonNull) { - ComponentInstance::from_vmctx(vmctx, |instance| instance.resource_enter_call()) + ComponentInstance::from_vmctx(vmctx, |store, instance| instance.resource_enter_call(store)) } unsafe fn resource_exit_call(vmctx: NonNull) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| instance.resource_exit_call()) + ComponentInstance::from_vmctx(vmctx, |store, instance| instance.resource_exit_call(store)) } unsafe fn trap(_vmctx: NonNull, code: u8) -> Result { @@ -587,7 +593,7 @@ unsafe fn backpressure_set( caller_instance: u32, enabled: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.backpressure_set( wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), enabled, @@ -604,8 +610,9 @@ unsafe fn task_return( storage: *mut u8, storage_len: usize, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.task_return( + store, wasmtime_environ::component::TypeTupleIndex::from_u32(ty), memory.cast::(), string_encoding, @@ -617,8 +624,9 @@ unsafe fn task_return( #[cfg(feature = "component-model-async")] unsafe fn task_cancel(vmctx: NonNull, caller_instance: u32) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.task_cancel( + store, wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), ) }) @@ -629,7 +637,7 @@ unsafe fn waitable_set_new( vmctx: NonNull, caller_instance: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.waitable_set_new( wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), ) @@ -645,8 +653,9 @@ unsafe fn waitable_set_wait( set: u32, payload: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.waitable_set_wait( + store, wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), async_ != 0, memory.cast::(), @@ -665,8 +674,9 @@ unsafe fn waitable_set_poll( set: u32, payload: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.waitable_set_poll( + store, wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), async_ != 0, memory.cast::(), @@ -682,7 +692,7 @@ unsafe fn waitable_set_drop( caller_instance: u32, set: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.waitable_set_drop( wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), set, @@ -697,7 +707,7 @@ unsafe fn waitable_join( waitable: u32, set: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.waitable_join( wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), waitable, @@ -708,7 +718,7 @@ unsafe fn waitable_join( #[cfg(feature = "component-model-async")] unsafe fn yield_(vmctx: NonNull, async_: u8) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| instance.yield_(async_ != 0)) + ComponentInstance::from_vmctx(vmctx, |store, instance| instance.yield_(store, async_ != 0)) } #[cfg(feature = "component-model-async")] @@ -717,7 +727,7 @@ unsafe fn subtask_drop( caller_instance: u32, task_id: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.subtask_drop( wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), task_id, @@ -732,8 +742,9 @@ unsafe fn subtask_cancel( async_: u8, task_id: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.subtask_cancel( + store, wasmtime_environ::component::RuntimeComponentInstanceIndex::from_u32(caller_instance), async_ != 0, task_id, @@ -755,8 +766,8 @@ unsafe fn sync_enter( storage: *mut u8, storage_len: usize, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().sync_enter( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().sync_enter( instance, memory.cast::(), start.cast::(), @@ -781,8 +792,8 @@ unsafe fn sync_exit( storage: *mut u8, storage_len: usize, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().sync_exit( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().sync_exit( instance, callback.cast::(), callee.cast::(), @@ -806,8 +817,8 @@ unsafe fn async_enter( params: u32, results: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().async_enter( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().async_enter( instance, memory.cast::(), start.cast::(), @@ -832,8 +843,8 @@ unsafe fn async_exit( result_count: u32, flags: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().async_exit( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().async_exit( instance, callback.cast::(), post_return.cast::(), @@ -852,7 +863,7 @@ unsafe fn future_transfer( src_table: u32, dst_table: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.future_transfer( src_idx, wasmtime_environ::component::TypeFutureTableIndex::from_u32(src_table), @@ -868,7 +879,7 @@ unsafe fn stream_transfer( src_table: u32, dst_table: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.stream_transfer( src_idx, wasmtime_environ::component::TypeStreamTableIndex::from_u32(src_table), @@ -888,7 +899,7 @@ unsafe fn error_context_transfer( wasmtime_environ::component::TypeComponentLocalErrorContextTableIndex::from_u32(src_table); let dst_table = wasmtime_environ::component::TypeComponentLocalErrorContextTableIndex::from_u32(dst_table); - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.error_context_transfer(src_idx, src_table, dst_table) }) } @@ -906,7 +917,7 @@ unsafe impl HostResultHasUnwindSentinel for ResourcePair { #[cfg(feature = "component-model-async")] unsafe fn future_new(vmctx: NonNull, ty: u32) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.future_new(wasmtime_environ::component::TypeFutureTableIndex::from_u32( ty, )) @@ -924,8 +935,8 @@ unsafe fn future_write( future: u32, address: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().future_write( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().future_write( instance, memory.cast::(), realloc.cast::(), @@ -949,8 +960,8 @@ unsafe fn future_read( future: u32, address: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().future_read( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().future_read( instance, memory.cast::(), realloc.cast::(), @@ -970,7 +981,7 @@ unsafe fn future_cancel_write( async_: u8, writer: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.future_cancel_write( wasmtime_environ::component::TypeFutureTableIndex::from_u32(ty), async_ != 0, @@ -986,7 +997,7 @@ unsafe fn future_cancel_read( async_: u8, reader: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.future_cancel_read( wasmtime_environ::component::TypeFutureTableIndex::from_u32(ty), async_ != 0, @@ -1001,7 +1012,7 @@ unsafe fn future_close_writable( ty: u32, writer: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.future_close_writable( wasmtime_environ::component::TypeFutureTableIndex::from_u32(ty), writer, @@ -1015,8 +1026,9 @@ unsafe fn future_close_readable( ty: u32, reader: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.future_close_readable( + store, wasmtime_environ::component::TypeFutureTableIndex::from_u32(ty), reader, ) @@ -1025,7 +1037,7 @@ unsafe fn future_close_readable( #[cfg(feature = "component-model-async")] unsafe fn stream_new(vmctx: NonNull, ty: u32) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.stream_new(wasmtime_environ::component::TypeStreamTableIndex::from_u32( ty, )) @@ -1044,8 +1056,8 @@ unsafe fn stream_write( address: u32, count: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().stream_write( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().stream_write( instance, memory.cast::(), realloc.cast::(), @@ -1071,8 +1083,8 @@ unsafe fn stream_read( address: u32, count: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()).component_async_store().stream_read( + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().stream_read( instance, memory.cast::(), realloc.cast::(), @@ -1093,7 +1105,7 @@ unsafe fn stream_cancel_write( async_: u8, writer: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.stream_cancel_write( wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), async_ != 0, @@ -1109,7 +1121,7 @@ unsafe fn stream_cancel_read( async_: u8, reader: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.stream_cancel_read( wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), async_ != 0, @@ -1124,7 +1136,7 @@ unsafe fn stream_close_writable( ty: u32, writer: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.stream_close_writable( wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), writer, @@ -1138,8 +1150,9 @@ unsafe fn stream_close_readable( ty: u32, reader: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.stream_close_readable( + store, wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), reader, ) @@ -1159,21 +1172,19 @@ unsafe fn flat_stream_write( address: u32, count: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()) - .component_async_store() - .flat_stream_write( - instance, - memory.cast::(), - realloc.cast::(), - async_ != 0, - wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), - payload_size, - payload_align, - stream, - address, - count, - ) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().flat_stream_write( + instance, + memory.cast::(), + realloc.cast::(), + async_ != 0, + wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), + payload_size, + payload_align, + stream, + address, + count, + ) }) } @@ -1190,21 +1201,19 @@ unsafe fn flat_stream_read( address: u32, count: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()) - .component_async_store() - .flat_stream_read( - instance, - memory.cast::(), - realloc.cast::(), - async_ != 0, - wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), - payload_size, - payload_align, - stream, - address, - count, - ) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().flat_stream_read( + instance, + memory.cast::(), + realloc.cast::(), + async_ != 0, + wasmtime_environ::component::TypeStreamTableIndex::from_u32(ty), + payload_size, + payload_align, + stream, + address, + count, + ) }) } @@ -1218,8 +1227,9 @@ unsafe fn error_context_new( debug_msg_address: u32, debug_msg_len: u32, ) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |store, instance| { instance.error_context_new( + store, memory.cast::(), realloc.cast::(), string_encoding, @@ -1240,18 +1250,16 @@ unsafe fn error_context_debug_message( err_ctx_handle: u32, debug_msg_address: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { - (*instance.store()) - .component_async_store() - .error_context_debug_message( - instance, - memory.cast::(), - realloc.cast::(), - string_encoding, - wasmtime_environ::component::TypeComponentLocalErrorContextTableIndex::from_u32(ty), - err_ctx_handle, - debug_msg_address, - ) + ComponentInstance::from_vmctx(vmctx, |store, instance| { + store.component_async_store().error_context_debug_message( + instance, + memory.cast::(), + realloc.cast::(), + string_encoding, + wasmtime_environ::component::TypeComponentLocalErrorContextTableIndex::from_u32(ty), + err_ctx_handle, + debug_msg_address, + ) }) } @@ -1261,7 +1269,7 @@ unsafe fn error_context_drop( ty: u32, err_ctx_handle: u32, ) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| { + ComponentInstance::from_vmctx(vmctx, |_, instance| { instance.error_context_drop( wasmtime_environ::component::TypeComponentLocalErrorContextTableIndex::from_u32(ty), err_ctx_handle, @@ -1271,10 +1279,10 @@ unsafe fn error_context_drop( #[cfg(feature = "component-model-async")] unsafe fn context_get(vmctx: NonNull, slot: u32) -> Result { - ComponentInstance::from_vmctx(vmctx, |instance| instance.context_get(slot)) + ComponentInstance::from_vmctx(vmctx, |_, instance| instance.context_get(slot)) } #[cfg(feature = "component-model-async")] unsafe fn context_set(vmctx: NonNull, slot: u32, val: u32) -> Result<()> { - ComponentInstance::from_vmctx(vmctx, |instance| instance.context_set(slot, val)) + ComponentInstance::from_vmctx(vmctx, |_, instance| instance.context_set(slot, val)) } diff --git a/crates/wast/src/spectest.rs b/crates/wast/src/spectest.rs index e9b1ec7575..e2aa3e230a 100644 --- a/crates/wast/src/spectest.rs +++ b/crates/wast/src/spectest.rs @@ -88,7 +88,7 @@ pub fn link_spectest( } #[cfg(feature = "component-model")] -pub fn link_component_spectest(linker: &mut component::Linker) -> Result<()> { +pub fn link_component_spectest(linker: &mut component::Linker) -> Result<()> { use std::sync::atomic::{AtomicU32, Ordering::SeqCst}; use std::sync::Arc; use wasmtime::component::{Resource, ResourceType}; diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rs index 7e871b9d24..5f62b71333 100644 --- a/crates/wast/src/wast.rs +++ b/crates/wast/src/wast.rs @@ -14,7 +14,7 @@ use wast::{QuoteWat, Wast, WastArg, WastDirective, WastExecute, WastInvoke, Wast /// The wast test script language allows modules to be defined and actions /// to be performed on them. -pub struct WastContext { +pub struct WastContext { /// Wast files have a concept of a "current" module, which is the most /// recently defined. current: Option, diff --git a/crates/wiggle/generate/src/wasmtime.rs b/crates/wiggle/generate/src/wasmtime.rs index cb488f9927..36a2aac6a1 100644 --- a/crates/wiggle/generate/src/wasmtime.rs +++ b/crates/wiggle/generate/src/wasmtime.rs @@ -58,6 +58,7 @@ pub fn link_module( get_cx: impl Fn(&mut T) -> #u + Send + Sync + Copy + 'static, ) -> wiggle::anyhow::Result<()> where + T: 'static, U: #ctx_bound #send_bound { #(#bodies)* diff --git a/crates/wiggle/tests/wasmtime_async.rs b/crates/wiggle/tests/wasmtime_async.rs index 3c309de9c8..07807bc8bd 100644 --- a/crates/wiggle/tests/wasmtime_async.rs +++ b/crates/wiggle/tests/wasmtime_async.rs @@ -41,7 +41,7 @@ impl atoms::Atoms for Ctx { #[tokio::test] async fn test_sync_host_func() { let mut store = async_store(); - let mut linker = Linker::new(store.engine()); + let mut linker = Linker::::new(store.engine()); atoms::add_to_linker(&mut linker, |cx| cx).unwrap(); let shim_mod = shim_module(linker.engine()); let shim_inst = linker @@ -67,7 +67,7 @@ async fn test_sync_host_func() { #[tokio::test] async fn test_async_host_func() { let mut store = async_store(); - let mut linker = Linker::new(store.engine()); + let mut linker = Linker::::new(store.engine()); atoms::add_to_linker(&mut linker, |cx| cx).unwrap(); let shim_mod = shim_module(linker.engine()); diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs index f71edc0080..3ee6d7bc02 100644 --- a/crates/wit-bindgen/src/lib.rs +++ b/crates/wit-bindgen/src/lib.rs @@ -854,12 +854,12 @@ pub fn new<_T>( /// has been created through a [`Linker`]({wt}::component::Linker). /// /// For more information see [`{camel}`] as well. -pub struct {camel}Pre {{ +pub struct {camel}Pre {{ instance_pre: {wt}::component::InstancePre, indices: {camel}Indices, }} -impl Clone for {camel}Pre {{ +impl Clone for {camel}Pre {{ fn clone(&self) -> Self {{ Self {{ instance_pre: self.instance_pre.clone(), @@ -868,7 +868,7 @@ impl Clone for {camel}Pre {{ }} }} -impl<_T> {camel}Pre<_T> {{ +impl<_T: 'static> {camel}Pre<_T> {{ /// Creates a new copy of `{camel}Pre` bindings which can then /// be used to instantiate into a particular store. /// @@ -1028,7 +1028,7 @@ impl<_T> {camel}Pre<_T> {{ "impl {camel} {{ /// Convenience wrapper around [`{camel}Pre::new`] and /// [`{camel}Pre::instantiate{async__}`]. - pub {async_} fn instantiate{async__}<_T>( + pub {async_} fn instantiate{async__}<_T: 'static>( store: impl {wt}::AsContextMut, component: &{wt}::component::Component, linker: &{wt}::component::Linker<_T>, @@ -2771,14 +2771,23 @@ impl<'a> InterfaceGenerator<'a> { match style { CallStyle::Concurrent => { - uwrite!(self.src, " where ::Data: Send",); + uwrite!( + self.src, + " where ::Data: Send + 'static", + ); } CallStyle::Async => { - uwrite!(self.src, " where ::Data: Send"); + uwrite!( + self.src, + " where ::Data: Send + 'static" + ); } CallStyle::Sync => { // TODO: should not require `Send` or 'static here. - uwrite!(self.src, " where ::Data: Send"); + uwrite!( + self.src, + " where ::Data: Send + 'static" + ); } } uwrite!(self.src, "{{\n"); diff --git a/tests/all/async_functions.rs b/tests/all/async_functions.rs index 6b2e077cbe..d872677e6f 100644 --- a/tests/all/async_functions.rs +++ b/tests/all/async_functions.rs @@ -847,7 +847,7 @@ async fn non_stacky_async_activations() -> Result<()> { let module2 = module2.clone(); let mut store2 = Store::new(caller.engine(), ()); - let mut linker2 = Linker::new(caller.engine()); + let mut linker2 = Linker::<()>::new(caller.engine()); linker2 .func_wrap_async("", "yield", { let stacks = stacks.clone(); @@ -876,7 +876,7 @@ async fn non_stacky_async_activations() -> Result<()> { .await?; capture_stack(&stacks, &store2); - Ok(()) + anyhow::Ok(()) } }) as _) .await @@ -1042,7 +1042,7 @@ async fn async_gc_with_func_new_and_func_wrap() -> Result<()> { "#, )?; - let mut linker = Linker::new(&engine); + let mut linker = Linker::<()>::new(&engine); linker.func_wrap_async("", "a", |mut cx: Caller<'_, _>, ()| { Box::new(async move { let externref = ExternRef::new_async(&mut cx, 100).await?; diff --git a/tests/all/epoch_interruption.rs b/tests/all/epoch_interruption.rs index f784d9d732..cd321d1b33 100644 --- a/tests/all/epoch_interruption.rs +++ b/tests/all/epoch_interruption.rs @@ -13,7 +13,7 @@ fn build_engine(config: &mut Config) -> Arc { Arc::new(Engine::new(&config).unwrap()) } -fn make_env(engine: &Engine) -> Linker { +fn make_env(engine: &Engine) -> Linker { let mut linker = Linker::new(engine); let engine = engine.clone(); @@ -53,7 +53,7 @@ async fn run_and_count_yields_or_trap)>( setup_func: F, ) -> Option<(usize, usize)> { let engine = build_engine(config); - let linker = make_env(&engine); + let linker = make_env::(&engine); let module = Module::new(&engine, wasm).unwrap(); let mut store = Store::new(&engine, 0); store.set_epoch_deadline(initial); @@ -446,7 +446,7 @@ async fn drop_future_on_epoch_yield(config: &mut Config) { "; let engine = build_engine(config); - let mut linker = make_env(&engine); + let mut linker = make_env::<()>(&engine); // Create a few helpers for the Wasm to call. let alive_flag = Arc::new(AtomicBool::new(false)); diff --git a/tests/all/limits.rs b/tests/all/limits.rs index 684d76de35..bec830c3e0 100644 --- a/tests/all/limits.rs +++ b/tests/all/limits.rs @@ -868,7 +868,7 @@ async fn custom_limiter_async_detect_grow_failure() -> Result<()> { config.async_support(true); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); let engine = Engine::new(&config).unwrap(); - let linker = Linker::new(&engine); + let linker = Linker::::new(&engine); let module = Module::new( &engine, @@ -1049,7 +1049,7 @@ async fn panic_in_async_memory_limiter() { let mut config = Config::new(); config.async_support(true); let engine = Engine::new(&config).unwrap(); - let linker = Linker::new(&engine); + let linker = Linker::::new(&engine); let module = Module::new(&engine, r#"(module (memory (export "m") 0))"#).unwrap(); @@ -1071,7 +1071,7 @@ async fn panic_in_async_memory_limiter_wasm_stack() { let mut config = Config::new(); config.async_support(true); let engine = Engine::new(&config).unwrap(); - let linker = Linker::new(&engine); + let linker = Linker::::new(&engine); let module = Module::new( &engine, @@ -1101,7 +1101,7 @@ async fn panic_in_async_table_limiter() { let mut config = Config::new(); config.async_support(true); let engine = Engine::new(&config).unwrap(); - let linker = Linker::new(&engine); + let linker = Linker::::new(&engine); let module = Module::new(&engine, r#"(module (table (export "t") 0 funcref))"#).unwrap();