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 -T-clippy

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

@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 the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 1, 2025
@jdonszelmann
Copy link
Contributor

@rustbot author

@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 Dec 4, 2025
@Jules-Bertholet
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 5, 2025
@jdonszelmann
Copy link
Contributor

One more nit: you now say that there's no declared name to affect which is an explanation sure. But I think for someone to learn what's actually going on it's important to say that specifically assigning to _ creates no new name and that's why there's nothing to make pub. I think the fact that the name is _ should be highlighted more in the why

@rustbot author

@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 Dec 6, 2025
@bors
Copy link
Collaborator

bors commented Dec 6, 2025

☔ The latest upstream changes (presumably #149701) made this pull request unmergeable. Please resolve the merge conflicts.

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

rustbot commented Dec 6, 2025

This PR was rebased onto a different main 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
Copy link
Contributor

@bors r+ rollup

1 similar comment
@jdonszelmann
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 6, 2025

📌 Commit 43fa060 has been approved by jdonszelmann

It is now in the queue for this repository.

1 similar comment
@bors
Copy link
Collaborator

bors commented Dec 6, 2025

📌 Commit 43fa060 has been approved by jdonszelmann

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 6, 2025
bors added a commit that referenced this pull request Dec 7, 2025
Rollup of 4 pull requests

Successful merges:

 - #147136 (Add warn-by-default lint for visibility on `const _` declarations)
 - #149498 (Tidying up `tests/ui/issues` tests [1/N])
 - #149721 (rustc book: fix `*-pc-windows-msvc` link label in sidebar)
 - #149724 (Fix off-by-one staging output when testing the library)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 842f95d into rust-lang:main Dec 7, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 7, 2025
rust-timer added a commit that referenced this pull request Dec 7, 2025
Rollup merge of #147136 - Jules-Bertholet:const-_-unused-vis, r=jdonszelmann

Add warn-by-default lint for visibility on `const _` declarations

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](https://sourcegraph.com/search?q=context:global+lang:Rust+pub%5Cs*%28%5C%28.*%5C%29%29%3F%5Cs*const%5Cs%2B_%5Cs*:&patternType=regexp&case=yes&sm=0) 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 -T-clippy
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. finished-final-comment-period The final comment period is finished for this PR / Issue. 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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.