Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/fuzzing/src/generators/component_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ macro_rules! define_static_api_test {
let mut store: Store<Box<dyn Any>> = Store::new(&engine, Box::new(()));
let instance = linker.instantiate(&mut store, &component).unwrap();
let func = instance
.get_typed_func::<($($param,)*), R, _>(&mut store, EXPORT_FUNCTION)
.get_typed_func::<($($param,)*), R>(&mut store, EXPORT_FUNCTION)
.unwrap();

while input.arbitrary()? {
Expand Down
9 changes: 4 additions & 5 deletions crates/wasmtime/src/component/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, store: &mut Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(), (), _>(&store)?;
/// let typed = func.typed::<(), ()>(&store)?;
/// typed.call(store, ())?;
/// # Ok(())
/// # }
Expand All @@ -198,7 +198,7 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(&str,), (String,), _>(&store)?;
/// let typed = func.typed::<(&str,), (String,)>(&store)?;
/// let ret = typed.call(&mut store, ("Hello, ",))?.0;
/// println!("returned string was: {}", ret);
/// # Ok(())
Expand All @@ -211,17 +211,16 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,), _>(&store)?;
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,)>(&store)?;
/// let ok: bool = typed.call(&mut store, (1, Some("hello"), b"bytes!"))?.0;
/// println!("return value was: {ok}");
/// # Ok(())
/// # }
/// ```
pub fn typed<Params, Return, S>(&self, store: S) -> Result<TypedFunc<Params, Return>>
pub fn typed<Params, Return>(&self, store: impl AsContext) -> Result<TypedFunc<Params, Return>>
where
Params: ComponentNamedList + Lower,
Return: ComponentNamedList + Lift,
S: AsContext,
{
self._typed(store.as_context().0)
}
Expand Down
7 changes: 3 additions & 4 deletions crates/wasmtime/src/component/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,19 @@ impl Instance {
/// # Panics
///
/// Panics if `store` does not own this instance.
pub fn get_typed_func<Params, Results, S>(
pub fn get_typed_func<Params, Results>(
&self,
mut store: S,
mut store: impl AsContextMut,
name: &str,
) -> Result<TypedFunc<Params, Results>>
where
Params: ComponentNamedList + Lower,
Results: ComponentNamedList + Lift,
S: AsContextMut,
{
let f = self
.get_func(store.as_context_mut(), name)
.ok_or_else(|| anyhow!("failed to find function export `{}`", name))?;
Ok(f.typed::<Params, Results, _>(store)
Ok(f.typed::<Params, Results>(store)
.with_context(|| format!("failed to convert function `{}` to given type", name))?)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/all/component_model/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn mildly_more_interesting() -> Result<()> {
let component = unsafe { Component::deserialize(&engine, &component)? };
let mut store = Store::new(&engine, ());
let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
let func = instance.get_typed_func::<(), (u32,), _>(&mut store, "a")?;
let func = instance.get_typed_func::<(), (u32,)>(&mut store, "a")?;
assert_eq!(func.call(&mut store, ())?, (103,));

Ok(())
Expand Down
6 changes: 3 additions & 3 deletions tests/all/component_model/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ async fn smoke() -> Result<()> {
.instantiate_async(&mut store, &component)
.await?;

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

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

let err = instance
.get_typed_func::<(), (), _>(&mut store, "thunk-trap")?
.get_typed_func::<(), ()>(&mut store, "thunk-trap")?
.call_async(&mut store, ())
.await
.unwrap_err();
Expand Down Expand Up @@ -79,7 +79,7 @@ async fn smoke_func_wrap() -> Result<()> {

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

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

thunk.call_async(&mut store, ()).await?;
thunk.post_return_async(&mut store).await?;
Expand Down
Loading