Skip to content

Conversation

Jules-Bertholet
Copy link
Contributor

@Jules-Bertholet Jules-Bertholet commented Sep 28, 2025

Add a warn-by-default unused_visibilities lint for visibility qualifiers on const _ declarations—e.g. pub const _: () = ();. Such qualifiers have no effect.

A Sourcegraph search suggests that this pattern is relatively rare, and mostly found in tests (with only 3 exceptions). So perhaps this could become an FCW/hard error in the future.

@rustbot label T-lang A-lints A-visibility

@rustbot
Copy link
Collaborator

rustbot commented Sep 28, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy
^^ Reviewed Clippy part by @blyxyas

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 28, 2025

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
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

@rustbot rustbot added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-visibility Area: Visibility / privacy T-lang Relevant to the language team labels Sep 28, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Add a warn-by-default `unused_visibility` lint for visibility qualifiers on `const _` declarations - e.g. `pub const _: () = ();`. These have no effect.
@jdonszelmann
Copy link
Contributor

cc: @rust-lang/lang

@traviscross traviscross added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Sep 29, 2025
@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 Sep 30, 2025
@jdonszelmann
Copy link
Contributor

seems reasonable from me (compiler) then, gotta wait for lang approval

@scottmcm

This comment was marked as outdated.

@rust-rfcbot

This comment was marked as outdated.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 1, 2025
@Jules-Bertholet

This comment was marked as outdated.

@Noratrieb Noratrieb removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-clippy Relevant to the Clippy team. labels Oct 1, 2025
@Noratrieb

This comment was marked as outdated.

@Noratrieb

This comment was marked as outdated.

@scottmcm

This comment was marked as outdated.

@rust-rfcbot

This comment was marked as outdated.

@rust-rfcbot rust-rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 1, 2025
@scottmcm
Copy link
Member

scottmcm commented Oct 2, 2025

I think this seems fine to warn on from the perspective of "don't write things that you don't need", though probably with the usual "well if it came from a macro it's fine" kinds of limits because if the vis or ident was passed-in then complaining about it might not be worth it.

@rfcbot fcp merge


Personally I don't know that I'd want to FCW this. For me it's not the "we don't want to define a meaning for this" case where turning things into hard errors is most valuable; it's more the "well, you don't need to do this but what it does is clear (even if what it does is functionally nothing)".

But that's not something we need to decide in this issue and that decision isn't part of the FCP.

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Oct 2, 2025

Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 2, 2025
@Jules-Bertholet
Copy link
Contributor Author

Personally, I would support an FCW, for the same reasons we disallow let mut _. But that discussion can happen later

@traviscross
Copy link
Contributor

traviscross commented Oct 2, 2025

Agree with @scottmcm here, including the analysis of whether an FCW is warranted (which we're not deciding here).

@rfcbot reviewed

@scottmcm
Copy link
Member

scottmcm commented Oct 2, 2025

for the same reasons we disallow let mut _

Note that mut is a binding modifier, not an item modifier, so it's not quite analogous. let mut _ doesn't have a binding to mut, but pub const _ does arguably have a constant to pub.

(aka mut is part of the same grammar thing as the binding itself, whereas the visibility it part of the item grammar that isn't split out by whether it's a _ or not.)

But we don't need to resolve this here either way. The FCP is compatible with both paths in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-visibility Area: Visibility / privacy disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-lang Relevant to the language team

8 participants