Static rustc_lint_defs::builtin::MACRO_USE_EXTERN_CRATE

source ·
pub static MACRO_USE_EXTERN_CRATE: &Lint
Expand description

The macro_use_extern_crate lint detects the use of the macro_use attribute.



extern crate serde_json;

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

This will produce:

error: applying the `#[macro_use]` attribute to an `extern crate` item is deprecated
 --> src/
3 | #[macro_use]
  | ^^^^^^^^^^^^
  = help: remove it and import macros at use sites with a `use` item instead
note: the lint level is defined here
 --> src/
1 | #![deny(macro_use_extern_crate)]
  |         ^^^^^^^^^^^^^^^^^^^^^^


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.