wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

rust: Generated resource bindings can conflict with resource methods

Open lann opened this issue 1 year ago • 4 comments

package repro:pkg;
world example {
  resource repro {
    constructor();
    handle: func();
  }
}

generates two conflicting Repro::handle methods; one #[doc(hidden)] internal method and the actual resource method. Same would presumably be true for take_handle and (static) from_handle.

lann avatar Sep 28 '24 20:09 lann

Oops, thanks! For purely internal functions we should probably rename them to _foo or similar, but otherwise we'll probably need to "mangle" WIT-based names that conflict.

alexcrichton avatar Sep 30 '24 14:09 alexcrichton

Do they need to be methods? Could they just be regular (associated) functions?

lann avatar Sep 30 '24 14:09 lann

Good point yeah, doc(hidden) items can also be associated functions. Using _ as a prefix for those I think would also be reasonable

alexcrichton avatar Sep 30 '24 14:09 alexcrichton

I guess bindgen will never generate a _ prefix so it doesn't really matter :shrug:

lann avatar Sep 30 '24 15:09 lann