improve diagnostics for empty attributes by jdonszelmann · Pull Request #146653 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation17 Commits1 Checks10 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@jdonszelmann

Adds a note about them not having any effect. This was previously done for feature attributes but no other attributes. In converting the feature parser I removed that note. This PR adds it back in and makes it so all attributes benefit from it.

Not blocked on #146652, either can merge first

@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

Sep 16, 2025

@rustbot

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jdonszelmann

@bors

@jdonszelmann

nnethercote

Choose a reason for hiding this comment

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

To be honest, I don't think this is an improvement. As explained below, in every case the note feels not quite right. The motivation was to restore the old behaviour for feature but I don't think it is necessary.

View changes since this review

LL | #[macro_use()]
| ^^ help: remove this attribute
|
= note: attribute `macro_use` with an empty list has no effect

Choose a reason for hiding this comment

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

I'm a bit surprised this is only a warning. But also, the note feels misleading: I assume macro_use() with an empty list does have an effect, i.e. the same effect as just macro_use.

A better improvement for this error message would be to say "remove these parentheses" instead of "remove this attribute".

Choose a reason for hiding this comment

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

I pushed a fix that makes this error better specifically when the no-argument version is available and so valid

@jdonszelmann

@rustbot

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

jdonszelmann

Choose a reason for hiding this comment

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

@jdonszelmann

@jdonszelmann

nnethercote

@nnethercote

@bors

📌 Commit b3631e1 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors 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-review

Status: Awaiting review from the assignee but also interested parties.

labels

Sep 29, 2025

bors added a commit that referenced this pull request

Sep 29, 2025

@bors

Rollup of 5 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit that referenced this pull request

Sep 29, 2025

@rust-timer

Rollup merge of #146653 - jdonszelmann:empty-attr-diags, r=nnethercote

improve diagnostics for empty attributes

Adds a note about them not having any effect. This was previously done for feature attributes but no other attributes. In converting the feature parser I removed that note. This PR adds it back in and makes it so all attributes benefit from it.

Not blocked on #146652, either can merge first

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Sep 30, 2025

@bors

github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request

Oct 2, 2025

@bors

flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request

Oct 18, 2025

@bors

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.