Skip to content

don't suggest turning crate-level attributes into outer style #127930

Closed

Description

Code

#![allow(dead_code)]
fn foo() {}
#![feature(iter_array_chunks)]
fn bar() {}

Current output

Compiling playground v0.0.1 (/playground)
error: an inner attribute is not permitted in this context
 --> src/lib.rs:3:1
  |
3 | #![feature(iter_array_chunks)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | fn bar() {}
  | ----------- the inner attribute doesn't annotate this function
  |
  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the function, change the attribute from inner to outer style
  |
3 - #![feature(iter_array_chunks)]
3 + #[feature(iter_array_chunks)]
  |

Desired output

Compiling playground v0.0.1 (/playground)
error: an inner attribute is not permitted in this context
 --> src/lib.rs:3:1
  |
3 | #![feature(iter_array_chunks)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | fn bar() {}
  | ----------- the inner attribute doesn't annotate this function
  |
  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files

Rationale and extra context

reduces distracting noise

Other cases

No response

Rust Version

rustc 1.80.0-nightly (debd22da6 2024-05-29)
binary: rustc
commit-hash: debd22da66cfa97c74040ebf68e420672ac8560e
commit-date: 2024-05-29
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions