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

emit unused_attributes lint for silly attributes #55112

Closed
3 of 4 tasks
zackmdavis opened this issue Oct 16, 2018 · 3 comments · Fixed by #88681
Closed
3 of 4 tasks

emit unused_attributes lint for silly attributes #55112

zackmdavis opened this issue Oct 16, 2018 · 3 comments · Fixed by #88681
Labels
A-attributes Area: #[attributes(..)] A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zackmdavis
Copy link
Member

zackmdavis commented Oct 16, 2018

We already have an UnusedAttributes late lint pass for attributes that don't get marked as having been used somewhere, but recent discussion has touched on the idea of also directly (during normal complication, not as a lint pass) issuing the lint for attributes that don't make much sense (but which we don't want to go to the length of declaring errors, e.g., for backwards-compatibility reasons). These include:

@zackmdavis zackmdavis added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-attributes Area: #[attributes(..)] labels Oct 16, 2018
@varkor
Copy link
Member

varkor commented Oct 16, 2018

I think "#[must_use] on functions with unit or uninhabited return type" should be a Clippy lint rather than a compiler lint.

@Centril
Copy link
Contributor

Centril commented Oct 17, 2018

I've stricken #[must_use] per @varkor's note.

Centril added a commit to Centril/rust that referenced this issue Jun 22, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 22, 2019
@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2020
@ehuss
Copy link
Contributor

ehuss commented Sep 6, 2021

Posted #88681 which adds some checks for empty attributes like #[allow()].

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 19, 2021
…chenkov

Check for duplicate attributes.

This adds some checks for duplicate attributes. In many cases, the duplicates were being ignored without error or warning. This adds several kinds of checks (see `AttributeDuplicates` enum).

The motivation here is to issue unused warnings with similar reasoning for any unused lint, and to error for cases where there are conflicts.

This also adds a check for empty attribute lists in a few attributes where this causes the attribute to be ignored.

Closes rust-lang#55112.
@bors bors closed this as completed in f7c4829 Nov 22, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 8, 2022
…attr, r=lcnr

Emit `unused_attributes` if a level attr only has a reason

Fixes a comment from `compiler/rustc_lint/src/levels.rs`. Lint level attributes that only contain a reason will also trigger the `unused_attribute` lint. The lint now also checks for the `expect` lint level.

That's it, have a great rest of the day for everyone reasoning this 🙃

cc: rust-lang#55112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

5 participants