Skip to content

Commit c2f47bd

Browse files
committed
fix(gen-rust-wasm): get rid of unused unit warning
1 parent 2679e06 commit c2f47bd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/gen-rust-wasm/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,8 +1580,10 @@ impl Bindgen for FunctionBindgen<'_> {
15801580
match amt {
15811581
0 => {}
15821582
1 => {
1583-
self.push_str(&operands[0]);
1584-
self.push_str("\n");
1583+
if &operands[0] != "()" {
1584+
self.push_str(&operands[0]);
1585+
self.push_str("\n");
1586+
}
15851587
}
15861588
_ => {
15871589
self.push_str("(");

crates/gen-rust/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ pub trait RustGenerator {
8888
sig: &FnSig,
8989
) -> Vec<String> {
9090
let params = self.print_docs_and_params(iface, func, param_mode, &sig);
91-
self.push_str(" -> ");
92-
self.print_ty(iface, &func.result, TypeMode::Owned);
91+
if !std::matches!(func.result, Type::Unit) {
92+
self.push_str(" -> ");
93+
self.print_ty(iface, &func.result, TypeMode::Owned);
94+
}
9395
params
9496
}
9597

0 commit comments

Comments
 (0)