Skip to content

Include Macro does not work properly: non-item macro in item position: include #17941

Closed
@mitsuhiko

Description

@mitsuhiko

test.rs:

include!("test.inc")

fn main() {
    println!("{}", foo());
}

test.inc:

fn foo() -> int {
    return 42;
}

Compiler error:

test.inc:1:1: 1:3 error: expected identifier, found keyword `fn`
test.inc:1 fn foo() -> int {
           ^~
test.rs:1:1: 1:8 error: non-item macro in item position: include
test.rs:1 include!("test.inc")
          ^~~~~~~
error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions