Skip to content

include!ed files are unable to #[macro_use] #28071

Closed
@codyps

Description

@codyps

This makes using codegen a bit more cumbersome.

What happens:

main_real.rs:

// main_real.rs:
#[macro_use]
extern crate log;

fn main() {
    info!("Hi!");
}

main.rs:

include!{"main_real.rs"}

Cargo.toml:

[package]
name = "macro-use-include"
version = "0.1.0"
authors = ["Cody P Schafer <dev@codyps.com>"]

[dependencies]
log = "*"

Attempt to build:

% cargo build
   Compiling macro-use-include v0.1.0 (file:///home/cody/macro-use-include)
src/main_real.rs:5:5: 5:9 error: macro undefined: 'info!'
src/main_real.rs:5     info!("Hi");
                       ^~~~
error: aborting due to previous error
Could not compile `macro-use-include`.

To learn more, run the command again with --verbose.

Moving main_real.rs to main.rs builds as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions