diff --git a/crates/rust/src/lib.rs b/crates/rust/src/lib.rs index f8d99cbab..ae446893e 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -566,6 +566,7 @@ impl InterfaceGenerator<'_> { uwrite!( macro_src, " + const _: () = {{ #[doc(hidden)] #[export_name = \"{export_name}\"] #[allow(non_snake_case)] @@ -647,7 +648,8 @@ impl InterfaceGenerator<'_> { for param in params.iter() { uwrite!(macro_src, "{param},"); } - uwriteln!(macro_src, ")\n}}"); + uwriteln!(macro_src, ")\n}}"); // close function call and function + uwriteln!(macro_src, "\n}};"); // close `const _: () = { ...` let mut f = FunctionBindgen::new(self, params); f.gen.resolve.call( diff --git a/crates/rust/tests/codegen.rs b/crates/rust/tests/codegen.rs index 62267f764..c33e570bb 100644 --- a/crates/rust/tests/codegen.rs +++ b/crates/rust/tests/codegen.rs @@ -168,3 +168,36 @@ mod skip { export_baz!(Component); } + +mod symbol_does_not_conflict { + wit_bindgen::generate!({ + inline: " + package my:inline + + interface foo1 { + foo: func() + } + + interface foo2 { + foo: func() + } + + world foo { + export foo1 + export foo2 + } + ", + }); + + struct Component; + + impl exports::my::inline::foo1::Foo1 for Component { + fn foo() {} + } + + impl exports::my::inline::foo2::Foo2 for Component { + fn foo() {} + } + + export_foo!(Component); +}