Skip to content

No longer able to generate bindings in submodule #973

@rylev

Description

@rylev

The following works in the latest release but not on main:

package my-ns:my-package;

interface my-interface {
  my-func: func();
}

world my-world {
  import my-interface;
  export my-interface;
}
mod bindings {
    wit_bindgen::generate!({
        path: "wit",
    });
}

use bindings::exports::my_ns::my_package::my_interface::Guest;

bindings::export!(Impl);

struct Impl;

impl Guest for Impl {
    fn my_func() {}
}

On the main, the following error shows:

error[E0433]: failed to resolve: could not find `export` in the crate root
  --> src/lib.rs:3:5
   |
3  | /     wit_bindgen::generate!({
4  | |         path: "wit",
5  | |     });
   | |______^ could not find `export` in the crate root
...
10 |   bindings::export!(Impl);
   |   ----------------------- in this macro invocation

Seems we're now assuming something lives at the crate root which we did not assume before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions