Skip to content

improve diagnostic for literals in lint attributes - #164486

Merged
rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
annieversary:bad-attribute-lit
Oct 18, 2026
Merged

rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
annieversary:bad-attribute-lit

Conversation

@annieversary

@annieversary annieversary commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Improves the diagnostic for literals in lint attributes, like #[allow("meow")].

Before:

error[E0452]: malformed lint attribute input
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ bad attribute argument

error[E0452]: malformed lint attribute input
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ bad attribute argument

After:

error: expected path to a lint, found literal
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ not a lint
  |
  = help: try using `#[allow(meow)]`

error: expected path to a lint, found literal
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ not a lint
  |
  = help: for example, write `#[deny(dead_code)]` for `dead_code`

Probably easier to review with whitespace changes turned off.

r? JonathanBrouwer

@rustbot

rustbot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 17, 2026
@rustbot

rustbot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

JonathanBrouwer is currently at their maximum review capacity.
They may take a while to respond.

@rustbot

rustbot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @JonathanBrouwer (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

@jdonszelmann jdonszelmann left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for this change?

View changes since this review

Comment thread compiler/rustc_attr_parsing/src/attributes/lint.rs Outdated
@jdonszelmann

Copy link
Copy Markdown
Contributor

Also grats on your first contrib ^.^

@rust-log-analyzer

This comment has been minimized.

@annieversary

Copy link
Copy Markdown
Contributor Author

I added a test (as a commit before the one with my change, as suggested by @N1ark), changed the original commit to update this test and another that failed, and made another commit to rename sub to kind. :3

Comment thread tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr Outdated
Comment thread tests/ui/diagnostic-flags/deduplicate-diagnostics.rs Outdated
Comment thread tests/ui/lint/lint-attribute-literals.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread compiler/rustc_attr_parsing/src/diagnostics.rs Outdated
Comment thread compiler/rustc_attr_parsing/src/diagnostics.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2026
@rustbot

rustbot commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors r+ rollup
Thanks a lot for improving this!

View changes since this review

@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 31b27ab has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 18, 2026
…JonathanBrouwer

improve diagnostic for literals in lint attributes

Improves the diagnostic for literals in lint attributes, like `#[allow("meow")]`.

Before:
```
error[E0452]: malformed lint attribute input
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ bad attribute argument

error[E0452]: malformed lint attribute input
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ bad attribute argument
```
After:
```
error: expected path to a lint, found literal
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ not a lint
  |
  = help: try using `#[allow(meow)]`

error: expected path to a lint, found literal
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ not a lint
  |
  = help: for example, write `#[deny(dead_code)]` for `dead_code`
```

Probably easier to review with whitespace changes turned off.

r? JonathanBrouwer
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 18, 2026
@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved due to being closed.

This PR was contained in the following rollups:

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

Whoops I did not intend on doing that
@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 31b27ab has been tentatively approved by JonathanBrouwer

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r+ force

@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 31b27ab has been approved by JonathanBrouwer

It is now in the queue for this repository.

rust-bors Bot pushed a commit that referenced this pull request Oct 18, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #164518 (stdarch subtree update)
 - #164497 (Generate redirect pages for hidden modules)
 - #113891 (Add more syscall doc aliases to std docs)
 - #163692 (breakpoint: warn against relying on SIGTRAP aborts)
 - #164486 (improve diagnostic for literals in lint attributes)
 - #164511 (abort_on_unwind: clarify docs)
@rust-bors
rust-bors Bot merged commit 62d48ad into rust-lang:main Oct 18, 2026
28 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 18, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 18, 2026
Rollup merge of #164486 - annieversary:bad-attribute-lit, r=JonathanBrouwer

improve diagnostic for literals in lint attributes

Improves the diagnostic for literals in lint attributes, like `#[allow("meow")]`.

Before:
```
error[E0452]: malformed lint attribute input
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ bad attribute argument

error[E0452]: malformed lint attribute input
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ bad attribute argument
```
After:
```
error: expected path to a lint, found literal
 --> main.rs:5:9
  |
5 | #[allow("meow")]
  |         ^^^^^^ not a lint
  |
  = help: try using `#[allow(meow)]`

error: expected path to a lint, found literal
 --> main.rs:8:8
  |
8 | #[deny(1.0)]
  |        ^^^ not a lint
  |
  = help: for example, write `#[deny(dead_code)]` for `dead_code`
```

Probably easier to review with whitespace changes turned off.

r? JonathanBrouwer
@annieversary
annieversary deleted the bad-attribute-lit branch October 18, 2026 19:41
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Oct 19, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#164518 (stdarch subtree update)
 - rust-lang/rust#164497 (Generate redirect pages for hidden modules)
 - rust-lang/rust#113891 (Add more syscall doc aliases to std docs)
 - rust-lang/rust#163692 (breakpoint: warn against relying on SIGTRAP aborts)
 - rust-lang/rust#164486 (improve diagnostic for literals in lint attributes)
 - rust-lang/rust#164511 (abort_on_unwind: clarify docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants