Skip to content

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

Closed

Description

@lolbinarycat

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 18, 2024
  2. tgross35 commented on Jul 19, 2024

    @tgross35
    Member

    We might be able to suggest moving it to the top of the module by default. And then only if it an attribute known to work as both inner and outer (allow/deny, cfg, etc) suggest removing the !.

  3. added
    D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
    on Jul 19, 2024
  4. self-assigned this
    on Aug 1, 2024
  5. added 2 commits that reference this issue on Aug 24, 2024
    05c3360
    0f78b48
  6. added a commit that references this issue on Aug 25, 2024
    dfe7d5c
  7. added a commit that references this issue on Aug 25, 2024
    271bf96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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