diff --git a/Cargo.lock b/Cargo.lock index 6eac4e468..65179de8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3425,8 +3425,8 @@ name = "test-helpers" version = "0.0.0" dependencies = [ "codegen-macro", - "wit-bindgen-core 0.37.0", - "wit-parser 0.223.1", + "wit-bindgen-core 0.38.0", + "wit-parser 0.224.1", ] [[package]] @@ -4381,9 +4381,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.223.1" +version = "0.224.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664b980991ed9a8c834eb528a8979ab1109edcf52dc05dd5751e2cc3fb31035d" +checksum = "04f17a5917c2ddd3819e84c661fae0d6ba29d7b9c1f0e96c708c65a9c4188e11" dependencies = [ "bitflags", "indexmap", @@ -5168,13 +5168,13 @@ checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" [[package]] name = "wit-bindgen-core" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba105733ba146c94e067793fb46505265ea8720eb14ceae65b10797c7728a65" +checksum = "70e2f98d49960a416074c5d72889f810ed3032a32ffef5e4760094426fefbfe8" dependencies = [ "anyhow", "heck", - "wit-parser 0.223.1", + "wit-parser 0.224.1", ] [[package]] @@ -5285,7 +5285,7 @@ dependencies = [ "clap", "heck", "test-helpers", - "wit-bindgen-core 0.37.0", + "wit-bindgen-core 0.38.0", "wrpc-introspect", ] @@ -5304,7 +5304,7 @@ dependencies = [ "syn", "test-helpers", "tokio", - "wit-bindgen-core 0.37.0", + "wit-bindgen-core 0.38.0", "wit-bindgen-wrpc", "wrpc-introspect", "wrpc-transport", @@ -5319,7 +5319,7 @@ dependencies = [ "proc-macro2", "quote", "syn", - "wit-bindgen-core 0.37.0", + "wit-bindgen-core 0.38.0", "wit-bindgen-wrpc-rust", ] @@ -5382,9 +5382,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.223.1" +version = "0.224.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "263fde17f1fbe55a413f16eb59094bf751795c6da469a05c3d45ea6c77df6b40" +checksum = "e3477d8d0acb530d76beaa8becbdb1e3face08929db275f39934963eb4f716f8" dependencies = [ "anyhow", "id-arena", @@ -5395,7 +5395,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.223.1", + "wasmparser 0.224.1", ] [[package]] @@ -5496,7 +5496,7 @@ dependencies = [ "wasmtime", "wasmtime-cli-flags", "wasmtime-wasi", - "wit-bindgen-core 0.37.0", + "wit-bindgen-core 0.38.0", "wit-bindgen-wrpc", "wit-bindgen-wrpc-go", "wit-bindgen-wrpc-rust", @@ -5525,7 +5525,7 @@ dependencies = [ name = "wrpc-introspect" version = "0.7.0" dependencies = [ - "wit-parser 0.223.1", + "wit-parser 0.224.1", ] [[package]] @@ -5655,7 +5655,7 @@ dependencies = [ "wasm-tokio", "wasmtime", "wasmtime-wasi", - "wit-parser 0.223.1", + "wit-parser 0.224.1", "wrpc-introspect", "wrpc-transport", ] diff --git a/Cargo.toml b/Cargo.toml index 0e949b570..bc9f300b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -179,13 +179,13 @@ wasmtime-cli-flags = { version = "45", default-features = false } wasmtime-wasi = { version = "45", default-features = false } wasmtime-wasi-http = { version = "45", default-features = false } wit-bindgen = { version = "0.45", default-features = false } -wit-bindgen-core = { version = "0.37", default-features = false } +wit-bindgen-core = { version = "0.38", default-features = false } wit-bindgen-wrpc = { version = "0.11", default-features = false, path = "./crates/wit-bindgen" } wit-bindgen-wrpc-go = { version = "0.13", default-features = false, path = "./crates/wit-bindgen-go" } wit-bindgen-wrpc-rust = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust" } wit-bindgen-wrpc-rust-macro = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust-macro" } wit-component = { version = "0.252", default-features = false } -wit-parser = { version = "0.223", default-features = false } +wit-parser = { version = "0.224", default-features = false } wrpc-cli = { version = "0.8", path = "./crates/cli", default-features = false } wrpc-introspect = { version = "0.7", default-features = false, path = "./crates/introspect" } wrpc-nats = { version = "0.1", path = "./crates/nats", default-features = false } diff --git a/crates/introspect/src/lib.rs b/crates/introspect/src/lib.rs index 5744ccf88..50a955152 100644 --- a/crates/introspect/src/lib.rs +++ b/crates/introspect/src/lib.rs @@ -190,13 +190,15 @@ pub fn async_paths_tyid(resolve: &Resolve, id: TypeId) -> (BTreeSet { let mut paths = BTreeSet::new(); - let (nested, fut) = async_paths_ty(resolve, element); - for mut path in nested { - path.push_front(None); - paths.insert(path); - } - if fut { - paths.insert(vec![None].into()); + if let Some(ty) = element { + let (nested, fut) = async_paths_ty(resolve, ty); + for mut path in nested { + path.push_front(None); + paths.insert(path); + } + if fut { + paths.insert(vec![None].into()); + } } (paths.into_iter().collect(), true) } diff --git a/crates/wit-bindgen-go/src/interface.rs b/crates/wit-bindgen-go/src/interface.rs index c17a0bf42..7ca6b7af5 100644 --- a/crates/wit-bindgen-go/src/interface.rs +++ b/crates/wit-bindgen-go/src/interface.rs @@ -1069,8 +1069,8 @@ impl InterfaceGenerator<'_> { } } - fn print_read_stream(&mut self, element: &Type, reader: &str, path: &str) { - match Some(element) { + fn print_read_stream(&mut self, element: &Option, reader: &str, path: &str) { + match element { Some(ty) if is_ty(self.resolve, Type::U8, ty) => { let bytes = self.deps.bytes(); let io = self.deps.io(); @@ -2065,8 +2065,8 @@ impl InterfaceGenerator<'_> { } } - fn print_write_stream(&mut self, element: &Type, name: &str, writer: &str) { - match Some(element) { + fn print_write_stream(&mut self, element: &Option, name: &str, writer: &str) { + match element { Some(ty) if is_ty(self.resolve, Type::U8, ty) => { let fmt = self.deps.fmt(); let io = self.deps.io(); @@ -3256,8 +3256,8 @@ func ServeInterface(s {wrpc}.Server, h Handler) (stop func() error, err error) { } } - fn print_stream(&mut self, element: &Type) { - match Some(element) { + fn print_stream(&mut self, element: &Option) { + match element { Some(ty) if is_ty(self.resolve, Type::U8, ty) => { let io = self.deps.io(); self.push_str(io); @@ -3884,7 +3884,7 @@ func (v *{name}) WriteToIndex(w {wrpc}.ByteWriter) (func({wrpc}.IndexWriter) err } } - fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Type, docs: &Docs) { + fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Option, docs: &Docs) { if let Some(name) = self.name_of(id) { self.godoc(docs); uwrite!(self.src, "type {name} = "); diff --git a/crates/wit-bindgen-rust/src/interface.rs b/crates/wit-bindgen-rust/src/interface.rs index 975bacbe0..7e4893e87 100644 --- a/crates/wit-bindgen-rust/src/interface.rs +++ b/crates/wit-bindgen-rust/src/interface.rs @@ -998,13 +998,17 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>( self.push_str("> + ::core::marker::Send>>"); } - fn print_stream(&mut self, element: &Type, submodule: bool) { + fn print_stream(&mut self, element: &Option, submodule: bool) { uwrite!( self.src, "::core::pin::Pin<::std::boxed::Box"); + } self.push_str("> + ::core::marker::Send>>"); } @@ -2468,7 +2472,7 @@ mod {mod_name} {{ } } - fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Type, docs: &Docs) { + fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Option, docs: &Docs) { if let Some(name) = self.name_of(id) { self.rustdoc(docs); uwrite!(self.src, "pub type {name} = "); diff --git a/tests/codegen/futures.wit b/tests/codegen/futures.wit index 2d634a400..ff24a5098 100644 --- a/tests/codegen/futures.wit +++ b/tests/codegen/futures.wit @@ -13,7 +13,7 @@ interface futures { future-f32-param: func(x: future); future-f64-param: func(x: future); - future-ret: func(x: future); + future-ret: func() -> future; future-u8-ret: func() -> future; future-u16-ret: func() -> future; future-u32-ret: func() -> future; diff --git a/tests/codegen/streams.wit b/tests/codegen/streams.wit index 7ed696ed8..96ccfeed2 100644 --- a/tests/codegen/streams.wit +++ b/tests/codegen/streams.wit @@ -15,6 +15,7 @@ interface transmit { } interface streams { + stream-param: func(x: stream); stream-u8-param: func(x: stream); stream-u16-param: func(x: stream); stream-u32-param: func(x: stream); @@ -26,6 +27,7 @@ interface streams { stream-f32-param: func(x: stream); stream-f64-param: func(x: stream); + stream-ret: func() -> stream; stream-u8-ret: func() -> stream; stream-u16-ret: func() -> stream; stream-u32-ret: func() -> stream;