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

Start using clippy on rustc #709

Closed
1 of 3 tasks
Noratrieb opened this issue Dec 30, 2023 · 7 comments
Closed
1 of 3 tasks

Start using clippy on rustc #709

Noratrieb opened this issue Dec 30, 2023 · 7 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@Noratrieb
Copy link
Member

Proposal

Thanks to the amazing work T-bootstrap, clippy now works properly in rust-lang/rust! This is great, we should start using it.

We should enforce clippy in CI with -Aclippy::all -Dclippy::correctness. This ensures that there is not much effort and has the highest value. This finds real bugs, like rust-lang/rust#119447.

Running it locally doesn't show too many lints, mostly problems with clippy::unused_io_amount on slices (these should just use read_exact and some issues around bitflags (which should be resolved with the upgrade)). Fixing all of this is not too much effort and high value.

clippy::all has hundreds of warnings and it's not realistic to enforce this any time soon. It's also unclear whether we ever want that, and I would very much prefer not bikeshedding that right now, let's focus on clippy::correctness. Meanwhile, we're still happy to take fixes for clippy::all lints as long as they aren't too much of a burden to review.

cc @flip1995, this could cause some trouble on syncs if clippy ships new correctness lints that fire and we use in-tree clippy instead of beta clippy.

Mentors or Reviewers

anyone

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@Noratrieb Noratrieb added T-compiler Add this label so rfcbot knows to poll the compiler team major-change A proposal to make a major change to rustc labels Dec 30, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Dec 30, 2023
@compiler-errors
Copy link
Member

🙌

@rustbot second

i'm very in favor of allowing a limited amount of clippy lints to be enforced in the compiler

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Dec 30, 2023
@matthiaskrgr
Copy link
Member

I've been applying a lot of clippy fixes to the codebase in the past years and I would say the most interesting lint groups for rustc are perf, correctness, and complexity, in that order.

There are a lot of style or pedantic lints which may be "nice to have"™ but still would be a pain to be gating on.

Some general questions:

How do we want to control the set of lints that we apply on rustc?
We could do this in-code with warn/allow attrs on entire crates to ignore a couple of FPs but also "turn on this particular lint for core for example.
We could add global -W -A to flags to x.py clippy.
Do we want [allow(clippy::xy)] sprinkled around rustcs codebase to dodge FPs?

How do we handle subtrees like rustfmt or rust-analyzer which are checked by x.py clippy but may have different code policies.

I don't think that a clippy update should be blocked by new TPs/FPs in clippy showing up in rustcs codebase, what will be the to-go way in such cases (allow the entire lint, throw some allow attrs into the relevant places..?)

@compiler-errors
Copy link
Member

compiler-errors commented Dec 30, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@matthiaskrgr: Do you mind copying all those questions over to the zulip thread so that we can discuss them in detail?

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jan 5, 2024
@apiraino
Copy link
Contributor

@rustbot label -final-comment-period +major-change-accepted

@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Jan 12, 2024
@nnethercote
Copy link

This has been closed. What's the status?

  • Is clippy is working reliably on rustc?
  • Does it get invoked automatically as part of x.py test or something else?
  • Does it run on CI?

@Noratrieb
Copy link
Member Author

It has been closed because the proposal has been accepted. @Kobzol is working on implementing it.

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jan 25, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 11, 2024
Rollup merge of rust-lang#119449 - Nilstrieb:library-clippy, r=cuviper

Fix `clippy::correctness` in the library

needs rust-lang/backtrace-rs#579 to be complete

for rust-lang/compiler-team#709
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2024
…crum

Gate PR CI on clippy correctness lints

Implements part of rust-lang/compiler-team#709.

Note that `x.py clippy compiler` also checks the standard library, because it needs to be checked before the compiler. This happens even with `x.py clippy --stage 0`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2024
…crum

Gate PR CI on clippy correctness lints

Implements part of rust-lang/compiler-team#709.

Note that `x.py clippy compiler` also checks the standard library, because it needs to be checked before the compiler. This happens even with `x.py clippy --stage 0`.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2024
Rollup merge of rust-lang#119451 - Kobzol:ci-pr-clippy, r=Mark-Simulacrum

Gate PR CI on clippy correctness lints

Implements part of rust-lang/compiler-team#709.

Note that `x.py clippy compiler` also checks the standard library, because it needs to be checked before the compiler. This happens even with `x.py clippy --stage 0`.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Feb 13, 2024
Gate PR CI on clippy correctness lints

Implements part of rust-lang/compiler-team#709.

Note that `x.py clippy compiler` also checks the standard library, because it needs to be checked before the compiler. This happens even with `x.py clippy --stage 0`.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

6 participants