Skip to content

Commit 284fec1

Browse files
authored
Remove explicit S type from component functions (#5722)
I ended up forgetting this as part of #5275.
1 parent 939b6ea commit 284fec1

File tree

11 files changed

+216
-225
lines changed

11 files changed

+216
-225
lines changed

crates/fuzzing/src/generators/component_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ macro_rules! define_static_api_test {
173173
let mut store: Store<Box<dyn Any>> = Store::new(&engine, Box::new(()));
174174
let instance = linker.instantiate(&mut store, &component).unwrap();
175175
let func = instance
176-
.get_typed_func::<($($param,)*), R, _>(&mut store, EXPORT_FUNCTION)
176+
.get_typed_func::<($($param,)*), R>(&mut store, EXPORT_FUNCTION)
177177
.unwrap();
178178

179179
while input.arbitrary()? {

crates/wasmtime/src/component/func.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl Func {
185185
/// # use wasmtime::component::Func;
186186
/// # use wasmtime::Store;
187187
/// # fn foo(func: &Func, store: &mut Store<()>) -> anyhow::Result<()> {
188-
/// let typed = func.typed::<(), (), _>(&store)?;
188+
/// let typed = func.typed::<(), ()>(&store)?;
189189
/// typed.call(store, ())?;
190190
/// # Ok(())
191191
/// # }
@@ -198,7 +198,7 @@ impl Func {
198198
/// # use wasmtime::component::Func;
199199
/// # use wasmtime::Store;
200200
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
201-
/// let typed = func.typed::<(&str,), (String,), _>(&store)?;
201+
/// let typed = func.typed::<(&str,), (String,)>(&store)?;
202202
/// let ret = typed.call(&mut store, ("Hello, ",))?.0;
203203
/// println!("returned string was: {}", ret);
204204
/// # Ok(())
@@ -211,17 +211,16 @@ impl Func {
211211
/// # use wasmtime::component::Func;
212212
/// # use wasmtime::Store;
213213
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
214-
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,), _>(&store)?;
214+
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,)>(&store)?;
215215
/// let ok: bool = typed.call(&mut store, (1, Some("hello"), b"bytes!"))?.0;
216216
/// println!("return value was: {ok}");
217217
/// # Ok(())
218218
/// # }
219219
/// ```
220-
pub fn typed<Params, Return, S>(&self, store: S) -> Result<TypedFunc<Params, Return>>
220+
pub fn typed<Params, Return>(&self, store: impl AsContext) -> Result<TypedFunc<Params, Return>>
221221
where
222222
Params: ComponentNamedList + Lower,
223223
Return: ComponentNamedList + Lift,
224-
S: AsContext,
225224
{
226225
self._typed(store.as_context().0)
227226
}

crates/wasmtime/src/component/instance.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,19 @@ impl Instance {
8585
/// # Panics
8686
///
8787
/// Panics if `store` does not own this instance.
88-
pub fn get_typed_func<Params, Results, S>(
88+
pub fn get_typed_func<Params, Results>(
8989
&self,
90-
mut store: S,
90+
mut store: impl AsContextMut,
9191
name: &str,
9292
) -> Result<TypedFunc<Params, Results>>
9393
where
9494
Params: ComponentNamedList + Lower,
9595
Results: ComponentNamedList + Lift,
96-
S: AsContextMut,
9796
{
9897
let f = self
9998
.get_func(store.as_context_mut(), name)
10099
.ok_or_else(|| anyhow!("failed to find function export `{}`", name))?;
101-
Ok(f.typed::<Params, Results, _>(store)
100+
Ok(f.typed::<Params, Results>(store)
102101
.with_context(|| format!("failed to convert function `{}` to given type", name))?)
103102
}
104103

tests/all/component_model/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn mildly_more_interesting() -> Result<()> {
6262
let component = unsafe { Component::deserialize(&engine, &component)? };
6363
let mut store = Store::new(&engine, ());
6464
let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
65-
let func = instance.get_typed_func::<(), (u32,), _>(&mut store, "a")?;
65+
let func = instance.get_typed_func::<(), (u32,)>(&mut store, "a")?;
6666
assert_eq!(func.call(&mut store, ())?, (103,));
6767

6868
Ok(())

tests/all/component_model/async.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ async fn smoke() -> Result<()> {
2828
.instantiate_async(&mut store, &component)
2929
.await?;
3030

31-
let thunk = instance.get_typed_func::<(), (), _>(&mut store, "thunk")?;
31+
let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?;
3232

3333
thunk.call_async(&mut store, ()).await?;
3434
thunk.post_return_async(&mut store).await?;
3535

3636
let err = instance
37-
.get_typed_func::<(), (), _>(&mut store, "thunk-trap")?
37+
.get_typed_func::<(), ()>(&mut store, "thunk-trap")?
3838
.call_async(&mut store, ())
3939
.await
4040
.unwrap_err();
@@ -79,7 +79,7 @@ async fn smoke_func_wrap() -> Result<()> {
7979

8080
let instance = linker.instantiate_async(&mut store, &component).await?;
8181

82-
let thunk = instance.get_typed_func::<(), (), _>(&mut store, "thunk")?;
82+
let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?;
8383

8484
thunk.call_async(&mut store, ()).await?;
8585
thunk.post_return_async(&mut store).await?;

0 commit comments

Comments
 (0)