Why does the log crate work without #[macro_use]?

Other crates, like lazy_static require the annotation #[macro_use] to export macros, why does the log crate work without?


extern crate log;
use log::{warn};

fn main() {
warn!("why isn't #[macro_use] needed?")
    
}

(Playground)

#[macro_use] is no longer required since Rust 2018.

1 Like

And the same goes for extern crate. Your example can be written simply as

use log::warn;

fn main() {
    warn!("why isn't #[macro_use] needed?")
}

or

fn main() {
    log::warn!("why isn't #[macro_use] needed?")
}
1 Like