pub static MACRO_USE_EXTERN_CRATE: &Lint
Expand description

The macro_use_extern_crate lint detects the use of the macro_use attribute.

§Example

#![deny(macro_use_extern_crate)]

#[macro_use]
extern crate serde_json;

fn main() {
    let _ = json!{{}};
}

This will produce:

error: deprecated `#[macro_use]` attribute used to import macros should be replaced at use sites with a `use` item to import the macro instead
 --> src/main.rs:3:1
  |
3 | #[macro_use]
  | ^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(macro_use_extern_crate)]
  |         ^^^^^^^^^^^^^^^^^^^^^^

§Explanation

The macro_use attribute on an [extern crate] item causes macros in that external crate to be brought into the prelude of the crate, making the macros in scope everywhere. As part of the efforts to simplify handling of dependencies in the [2018 edition], the use of extern crate is being phased out. To bring macros from extern crates into scope, it is recommended to use a use import.

This lint is “allow” by default because this is a stylistic choice that has not been settled, see issue #52043 for more information.