Hi, I was trying to figure out how include and use work across package boundaries and I triggered a panic in the wit-bindgen macro. I think it’d be better to report a nice error if my syntax is invalid. But in this case I think my syntax is valid?
colors/world.wit
package wasmo:colors;
interface colors {
resource rgb {
red: func() -> u32;
green: func() -> u32;
blue: func() -> u32;
}
}
testing/world.wit
package wasmo:testing;
world wasmo-testing {
use wasmo:colors/colors.{rgb};
export greyscale: func(color: rgb) -> u32;
}
lib.rs
mod bindings {
wit_bindgen::generate!({
path: [
"colors/world.wit",
"testing/world.wit",
],
world: "wasmo:testing/wasmo-testing",
});
use super::WasmoTesting;
export!(WasmoTesting);
}
error: proc macro panicked
--> src/lib.rs:11:5
|
11 | / wit_bindgen::generate!({
12 | | path: [
13 | | "colors/world.wit",
14 | | "testing/world.wit",
15 | | ],
16 | | world: "wasmo:testing/wasmo-testing",
17 | | });
| |______^
|
= help: message: called `Result::unwrap()` on an `Err` value: missing `with` mapping for the key `wasmo:colors/colors`
Stack backtrace:
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: std::backtrace_rs::backtrace::trace_unsynchronized::<<std::backtrace::Backtrace>::create::{closure#0}>
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: <std::backtrace::Backtrace>::create
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/backtrace.rs:331:13
3: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
4: <T as core::convert::Into<U>>::into
5: anyhow::kind::Trait::new
6: wit_bindgen_rust::RustWasm::name_interface
7: <wit_bindgen_rust::RustWasm as wit_bindgen_core::WorldGenerator>::preprocess
8: wit_bindgen_core::WorldGenerator::generate
9: wit_bindgen_rust_macro::Config::expand
10: wit_bindgen_rust_macro::generate
11: core::ops::function::Fn::call
12: proc_macro::bridge::client::Client<proc_macro::TokenStream,proc_macro::TokenStream>::expand1::{{closure}}::{{closure}}
13: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}
14: proc_macro::bridge::client::state::set
15: proc_macro::bridge::client::run_client::{{closure}}
16: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
17: std::panicking::catch_unwind::do_call
18: ___rust_try
19: proc_macro::bridge::client::run_client
20: proc_macro::bridge::client::Client<proc_macro::TokenStream,proc_macro::TokenStream>::expand1::{{closure}}
21: proc_macro::bridge::selfless_reify::reify_to_extern_c_fn_hrt_bridge::wrapper
22: <rustc_proc_macro::bridge::server::MaybeCrossThread as rustc_proc_macro::bridge::server::ExecutionStrategy>::run_bridge_and_client::<rustc_expand::proc_macro_server::Rustc>
23: <rustc_proc_macro::bridge::client::Client<rustc_proc_macro::TokenStream, rustc_proc_macro::TokenStream>>::run::<rustc_expand::proc_macro_server::Rustc, rustc_proc_macro::bridge::server::MaybeCrossThread>
24: <rustc_expand::proc_macro::BangProcMacro as rustc_expand::base::BangProcMacro>::expand
25: <rustc_expand::expand::MacroExpander>::expand_invoc
26: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
27: <rustc_expand::expand::MacroExpander>::expand_crate
28: rustc_interface::passes::configure_and_expand
29: rustc_interface::passes::resolver_for_lowering_raw
30: rustc_query_impl::query_impl::resolver_for_lowering_raw::invoke_provider_fn::__rust_begin_short_backtrace
31: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 16]>>, true>
32: rustc_query_impl::query_impl::resolver_for_lowering_raw::execute_query_incr::__rust_end_short_backtrace
33: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
34: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
35: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
36: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
37: <std::sys::thread::unix::Thread>::new::thread_start
38: __pthread_cond_wait
Hi, I was trying to figure out how
includeandusework across package boundaries and I triggered a panic in the wit-bindgen macro. I think it’d be better to report a nice error if my syntax is invalid. But in this case I think my syntax is valid?colors/world.wittesting/world.witlib.rs