Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inner attributes cannot be specified in include! files #47995

Closed
Marwes opened this issue Feb 4, 2018 · 1 comment
Closed

Inner attributes cannot be specified in include! files #47995

Marwes opened this issue Feb 4, 2018 · 1 comment

Comments

@Marwes
Copy link
Contributor

Marwes commented Feb 4, 2018

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
@TimNN
Copy link
Contributor

TimNN commented Feb 6, 2018

Duplicate of #18810, which was closed in favour of rust-lang/rfcs#752. In some situation you can work around this by having a #[path="test.rs"] mod foo;` (if I remember the syntax correctly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants