Skip to content

bindgen: errors if interface and exported resource have same name #7775

@jcbhmr

Description

@jcbhmr

Thanks for filing a bug report! Please fill out the TODOs below.

Note: if you want to report a security issue, please read our security policy!

Test Case

TODO: upload Wasm file here
no wasm. just rust.

Steps to Reproduce

  • TODO: first, ...
  • TODO: second, ...
  • Etc...
  • crate a new cargo project
  • add wasmtime with the component-model feature
  • use the below wit in the wit/ folder with bindgen!()
  • see error
package jcbhmr:hello-world-rust-wasm-component-lib;

interface my-box {
  resource my-box {
    constructor(value: u32);
    value: func() -> u32;
  }
  set-global: func(value: my-box);
  global-value: func() -> u32;
}

world example {
  export my-box;
}
use wasmtime::component::*;
use wasmtime::{Config, Engine, Store};

bindgen!();

Expected Results

it to either auto-rename it due to duplication or otherwise scope it so that this collision doesn't happen

Actual Results

image

jcbhmr@PIG-2016:~/Documents/rswasmtest$ cargo  build
   Compiling rswasmtest v0.1.0 (/home/jcbhmr/Documents/rswasmtest)
error[E0428]: the name `MyBox` is defined multiple times
 --> src/main.rs:4:1
  |
4 | bindgen!();
  | ^^^^^^^^^^ `MyBox` redefined here
  |
  = note: `MyBox` must be defined only once in the type namespace of this module
  = note: this error originates in the macro `bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> src/main.rs:4:1
  |
4 | bindgen!();
  | ^^^^^^^^^^ impl for type defined outside of crate.
  |
  = note: define and implement a trait or new type instead
  = note: this error originates in the macro `bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0116, E0428.
For more information about an error, try `rustc --explain E0116`.
error: could not compile `rswasmtest` (bin "rswasmtest") due to 2 previous errors

Versions and Environment

Wasmtime version or commit: 16.0.0

Operating system: Windows 10 using WSL

Architecture: x86_64

Extra Info

Anything else you'd like to add?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions