In Rust 1.30 (pre-release build), #[macro_use] is no longer required when importing macros by name. However, it is unclear how to make this work with embed_migrations!, since the following doesn't compile:
use diesel_migrations::embed_migrations;
...
embed_migrations!();
...
The above fails to compile with:
error: cannot find derive macro `EmbedMigrations` in this scope
It is possible that I'm missing something - if so I would love to learn how to do this correctly.
Thanks in advance!
You will need to continue to use #[macro_use] for the time being.
@sgrif Any plans to change that? I try to avoid using #[macro_use] everywhere, preferring to be explicit about what is brought in (and from where).
@jhpratt Diesel 2.0 will contain a "fix" for this, but there is currently no concrete timeline for a release beside of The next big release will be 2.0.
@sgrif where exactly do I need to put #[macro_use]? Have tried all the obvious places but still seeing the error.
@quickdudley If you are talking about using diesel_migrations::embed_migrations!(), you can use macro_use like this:
#[macro_use]
extern crate diesel_migrations;
[...]
diesel_migrations::embed_migrations!();
You could also write it in one line like this #[macro_use] extern crate diesel_migrations;, but rustfmt will complain/correct it to the aforementioned way of writing it.
Thanks @dennissivia; I hadn't realised I'd need to use extern crate because everything except macros was available without it.
Most helpful comment
@sgrif Any plans to change that? I try to avoid using
#[macro_use]everywhere, preferring to be explicit about what is brought in (and from where).