Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit f8dff07

Browse files
committed
update-expectations
1 parent 181c1eb commit f8dff07

116 files changed

Lines changed: 5139 additions & 17109 deletions

File tree

Some content is hidden

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

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

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ const _: () = {
144144
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
145145
indices.load(&mut store, instance)
146146
}
147-
pub fn add_to_linker<T, U>(
147+
pub fn add_to_linker<T, D>(
148148
linker: &mut wasmtime::component::Linker<T>,
149-
get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
149+
host_getter: fn(&mut T) -> D::Data<'_>,
150150
) -> wasmtime::Result<()>
151151
where
152-
U: foo::foo::chars::Host,
152+
D: wasmtime::component::HasData,
153+
for<'a> D::Data<'a>: foo::foo::chars::Host,
154+
T: 'static,
153155
{
154-
foo::foo::chars::add_to_linker(linker, get)?;
156+
foo::foo::chars::add_to_linker::<T, D>(linker, host_getter)?;
155157
Ok(())
156158
}
157159
pub fn foo_foo_chars(&self) -> &exports::foo::foo::chars::Guest {
@@ -171,12 +173,24 @@ pub mod foo {
171173
/// A function that returns a character
172174
fn return_char(&mut self) -> char;
173175
}
174-
pub fn add_to_linker_get_host<T, G>(
176+
impl<_T: Host> Host for &mut _T {
177+
/// A function that accepts a character
178+
fn take_char(&mut self, x: char) -> () {
179+
Host::take_char(*self, x)
180+
}
181+
/// A function that returns a character
182+
fn return_char(&mut self) -> char {
183+
Host::return_char(*self)
184+
}
185+
}
186+
pub fn add_to_linker<T, D>(
175187
linker: &mut wasmtime::component::Linker<T>,
176-
host_getter: G,
188+
host_getter: fn(&mut T) -> D::Data<'_>,
177189
) -> wasmtime::Result<()>
178190
where
179-
G: for<'a> wasmtime::component::GetHost<&'a mut T, Host: Host>,
191+
D: wasmtime::component::HasData,
192+
for<'a> D::Data<'a>: Host,
193+
T: 'static,
180194
{
181195
let mut inst = linker.instance("foo:foo/chars")?;
182196
inst.func_wrap(
@@ -200,25 +214,6 @@ pub mod foo {
200214
)?;
201215
Ok(())
202216
}
203-
pub fn add_to_linker<T, U>(
204-
linker: &mut wasmtime::component::Linker<T>,
205-
get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
206-
) -> wasmtime::Result<()>
207-
where
208-
U: Host,
209-
{
210-
add_to_linker_get_host(linker, get)
211-
}
212-
impl<_T: Host + ?Sized> Host for &mut _T {
213-
/// A function that accepts a character
214-
fn take_char(&mut self, x: char) -> () {
215-
Host::take_char(*self, x)
216-
}
217-
/// A function that returns a character
218-
fn return_char(&mut self) -> char {
219-
Host::return_char(*self)
220-
}
221-
}
222217
}
223218
}
224219
}

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

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,16 @@ const _: () = {
150150
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
151151
indices.load(&mut store, instance)
152152
}
153-
pub fn add_to_linker<T, U>(
153+
pub fn add_to_linker<T, D>(
154154
linker: &mut wasmtime::component::Linker<T>,
155-
get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
155+
host_getter: fn(&mut T) -> D::Data<'_>,
156156
) -> wasmtime::Result<()>
157157
where
158-
T: Send,
159-
U: foo::foo::chars::Host + Send,
158+
D: wasmtime::component::HasData,
159+
for<'a> D::Data<'a>: foo::foo::chars::Host + Send,
160+
T: 'static + Send,
160161
{
161-
foo::foo::chars::add_to_linker(linker, get)?;
162+
foo::foo::chars::add_to_linker::<T, D>(linker, host_getter)?;
162163
Ok(())
163164
}
164165
pub fn foo_foo_chars(&self) -> &exports::foo::foo::chars::Guest {
@@ -179,13 +180,24 @@ pub mod foo {
179180
/// A function that returns a character
180181
async fn return_char(&mut self) -> char;
181182
}
182-
pub fn add_to_linker_get_host<T, G>(
183+
impl<_T: Host + Send> Host for &mut _T {
184+
/// A function that accepts a character
185+
async fn take_char(&mut self, x: char) -> () {
186+
Host::take_char(*self, x).await
187+
}
188+
/// A function that returns a character
189+
async fn return_char(&mut self) -> char {
190+
Host::return_char(*self).await
191+
}
192+
}
193+
pub fn add_to_linker<T, D>(
183194
linker: &mut wasmtime::component::Linker<T>,
184-
host_getter: G,
195+
host_getter: fn(&mut T) -> D::Data<'_>,
185196
) -> wasmtime::Result<()>
186197
where
187-
G: for<'a> wasmtime::component::GetHost<&'a mut T, Host: Host + Send>,
188-
T: Send,
198+
D: wasmtime::component::HasData,
199+
for<'a> D::Data<'a>: Host,
200+
T: 'static + Send,
189201
{
190202
let mut inst = linker.instance("foo:foo/chars")?;
191203
inst.func_wrap_async(
@@ -213,26 +225,6 @@ pub mod foo {
213225
)?;
214226
Ok(())
215227
}
216-
pub fn add_to_linker<T, U>(
217-
linker: &mut wasmtime::component::Linker<T>,
218-
get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
219-
) -> wasmtime::Result<()>
220-
where
221-
U: Host + Send,
222-
T: Send,
223-
{
224-
add_to_linker_get_host(linker, get)
225-
}
226-
impl<_T: Host + ?Sized + Send> Host for &mut _T {
227-
/// A function that accepts a character
228-
async fn take_char(&mut self, x: char) -> () {
229-
Host::take_char(*self, x).await
230-
}
231-
/// A function that returns a character
232-
async fn return_char(&mut self) -> char {
233-
Host::return_char(*self).await
234-
}
235-
}
236228
}
237229
}
238230
}

0 commit comments

Comments
 (0)