Skip to content

Inner attributes cannot be specified in include! files #47995

@Marwes

Description

@Marwes

Getting the following error when attempting to use an inner attribute in a file that gets called by include!.

error: an inner attribute is not permitted in this context
 --> test.rs:1:3
  |
1 | #![cfg_attr(rustfmt, rustfmt_skip)]
  |   ^
  |
  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.

Example

test.rs

#![cfg_attr(rustfmt, rustfmt_skip)]

fn main() {
}

main.rs

include!("test.rs");
$ rustc --version --verbose
rustc 1.25.0-nightly (5965b7901 2018-01-19)
binary: rustc
commit-hash: 5965b790142eff7a8546e947914e7a8e00c61575
commit-date: 2018-01-19
host: x86_64-pc-windows-msvc
release: 1.25.0-nightly
LLVM version: 4.0

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