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

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

Closed
lolbinarycat opened this issue Jul 18, 2024 · 1 comment · Fixed by #128524
Closed

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

lolbinarycat opened this issue Jul 18, 2024 · 1 comment · Fixed by #128524
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

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

@lolbinarycat lolbinarycat added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 18, 2024
@tgross35
Copy link
Contributor

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 !.

@tgross35 tgross35 added the D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. label Jul 19, 2024
@chenyukang chenyukang self-assigned this Aug 1, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 24, 2024
…id-outer-style-sugg, r=cjgillot

Don't suggest turning crate-level attributes into outer style

Fixes rust-lang#127930
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 24, 2024
…id-outer-style-sugg, r=cjgillot

Don't suggest turning crate-level attributes into outer style

Fixes rust-lang#127930
@bors bors closed this as completed in dfe7d5c Aug 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 25, 2024
Rollup merge of rust-lang#128524 - chenyukang:yukang-fix-127930-invalid-outer-style-sugg, r=cjgillot

Don't suggest turning crate-level attributes into outer style

Fixes rust-lang#127930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants