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

Improve the rustc-side clippy development experience #76495

Open
1 of 4 tasks
Aaron1011 opened this issue Sep 8, 2020 · 14 comments
Open
1 of 4 tasks

Improve the rustc-side clippy development experience #76495

Aaron1011 opened this issue Sep 8, 2020 · 14 comments
Labels
A-clippy Area: Clippy A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@Aaron1011
Copy link
Member

Aaron1011 commented Sep 8, 2020

When working on #75573, I ended up needing to modify Clippy (both a lint implementation and some UI tests). This process left a lot to be desired, and could be a significant roadblock to new contributors. I came up with some ideas for improving the process:

  • Run Clippy tests on the PR builder (if we have the CI budget). My PR was initially approved, then unapproved due to a (correct) suspicion that Clippy UI tests would be broken. However, this could easily be missed on other PRs, leading to wasted merge queue time and failed rollups. By running these tests on the PR builder, we could catch Clippy changes prior to PR approval.
  • Allow running Clippy tests in-tree from stage1. Currently, running ./x.py test src/tools/clippy requires a full compiler bootstrap (e.g. building a stage2 compiler). This takes a significant amount of time, and interacts badly with incremental compilation. For contributors with lower-end machines, this may make the contribution process incredibly frustrating. Attempting to build Clippy against a stage1 compiler (which requires running ./x.py test src/tools/clippy --stage 0 for some reason) works, but the tests fail with a confusing error about LLVM being missing.
  • Integrate Clippy UI tests with ./x.py test --bless. Currently, blessing Clippy UI tests requires manually running scripts from inside src/tools/clippy. It would be nice if ./x.py test --bless worked on all UI tests, allowing Clippy to be largely treated as 'just another directory'.
  • Document the interaction between -D warnings and Clippy lints. It seems as though denying a built-in lint with -D warnings prevents Clippy lints from being run. Since Clippy UI tests are run with -D warnings, adding a new builtin Rust lint can end up preventing Clippy UI tests from testing Clippy lints. Ideally, we would allow both sets of lints to run - if this is not possible, we should document the workaround (adding #![allow(problematic_rustc_lint)] to the affected Clippy UI tests).
@Aaron1011 Aaron1011 added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Sep 8, 2020
@Mark-Simulacrum Mark-Simulacrum added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. and removed T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. labels Sep 8, 2020
@jyn514
Copy link
Member

jyn514 commented Jan 1, 2021

Note that at some point test --stage 0 src/tools/clippy broke: #78717

@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2021

Last time I tried blessing clippy tests, that did not work, so I ended up manually adjusting stderr files. Maybe that's because I didn't try stage 2. Note that ./x.py test --bless (which is listed as 'working' in the list above) nowadays runs stage 1, so the OP text likely needs adjustments.

@rust-lang/clippy this issue has remained open for more than half a year. The clippy-subtree-merger put the burden of keeping clippy working onto all rustc contributors, so having sub-par tooling like this is now a much bigger problem than it was back when only clippy devs had to use that tooling.

@RalfJung RalfJung added the A-clippy Area: Clippy label Jun 2, 2021
@jyn514
Copy link
Member

jyn514 commented Jun 2, 2021

Last time I tried blessing clippy tests, that did not work, so I ended up manually adjusting stderr files. Maybe that's because I didn't try stage 2.

What was the error? That should work, if not it's a bug.

@flip1995
Copy link
Member

flip1995 commented Jun 2, 2021

./x.py test --bless src/tools/clippy works. ./x.py test --bless does not run the Clippy tests, so it also doesn't update them.

@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2021

I think ./x.py test --bless src/tools/clippy is what I tried and got tons of strange linking errors. I figured this was expected so I didn't report a bug, sorry.

@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2021

Ah, turns out what I actually tried is ./x.py test src/tools/clippy --bless --stage 0, since I did not want to wait for two full rustc builds. (Stage 1 clippy uses the stage 1 rustc libs, so those have to be built first.)

@flip1995
Copy link
Member

flip1995 commented Jun 2, 2021

Run Clippy tests on the PR builder (if we have the CI budget)

This is already done, if something in the src/tools/clippy is touched by the PR. IIRC the decision was made that running it on every PR is not necessary, since most PRs won't cause problems with it.

Allow running Clippy tests in-tree from stage1

That would be great. Unfortunately most Clippy folks don't really know how the bootstrapping works exactly and therefore fixing this would be really hard for us to do.

Document the interaction between -D warnings and Clippy lints.

Changes to rustc should not change Clippy tests, except for line number updates. The only exception I can think of is if a lint is being uplifted from Clippy to rustc. Fixing the issue where a new rust error/lint suppresses Clippy lints should be fixed by either adding #[allow(problematic_lint)] or by fixing the issue in the test, if it doesn't change the semantics of the test.

Ah, turns out what I actually tried is ./x.py test src/tools/clippy --bless --stage 0

Yes, Clippy on --stage 0 doesn't work (yet). I don't know how to fix that.

@jyn514
Copy link
Member

jyn514 commented Jun 2, 2021

That would be great. Unfortunately most Clippy folks don't really know how the bootstrapping works exactly and therefore fixing this would be really hard for us to do.

The error that @RalfJung linked is not a bootstrapping issue. Clippy's fork of compile test needs to be fixed not to reuse the same target directory for tests as for building clippy itself.

@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2021

Allow running Clippy tests in-tree from stage1

That would be great. Unfortunately most Clippy folks don't really know how the bootstrapping works exactly and therefore fixing this would be really hard for us to do.

Actually that works, since stage 1 is what x.py test uses by default -- right?
Stage 0 doesn't work. That might be #78778, or it might be a separate problem.

@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2021

Clippy's fork of compile test needs to be fixed not to reuse the same target directory for tests as for building clippy itself.

Clippy uses the same fork that Miri uses, and Miri doesn't have this particular problem I think (at least, Miri worked on stage 0 before #78778 got introduced). However, it looks like clippy actually supports ui tests that depend on 3rd-party crates, so that logic might be wrong -- Miri doesn't have anything like this.

@flip1995
Copy link
Member

flip1995 commented Jun 2, 2021

Yes using external crates in compiletest causes some problems also in Clippy. So this is most likely the reason, why it also causes problems in the Rust repo.

@camsteffen
Copy link
Contributor

I just opened rust-lang/rust-clippy#7343 to explain the problem from Clippy's side. I'd appreciate feedback from people with more rustc knowledge.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 7, 2022
…k-Simulacrum

Don't constantly rebuild clippy on `x test src/tools/clippy`.

This happened because the `SYSROOT` variable was set for `x test`, but not `x build`.
Set it consistently for both to avoid unnecessary rebuilds.

This is a very small step towards rust-lang#76495.
@jyn514
Copy link
Member

jyn514 commented May 20, 2023

I have a prototype for running clippy tests without having to build rustc twice in #96798, which is currently blocked on changing the stage numbering for tools: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Stage.20numbering.20for.20tools

See #96798 (comment) for more details.

@jyn514 jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself and removed T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels May 20, 2023
@jyn514 jyn514 mentioned this issue Nov 5, 2023
@jyn514
Copy link
Member

jyn514 commented Nov 16, 2023

  • Document the interaction between -D warnings and Clippy lints. It seems as though denying a built-in lint with -D warnings prevents Clippy lints from being run. Since Clippy UI tests are run with -D warnings, adding a new builtin Rust lint can end up preventing Clippy UI tests from testing Clippy lints. Ideally, we would allow both sets of lints to run - if this is not possible, we should document the workaround (adding #![allow(problematic_rustc_lint)] to the affected Clippy UI tests).

this is likely fixed since #87337, although i haven't tested

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
x clippy

thanks to `@asquared31415` `@albertlarsan68` for all their help, most of this pr is their work

note that this also adds x clippy --stage 0 -Awarnings to x86_64-gnu-llvm-15 to make sure it stays working; that won't gate on any clippy warnings, just enforce that clippy doesn't give a hard error. we can't add --stage 1 until clippy fixes its debug assertions not to panic.

note that `x clippy --stage 1` currently breaks when combined with download-rustc.

unlike the previous prs, this doesn't require changes to clippy (it works by using RUSTC_WRAPPER instead), and supports stage 0

read this commit-by-commit

closes rust-lang#107628; see also rust-lang#106394, rust-lang#97443. fixes rust-lang#95988. helps with rust-lang#76495.

r? bootstrap
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 16, 2023
x clippy

thanks to `@asquared31415` `@albertlarsan68` for all their help, most of this pr is their work

note that this also adds x clippy --stage 0 -Awarnings to x86_64-gnu-llvm-15 to make sure it stays working; that won't gate on any clippy warnings, just enforce that clippy doesn't give a hard error. we can't add --stage 1 until clippy fixes its debug assertions not to panic.

note that `x clippy --stage 1` currently breaks when combined with download-rustc.

unlike the previous prs, this doesn't require changes to clippy (it works by using RUSTC_WRAPPER instead), and supports stage 0

read this commit-by-commit

closes rust-lang#107628; see also rust-lang#106394, rust-lang#97443. fixes rust-lang#95988. helps with rust-lang#76495.

r? bootstrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

6 participants