How to use derive macros on the 2018 edition?


#1

I’m trying to use failure in a 2018-edition crate, but I’m getting:

error: cannot find derive macro `Fail` in this scope

What do I need to import to make it work? use failure::Fail doesn’t fix it.

Edit: adding use failure::* fixes it, though it gives me an unused import warning :stuck_out_tongue:. I’d rather not use glob imports though, and instead actually know what I’m importing.


#2

When you imported the failure crate, did you add the #[macro_use] attribute?


#3

I’m using the 2018 edition and trying not to use extern crate declarations at all, since they’re deprecated.


#4

Then you must use #![feature(use_extern_macros)]

https://rust-lang-nursery.github.io/edition-guide/2018/transitioning/modules/macros.html


#5

Aha! That fixed it :smiley:. I forgot all about that feature.

Thanks a lot!