Skip to content

Commit 7019072

Browse files
authored
fix symbol conflicts for post return (#602)
follow-up of #593
1 parent 8ceb28d commit 7019072

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

crates/rust/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ impl InterfaceGenerator<'_> {
687687
uwrite!(
688688
macro_src,
689689
"
690+
const _: () = {{
690691
#[doc(hidden)]
691692
#[export_name = \"cabi_post_{export_name}\"]
692693
#[allow(non_snake_case)]
@@ -708,7 +709,8 @@ impl InterfaceGenerator<'_> {
708709
for param in params.iter() {
709710
uwrite!(macro_src, "{param},");
710711
}
711-
uwriteln!(macro_src, ")\n}}");
712+
uwriteln!(macro_src, ")\n}}"); // close function call and function
713+
uwriteln!(macro_src, "\n}};"); // close `const _: () = { ...`
712714

713715
let mut f = FunctionBindgen::new(self, params);
714716
f.gen.resolve.post_return(func, &mut f);

crates/rust/tests/codegen.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,20 @@ mod symbol_does_not_conflict {
184184
foo: func()
185185
}
186186
187+
interface bar1 {
188+
bar: func() -> string
189+
}
190+
191+
interface bar2 {
192+
bar: func() -> string
193+
}
194+
195+
187196
world foo {
188197
export foo1
189198
export foo2
199+
export bar1
200+
export bar2
190201
}
191202
",
192203
});
@@ -201,5 +212,17 @@ mod symbol_does_not_conflict {
201212
fn foo() {}
202213
}
203214

215+
impl exports::my::inline::bar1::Bar1 for Component {
216+
fn bar() -> String {
217+
String::new()
218+
}
219+
}
220+
221+
impl exports::my::inline::bar2::Bar2 for Component {
222+
fn bar() -> String {
223+
String::new()
224+
}
225+
}
226+
204227
export_foo!(Component);
205228
}

0 commit comments

Comments
 (0)