Skip to content

include! macro fails if included file has top-level inner attributes #18810

Closed
@dwrensha

Description

@dwrensha
// test.rs

pub mod included {
    include!("test_included.rs")
}

fn main() {}
// test_included.rs

#![allow(dead_code)]

pub fn foo() {}
$ rustc test.rs
test_included.rs:3:3: 3:4 error: an inner attribute is not permitted in this context
test_included.rs:3 #![allow(dead_code)]
                     ^
error: aborting due to previous error

I at first thought that the problem was due to the implicit insert of the prelude in the included module. However, adding a #[no_implicit_prelude] attribute does not help.

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