From 6a68785f332b70ce06fa340a3153aea4e544bdba Mon Sep 17 00:00:00 2001 From: yezihang Date: Tue, 3 Mar 2026 11:50:52 +0800 Subject: [PATCH 1/2] wit-parser: add future/stream intrinsic WasmImport naming --- crates/wit-component/src/dummy.rs | 131 ++++++++--- crates/wit-parser/src/resolve/mod.rs | 325 ++++++++++++++++++++++++++- 2 files changed, 422 insertions(+), 34 deletions(-) diff --git a/crates/wit-component/src/dummy.rs b/crates/wit-component/src/dummy.rs index 9651c2939b..65f1c57e93 100644 --- a/crates/wit-component/src/dummy.rs +++ b/crates/wit-component/src/dummy.rs @@ -1,7 +1,8 @@ use wit_parser::abi::WasmType; use wit_parser::{ - Function, LiftLowerAbi, ManglingAndAbi, Resolve, ResourceIntrinsic, TypeDefKind, TypeId, - WasmExport, WasmExportKind, WasmImport, WorldId, WorldItem, WorldKey, + Function, FutureIntrinsic, LiftLowerAbi, ManglingAndAbi, Resolve, ResourceIntrinsic, + StreamIntrinsic, TypeDefKind, TypeId, WasmExport, WasmExportKind, WasmImport, WorldId, + WorldItem, WorldKey, }; /// Generate a dummy implementation core Wasm module for a given WIT document @@ -98,7 +99,7 @@ fn push_imported_func( wat.push_str("))\n"); if mangling.is_async() { - push_imported_future_and_stream_intrinsics(wat, resolve, "", interface, func); + push_imported_future_and_stream_intrinsics(wat, resolve, mangling, false, interface, func); } } @@ -156,63 +157,127 @@ fn push_exported_func_intrinsics( push_tys(wat, "result", &sig.results); wat.push_str("))\n"); - push_imported_future_and_stream_intrinsics(wat, resolve, "[export]", interface, func); + push_imported_future_and_stream_intrinsics(wat, resolve, mangling, true, interface, func); } fn push_imported_future_and_stream_intrinsics( wat: &mut String, resolve: &Resolve, - module_prefix: &str, + mangling: ManglingAndAbi, + exported: bool, interface: Option<&WorldKey>, func: &Function, ) { - let module = match interface { - Some(key) => format!("{module_prefix}{}", resolve.name_world_key(key)), - None => format!("{module_prefix}$root"), - }; - let name = &func.name; - for (i, id) in func .find_futures_and_streams(resolve) .into_iter() .enumerate() { + let type_index = u32::try_from(i).unwrap(); match &resolve.types[id].kind { TypeDefKind::Future(_) => { + let mut module = None; + let mut intrinsic_name = |intrinsic, async_| { + let (m, name) = resolve.wasm_import_name( + mangling, + WasmImport::FutureIntrinsic { + interface, + func, + type_index: Some(type_index), + intrinsic, + exported, + async_, + }, + ); + if let Some(prev) = &module { + debug_assert_eq!(prev, &m); + } else { + module = Some(m); + } + name + }; + + let new = intrinsic_name(FutureIntrinsic::New, false); + let read = intrinsic_name(FutureIntrinsic::Read, false); + let write = intrinsic_name(FutureIntrinsic::Write, false); + let cancel_read = intrinsic_name(FutureIntrinsic::CancelRead, false); + let cancel_write = intrinsic_name(FutureIntrinsic::CancelWrite, false); + let drop_readable = intrinsic_name(FutureIntrinsic::DropReadable, false); + let drop_writable = intrinsic_name(FutureIntrinsic::DropWritable, false); + let async_read = intrinsic_name(FutureIntrinsic::Read, true); + let async_write = intrinsic_name(FutureIntrinsic::Write, true); + let async_cancel_read = intrinsic_name(FutureIntrinsic::CancelRead, true); + let async_cancel_write = intrinsic_name(FutureIntrinsic::CancelWrite, true); + let module = module.unwrap(); + wat.push_str(&format!( r#" -(import {module:?} "[future-new-{i}]{name}" (func (result i64))) -(import {module:?} "[future-read-{i}]{name}" (func (param i32 i32) (result i32))) -(import {module:?} "[future-write-{i}]{name}" (func (param i32 i32) (result i32))) -(import {module:?} "[future-cancel-read-{i}]{name}" (func (param i32) (result i32))) -(import {module:?} "[future-cancel-write-{i}]{name}" (func (param i32) (result i32))) -(import {module:?} "[future-drop-readable-{i}]{name}" (func (param i32))) -(import {module:?} "[future-drop-writable-{i}]{name}" (func (param i32))) -(import {module:?} "[async-lower][future-read-{i}]{name}" (func (param i32 i32) (result i32))) -(import {module:?} "[async-lower][future-write-{i}]{name}" (func (param i32 i32) (result i32))) +(import {module:?} {new:?} (func (result i64))) +(import {module:?} {read:?} (func (param i32 i32) (result i32))) +(import {module:?} {write:?} (func (param i32 i32) (result i32))) +(import {module:?} {cancel_read:?} (func (param i32) (result i32))) +(import {module:?} {cancel_write:?} (func (param i32) (result i32))) +(import {module:?} {drop_readable:?} (func (param i32))) +(import {module:?} {drop_writable:?} (func (param i32))) +(import {module:?} {async_read:?} (func (param i32 i32) (result i32))) +(import {module:?} {async_write:?} (func (param i32 i32) (result i32))) ;; deferred behind 🚝 -;;(import {module:?} "[async-lower][future-cancel-read-{i}]{name}" (func (param i32) (result i32))) -;;(import {module:?} "[async-lower][future-cancel-write-{i}]{name}" (func (param i32) (result i32))) +;;(import {module:?} {async_cancel_read:?} (func (param i32) (result i32))) +;;(import {module:?} {async_cancel_write:?} (func (param i32) (result i32))) "# )); } TypeDefKind::Stream(_) => { + let mut module = None; + let mut intrinsic_name = |intrinsic, async_| { + let (m, name) = resolve.wasm_import_name( + mangling, + WasmImport::StreamIntrinsic { + interface, + func, + type_index: Some(type_index), + intrinsic, + exported, + async_, + }, + ); + if let Some(prev) = &module { + debug_assert_eq!(prev, &m); + } else { + module = Some(m); + } + name + }; + + let new = intrinsic_name(StreamIntrinsic::New, false); + let read = intrinsic_name(StreamIntrinsic::Read, false); + let write = intrinsic_name(StreamIntrinsic::Write, false); + let cancel_read = intrinsic_name(StreamIntrinsic::CancelRead, false); + let cancel_write = intrinsic_name(StreamIntrinsic::CancelWrite, false); + let drop_readable = intrinsic_name(StreamIntrinsic::DropReadable, false); + let drop_writable = intrinsic_name(StreamIntrinsic::DropWritable, false); + let async_read = intrinsic_name(StreamIntrinsic::Read, true); + let async_write = intrinsic_name(StreamIntrinsic::Write, true); + let async_cancel_read = intrinsic_name(StreamIntrinsic::CancelRead, true); + let async_cancel_write = intrinsic_name(StreamIntrinsic::CancelWrite, true); + let module = module.unwrap(); + wat.push_str(&format!( r#" -(import {module:?} "[stream-new-{i}]{name}" (func (result i64))) -(import {module:?} "[stream-read-{i}]{name}" (func (param i32 i32 i32) (result i32))) -(import {module:?} "[stream-write-{i}]{name}" (func (param i32 i32 i32) (result i32))) -(import {module:?} "[stream-cancel-read-{i}]{name}" (func (param i32) (result i32))) -(import {module:?} "[stream-cancel-write-{i}]{name}" (func (param i32) (result i32))) -(import {module:?} "[stream-drop-readable-{i}]{name}" (func (param i32))) -(import {module:?} "[stream-drop-writable-{i}]{name}" (func (param i32))) -(import {module:?} "[async-lower][stream-read-{i}]{name}" (func (param i32 i32 i32) (result i32))) -(import {module:?} "[async-lower][stream-write-{i}]{name}" (func (param i32 i32 i32) (result i32))) +(import {module:?} {new:?} (func (result i64))) +(import {module:?} {read:?} (func (param i32 i32 i32) (result i32))) +(import {module:?} {write:?} (func (param i32 i32 i32) (result i32))) +(import {module:?} {cancel_read:?} (func (param i32) (result i32))) +(import {module:?} {cancel_write:?} (func (param i32) (result i32))) +(import {module:?} {drop_readable:?} (func (param i32))) +(import {module:?} {drop_writable:?} (func (param i32))) +(import {module:?} {async_read:?} (func (param i32 i32 i32) (result i32))) +(import {module:?} {async_write:?} (func (param i32 i32 i32) (result i32))) ;; deferred behind 🚝 -;;(import {module:?} "[async-lower][stream-cancel-read-{i}]{name}" (func (param i32) (result i32))) -;;(import {module:?} "[async-lower][stream-cancel-write-{i}]{name}" (func (param i32) (result i32))) +;;(import {module:?} {async_cancel_read:?} (func (param i32) (result i32))) +;;(import {module:?} {async_cancel_write:?} (func (param i32) (result i32))) "# )); } diff --git a/crates/wit-parser/src/resolve/mod.rs b/crates/wit-parser/src/resolve/mod.rs index 12900fe4d0..34aec49cd0 100644 --- a/crates/wit-parser/src/resolve/mod.rs +++ b/crates/wit-parser/src/resolve/mod.rs @@ -2436,6 +2436,13 @@ package {name} is defined in two different locations:\n\ }; (module, name) } + WasmImport::FutureIntrinsic { .. } | WasmImport::StreamIntrinsic { .. } => { + panic!( + "at the time of writing, standard32 name mangling only supports the \ + synchronous ABI and does not define future/stream intrinsic imports; \ + use legacy mangling for these imports" + ) + } }, ManglingAndAbi::Legacy(abi) => match import { WasmImport::Func { interface, func } => { @@ -2472,6 +2479,102 @@ package {name} is defined in two different locations:\n\ }; (module, format!("{}{name}", abi.import_prefix())) } + WasmImport::FutureIntrinsic { + interface, + func, + type_index, + intrinsic, + exported, + async_, + } => { + let module_prefix = if exported { "[export]" } else { "" }; + let module = match interface { + Some(key) => format!("{module_prefix}{}", self.name_world_key(key)), + None => format!("{module_prefix}$root"), + }; + let type_index = match type_index { + Some(i) => i.to_string(), + None => "unit".to_string(), + }; + let (async_prefix, name) = match intrinsic { + FutureIntrinsic::New => { + assert!(!async_, "future.new cannot be async-lowered"); + ("", "new") + } + FutureIntrinsic::Read => { + (if async_ { "[async-lower]" } else { "" }, "read") + } + FutureIntrinsic::Write => { + (if async_ { "[async-lower]" } else { "" }, "write") + } + FutureIntrinsic::CancelRead => { + (if async_ { "[async-lower]" } else { "" }, "cancel-read") + } + FutureIntrinsic::CancelWrite => { + (if async_ { "[async-lower]" } else { "" }, "cancel-write") + } + FutureIntrinsic::DropReadable => { + assert!(!async_, "future.drop-readable cannot be async-lowered"); + ("", "drop-readable") + } + FutureIntrinsic::DropWritable => { + assert!(!async_, "future.drop-writable cannot be async-lowered"); + ("", "drop-writable") + } + }; + ( + module, + format!("{async_prefix}[future-{name}-{type_index}]{}", func.name), + ) + } + WasmImport::StreamIntrinsic { + interface, + func, + type_index, + intrinsic, + exported, + async_, + } => { + let module_prefix = if exported { "[export]" } else { "" }; + let module = match interface { + Some(key) => format!("{module_prefix}{}", self.name_world_key(key)), + None => format!("{module_prefix}$root"), + }; + let type_index = match type_index { + Some(i) => i.to_string(), + None => "unit".to_string(), + }; + let (async_prefix, name) = match intrinsic { + StreamIntrinsic::New => { + assert!(!async_, "stream.new cannot be async-lowered"); + ("", "new") + } + StreamIntrinsic::Read => { + (if async_ { "[async-lower]" } else { "" }, "read") + } + StreamIntrinsic::Write => { + (if async_ { "[async-lower]" } else { "" }, "write") + } + StreamIntrinsic::CancelRead => { + (if async_ { "[async-lower]" } else { "" }, "cancel-read") + } + StreamIntrinsic::CancelWrite => { + (if async_ { "[async-lower]" } else { "" }, "cancel-write") + } + StreamIntrinsic::DropReadable => { + assert!(!async_, "stream.drop-readable cannot be async-lowered"); + ("", "drop-readable") + } + StreamIntrinsic::DropWritable => { + assert!(!async_, "stream.drop-writable cannot be async-lowered"); + ("", "drop-writable") + } + }; + ( + module, + format!("{async_prefix}[stream-{name}-{type_index}]{}", func.name), + ) + } }, } } @@ -2688,7 +2791,7 @@ pub enum WasmImport<'a> { /// The name of the interface that the function is being imported from. /// /// If the function is imported directly from the world then this is - /// `Noen`. + /// `None`. interface: Option<&'a WorldKey>, /// The function being imported. @@ -2706,6 +2809,60 @@ pub enum WasmImport<'a> { /// The intrinsic that's being imported. intrinsic: ResourceIntrinsic, }, + + /// A future-related intrinsic is being imported. + FutureIntrinsic { + /// The optional interface to import from, same as `WasmImport::Func`. + interface: Option<&'a WorldKey>, + + /// The function whose signature this future type appears in. + func: &'a Function, + + /// The index into `func.find_futures_and_streams(resolve)`. + /// + /// Use `None` for the special `unit` payload case. + type_index: Option, + + /// The intrinsic that's being imported. + intrinsic: FutureIntrinsic, + + /// Whether this import is for an exported WIT function. + /// + /// This controls whether the module name is prefixed with `[export]`. + exported: bool, + + /// Whether this intrinsic import is async-lowered. + /// + /// This is only valid for read/write/cancel intrinsics. + async_: bool, + }, + + /// A stream-related intrinsic is being imported. + StreamIntrinsic { + /// The optional interface to import from, same as `WasmImport::Func`. + interface: Option<&'a WorldKey>, + + /// The function whose signature this stream type appears in. + func: &'a Function, + + /// The index into `func.find_futures_and_streams(resolve)`. + /// + /// Use `None` for the special `unit` payload case. + type_index: Option, + + /// The intrinsic that's being imported. + intrinsic: StreamIntrinsic, + + /// Whether this import is for an exported WIT function. + /// + /// This controls whether the module name is prefixed with `[export]`. + exported: bool, + + /// Whether this intrinsic import is async-lowered. + /// + /// This is only valid for read/write/cancel intrinsics. + async_: bool, + }, } /// Intrinsic definitions to go with [`WasmImport::ResourceIntrinsic`] which @@ -2718,6 +2875,32 @@ pub enum ResourceIntrinsic { ExportedRep, } +/// Intrinsic definitions to go with [`WasmImport::FutureIntrinsic`] which +/// also goes with [`Resolve::wasm_import_name`]. +#[derive(Debug)] +pub enum FutureIntrinsic { + New, + Read, + Write, + CancelRead, + CancelWrite, + DropReadable, + DropWritable, +} + +/// Intrinsic definitions to go with [`WasmImport::StreamIntrinsic`] which +/// also goes with [`Resolve::wasm_import_name`]. +#[derive(Debug)] +pub enum StreamIntrinsic { + New, + Read, + Write, + CancelRead, + CancelWrite, + DropReadable, + DropWritable, +} + /// Indicates whether a function export is a normal export, a post-return /// function, or a callback function. #[derive(Debug)] @@ -4232,6 +4415,7 @@ impl core::error::Error for InvalidTransitiveDependency {} #[cfg(test)] mod tests { + use crate::alloc::format; use crate::alloc::string::ToString; use crate::{Resolve, WorldItem, WorldKey}; use anyhow::Result; @@ -4296,6 +4480,145 @@ mod tests { Ok(()) } + #[test] + fn wasm_import_name_future_and_stream_intrinsics() -> Result<()> { + use crate::{FutureIntrinsic, LiftLowerAbi, ManglingAndAbi, StreamIntrinsic, WasmImport}; + + let mut resolve = Resolve::default(); + let pkg = resolve.push_str( + "test.wit", + r#" + package foo:bar; + + interface iface { + iface-func: func(x: future) -> stream; + } + + world w { + import import-func: func(x: future>, y: u32) -> stream; + export export-func: func(x: future, y: stream); + import iface; + export iface; + } + "#, + )?; + let world = resolve.packages[pkg].worlds["w"]; + let world = &resolve.worlds[world]; + let mangling = ManglingAndAbi::Legacy(LiftLowerAbi::AsyncStackful); + + let WorldItem::Function(import_func) = + &world.imports[&WorldKey::Name("import-func".to_string())] + else { + panic!("expected `import-func` to be a top-level world import"); + }; + let WorldItem::Function(export_func) = + &world.exports[&WorldKey::Name("export-func".to_string())] + else { + panic!("expected `export-func` to be a top-level world export"); + }; + + let (interface_key, interface_func) = world + .imports + .iter() + .find_map(|(key, item)| match item { + WorldItem::Interface { id, .. } => Some(( + key.clone(), + &resolve.interfaces[*id].functions["iface-func"], + )), + _ => None, + }) + .expect("expected interface import"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::FutureIntrinsic { + interface: None, + func: import_func, + type_index: Some(0), + intrinsic: FutureIntrinsic::New, + exported: false, + async_: false, + }, + ); + assert_eq!(module, "$root"); + assert_eq!(name, "[future-new-0]import-func"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::FutureIntrinsic { + interface: None, + func: import_func, + type_index: Some(1), + intrinsic: FutureIntrinsic::Read, + exported: false, + async_: true, + }, + ); + assert_eq!(module, "$root"); + assert_eq!(name, "[async-lower][future-read-1]import-func"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::StreamIntrinsic { + interface: None, + func: import_func, + type_index: Some(2), + intrinsic: StreamIntrinsic::CancelRead, + exported: false, + async_: true, + }, + ); + assert_eq!(module, "$root"); + assert_eq!(name, "[async-lower][stream-cancel-read-2]import-func"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::FutureIntrinsic { + interface: None, + func: export_func, + type_index: None, + intrinsic: FutureIntrinsic::DropReadable, + exported: true, + async_: false, + }, + ); + assert_eq!(module, "[export]$root"); + assert_eq!(name, "[future-drop-readable-unit]export-func"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::StreamIntrinsic { + interface: None, + func: export_func, + type_index: None, + intrinsic: StreamIntrinsic::Write, + exported: true, + async_: true, + }, + ); + assert_eq!(module, "[export]$root"); + assert_eq!(name, "[async-lower][stream-write-unit]export-func"); + + let (module, name) = resolve.wasm_import_name( + mangling, + WasmImport::StreamIntrinsic { + interface: Some(&interface_key), + func: interface_func, + type_index: Some(1), + intrinsic: StreamIntrinsic::Read, + exported: true, + async_: false, + }, + ); + assert_eq!( + module, + format!("[export]{}", resolve.name_world_key(&interface_key)) + ); + assert_eq!(name, "[stream-read-1]iface-func"); + + Ok(()) + } + /// When there are multiple packages and there's no main package, don't /// pick a world just based on it being the only one that matches. #[test] From ced4d966a2f773dab1496e55141e6fad8d5ec88b Mon Sep 17 00:00:00 2001 From: yezihang Date: Tue, 3 Mar 2026 14:00:37 +0800 Subject: [PATCH 2/2] wit-parser: use TypeId for async payload import naming --- crates/wit-component/src/dummy.rs | 11 ++---- crates/wit-parser/src/resolve/mod.rs | 56 ++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/crates/wit-component/src/dummy.rs b/crates/wit-component/src/dummy.rs index 65f1c57e93..257b21053f 100644 --- a/crates/wit-component/src/dummy.rs +++ b/crates/wit-component/src/dummy.rs @@ -168,12 +168,7 @@ fn push_imported_future_and_stream_intrinsics( interface: Option<&WorldKey>, func: &Function, ) { - for (i, id) in func - .find_futures_and_streams(resolve) - .into_iter() - .enumerate() - { - let type_index = u32::try_from(i).unwrap(); + for id in func.find_futures_and_streams(resolve).into_iter() { match &resolve.types[id].kind { TypeDefKind::Future(_) => { let mut module = None; @@ -183,7 +178,7 @@ fn push_imported_future_and_stream_intrinsics( WasmImport::FutureIntrinsic { interface, func, - type_index: Some(type_index), + ty: Some(id), intrinsic, exported, async_, @@ -236,7 +231,7 @@ fn push_imported_future_and_stream_intrinsics( WasmImport::StreamIntrinsic { interface, func, - type_index: Some(type_index), + ty: Some(id), intrinsic, exported, async_, diff --git a/crates/wit-parser/src/resolve/mod.rs b/crates/wit-parser/src/resolve/mod.rs index 34aec49cd0..f7d7b5ac92 100644 --- a/crates/wit-parser/src/resolve/mod.rs +++ b/crates/wit-parser/src/resolve/mod.rs @@ -2482,7 +2482,7 @@ package {name} is defined in two different locations:\n\ WasmImport::FutureIntrinsic { interface, func, - type_index, + ty, intrinsic, exported, async_, @@ -2492,8 +2492,18 @@ package {name} is defined in two different locations:\n\ Some(key) => format!("{module_prefix}{}", self.name_world_key(key)), None => format!("{module_prefix}$root"), }; - let type_index = match type_index { - Some(i) => i.to_string(), + let type_index = match ty { + Some(ty) => func + .find_futures_and_streams(self) + .into_iter() + .position(|candidate| candidate == ty) + .unwrap_or_else(|| { + panic!( + "future type {ty:?} not found in `find_futures_and_streams` for `{}`", + func.name + ) + }) + .to_string(), None => "unit".to_string(), }; let (async_prefix, name) = match intrinsic { @@ -2530,7 +2540,7 @@ package {name} is defined in two different locations:\n\ WasmImport::StreamIntrinsic { interface, func, - type_index, + ty, intrinsic, exported, async_, @@ -2540,8 +2550,18 @@ package {name} is defined in two different locations:\n\ Some(key) => format!("{module_prefix}{}", self.name_world_key(key)), None => format!("{module_prefix}$root"), }; - let type_index = match type_index { - Some(i) => i.to_string(), + let type_index = match ty { + Some(ty) => func + .find_futures_and_streams(self) + .into_iter() + .position(|candidate| candidate == ty) + .unwrap_or_else(|| { + panic!( + "stream type {ty:?} not found in `find_futures_and_streams` for `{}`", + func.name + ) + }) + .to_string(), None => "unit".to_string(), }; let (async_prefix, name) = match intrinsic { @@ -2818,10 +2838,10 @@ pub enum WasmImport<'a> { /// The function whose signature this future type appears in. func: &'a Function, - /// The index into `func.find_futures_and_streams(resolve)`. + /// The future type appearing in `func.find_futures_and_streams(resolve)`. /// /// Use `None` for the special `unit` payload case. - type_index: Option, + ty: Option, /// The intrinsic that's being imported. intrinsic: FutureIntrinsic, @@ -2845,10 +2865,10 @@ pub enum WasmImport<'a> { /// The function whose signature this stream type appears in. func: &'a Function, - /// The index into `func.find_futures_and_streams(resolve)`. + /// The stream type appearing in `func.find_futures_and_streams(resolve)`. /// /// Use `None` for the special `unit` payload case. - type_index: Option, + ty: Option, /// The intrinsic that's being imported. intrinsic: StreamIntrinsic, @@ -4516,6 +4536,8 @@ mod tests { else { panic!("expected `export-func` to be a top-level world export"); }; + let import_types = import_func.find_futures_and_streams(&resolve); + assert_eq!(import_types.len(), 3); let (interface_key, interface_func) = world .imports @@ -4528,13 +4550,15 @@ mod tests { _ => None, }) .expect("expected interface import"); + let interface_types = interface_func.find_futures_and_streams(&resolve); + assert_eq!(interface_types.len(), 2); let (module, name) = resolve.wasm_import_name( mangling, WasmImport::FutureIntrinsic { interface: None, func: import_func, - type_index: Some(0), + ty: Some(import_types[0]), intrinsic: FutureIntrinsic::New, exported: false, async_: false, @@ -4548,7 +4572,7 @@ mod tests { WasmImport::FutureIntrinsic { interface: None, func: import_func, - type_index: Some(1), + ty: Some(import_types[1]), intrinsic: FutureIntrinsic::Read, exported: false, async_: true, @@ -4562,7 +4586,7 @@ mod tests { WasmImport::StreamIntrinsic { interface: None, func: import_func, - type_index: Some(2), + ty: Some(import_types[2]), intrinsic: StreamIntrinsic::CancelRead, exported: false, async_: true, @@ -4576,7 +4600,7 @@ mod tests { WasmImport::FutureIntrinsic { interface: None, func: export_func, - type_index: None, + ty: None, intrinsic: FutureIntrinsic::DropReadable, exported: true, async_: false, @@ -4590,7 +4614,7 @@ mod tests { WasmImport::StreamIntrinsic { interface: None, func: export_func, - type_index: None, + ty: None, intrinsic: StreamIntrinsic::Write, exported: true, async_: true, @@ -4604,7 +4628,7 @@ mod tests { WasmImport::StreamIntrinsic { interface: Some(&interface_key), func: interface_func, - type_index: Some(1), + ty: Some(interface_types[1]), intrinsic: StreamIntrinsic::Read, exported: true, async_: false,