Skip to content

Inner tool attributes emit spurious unused attribute warningΒ #81661

Closed

Description

I tried this code:

// main.rs
mod bar;

fn main() {
    bar::foo();
}
// bar.rs
#![rustfmt::skip]

pub fn foo() { println!("unformatted") }

I expected to see this happen: No warnings and bar.rs will not get formatted by cargo fmt.

Instead, this happened: cargo build emits a warning, bar.rs is correctly not formatted by cargo fmt.

warning: unused attribute
 --> src/bar.rs:1:1
  |
1 | #![rustfmt::skip]
  | ^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

While trying to minimize I changed mod bar to be an inline module, but that hits the unstable custom_inner_attributes feature (#54726). So maybe rustfmt shouldn't be obeying this attribute? Either way there's an inconsistency here with whether rustc or rustfmt believe the attribute is active or not.

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (0f6f2d681 2020-12-06)
binary: rustc
commit-hash: 0f6f2d681b39c5f95459cd09cb936b6ceb27cd82
commit-date: 2020-12-06
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions