Skip to content

Macro import does not bring dependent macros in scope in 2018 edition #53811

Closed
@VoidStarKat

Description

@VoidStarKat

Importing a macro from a crate in 2018 edition that invokes other macros does not bring those macros in scope. It's easy enough to make work by importing the other macros of course, but surprising behavior anyway, especially when it involves importing macros that won't actually be referenced anywhere in the file itself, only through invocations.

Example (using clap 2.32):

use clap::app_from_crate;
fn main() {
    let _args = app_from_crate!().get_matches();
}

will produce the following error

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions