diff --git a/crates/gen-rust-wasm/src/lib.rs b/crates/gen-rust-wasm/src/lib.rs index 2667a9922..7600d4c9c 100644 --- a/crates/gen-rust-wasm/src/lib.rs +++ b/crates/gen-rust-wasm/src/lib.rs @@ -1580,8 +1580,10 @@ impl Bindgen for FunctionBindgen<'_> { match amt { 0 => {} 1 => { - self.push_str(&operands[0]); - self.push_str("\n"); + if &operands[0] != "()" { + self.push_str(&operands[0]); + self.push_str("\n"); + } } _ => { self.push_str("("); diff --git a/crates/gen-rust/src/lib.rs b/crates/gen-rust/src/lib.rs index 970f92635..bba71d8c8 100644 --- a/crates/gen-rust/src/lib.rs +++ b/crates/gen-rust/src/lib.rs @@ -88,8 +88,10 @@ pub trait RustGenerator { sig: &FnSig, ) -> Vec { let params = self.print_docs_and_params(iface, func, param_mode, &sig); - self.push_str(" -> "); - self.print_ty(iface, &func.result, TypeMode::Owned); + if !std::matches!(func.result, Type::Unit) { + self.push_str(" -> "); + self.print_ty(iface, &func.result, TypeMode::Owned); + } params }