Skip to content

[Rust] export_cabi codegen bug #1466

@chenyan2002

Description

@chenyan2002

Consider this WIT

package test:test;

interface original {
  resource extra-options;
  record options {
    extra: option<borrow<extra-options>>,
  }
}

interface adapter {
  use original.{options};
  f: func(x: options);
}

world root {
  export original;
  export adapter;
}

wit-bindgen generates this code for adapter interface,

pub mod adapter {
  pub type Options<'a,> = super::super::super::super::exports::test::test::original::Options<'a,>;
  pub unsafe fn _export_f_cabi<T: Guest>(arg0: i32,arg1: i32,) {
    ...
      let e = ExtraOptionsBorrow::lift(arg1 as u32 as usize);
    ...
  }
}

ExtraOptionsBorrow needs to use relative path, otherwise the code won't compile.
If the world doesn't export original, the generated code is using the relative path correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions