Skip to content

Only the first expression in an include!d file is included. #35560

Open
@emilio

Description

@emilio

If you have a file that invokes a macro and you include! it, the following happens:

main.rs

fn main() {
    macro_rules! my_macro {
        ($name:expr) => {{
            printn!("{}", $name);
        }}
    }

    include!("helper.rs");
}

helper.rs

my_macro!("foo");
my_macro!("bar");

STR

$ rustc main.rs
$ ./main
foo

Expected output

Should print foo and bar, just as if the code would have been inlined.

Tested with latest nightly and stable:

rustc 1.12.0-nightly (080e0e072 2016-08-08)
rustc 1.10.0 (cfcb716cf 2016-07-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions