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

Crate level attribute does not work in file included by include macro #99804

Closed
hehaoqian opened this issue Jul 27, 2022 · 1 comment
Closed
Labels
C-bug Category: This is a bug.

Comments

@hehaoqian
Copy link
Contributor

I want to share deny warnings settings among multiple crates,
so I want to use the include! macro to include files

I tried this code:

// main.rs
include!("deny_warnings.rs");

fn main() {
}
// deny_warnings.rs
#![deny(warnings)]

I expected to see this happen: Compilation success

Instead, this happened:

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

error: expected item after attributes
--> deny_warnings.rs:1:1
|
1 | #![deny(warnings)]
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

Meta

rustc --version --verbose:

rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
Backtrace

@hehaoqian hehaoqian added the C-bug Category: This is a bug. label Jul 27, 2022
@ehuss
Copy link
Contributor

ehuss commented Jul 27, 2022

Closing as a duplicate of #66920 (and #47995 and #18810 and rust-lang/rfcs#752).

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants