Skip to content

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

@steveklabnik

Description

@steveklabnik

Issue by dwrensha
Sunday Nov 09, 2014 at 14:25 GMT

For earlier discussion, see rust-lang/rust#18810

This issue was labelled with: in the Rust repository


// 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

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions