Skip to content

Cannot import macros from extern crate with use in edition 2018  #54642

@csmoe

Description

@csmoe
#![deny(rust_2018_idioms)]

// works
// #[macro_use]
// extern crate clap; // 2.32.0

// err
use clap::app_from_crate;

fn main() {
  app_from_crate!();
}

Err:

error: cannot find macro `crate_name!` in this scope
  --> src/main.rs:11:3
   |
11 |   app_from_crate!();
   |   ^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `crate_version!` in this scope
  --> src/main.rs:11:3
   |
11 |   app_from_crate!();
   |   ^^^^^^^^^^^^^^^^^^ help: you could try the macro: `rustc_version`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `crate_authors!` in this scope
  --> src/main.rs:11:3
   |
11 |   app_from_crate!();
   |   ^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

playground


And it's kind of strange that rustc won't complain about unidiomatic extern crate ... even #![deny(rust_2018_idioms)] in the working one.
cc @petrochenkov

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions