Import js macro using `use` requires importing _js_impl as well
daboross opened this issue · comments
As part of transition to rust 2018 idioms in one of my projects, I ran into an issue with macro imports in stdweb
. Particularly, the following code fails to compile:
use stdweb::js;
fn main() {
js! {
console.log("Hello, world!");
}
}
With the following error:
error: cannot find macro `_js_impl!` in this scope
--> src/main.rs:4:5
|
4 | / js! {
5 | | console.log("Hello, world!");
6 | | }
| |_____^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
Importing the macro using #[macro_use]
still works, as does
use stdweb::{_js_impl, js};
fn main() {
js! {
console.log("Hello, world!");
}
}
The edition guide's macro changes section documents this error, as well as two ways to fix it. Since the minimum rust version for this crate is 1.33.0, I think using $crate::
to reference local macros should be reasonable?
Edit: realized the minimum rust version of stdweb is already 1.33.0