Skip to content

Rust: export symbols may conflict #592

@peterhuene

Description

@peterhuene

If we generate bindings for the following world foo:

package wit:repro

interface foo1 {
  foo: func()
}

interface foo2 {
  foo: func()
}

world foo {
  export foo1
  export foo2
}

The export_foo macro will generate the following conflicting decls:

// ...
macro_rules! export_foo(($t:ident) => {
  const _: () = {

    #[doc(hidden)]
    #[export_name = "wit:repro/foo1#foo"]
    #[allow(non_snake_case)]
    unsafe extern "C" fn __export_foo() {
      bindings::exports::wit::repro::foo1::call_foo::<$t>()
    }

    #[doc(hidden)]
    #[export_name = "wit:repro/foo2#foo"]
    #[allow(non_snake_case)]
    unsafe extern "C" fn __export_foo() {
      bindings::exports::wit::repro::foo2::call_foo::<$t>()
    }
  };

 // ...

The code that generates these decls uses just the method name.

The name should be based on the qualified name of the interface as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssemblygood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions