Skip to content

Fix ./x fix compiler and allow --allow-dirty - #160417

Open
Zalathar wants to merge 3 commits into
rust-lang:mainfrom
Zalathar:x-fix
Open

Fix ./x fix compiler and allow --allow-dirty#160417
Zalathar wants to merge 3 commits into
rust-lang:mainfrom
Zalathar:x-fix

Conversation

@Zalathar

@Zalathar Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member

This PR makes ./x fix compiler actually run cargo fix on compiler crates, instead of accidentally running cargo check.

Also, we now forward --allow-dirty from bootstrap to cargo, making ./x fix more convenient in general.

@rustbot

rustbot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 3, 2026
@rustbot

rustbot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

@jieyouxu jieyouxu assigned jieyouxu and unassigned Mark-Simulacrum Aug 3, 2026
@rust-log-analyzer

This comment has been minimized.

@Kobzol Kobzol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/bootstrap/src/core/config/flags.rs
);

std_cargo(builder, target, &mut cargo, &self.crates);
if matches!(builder.config.cmd, Subcommand::Fix) {

@Zalathar Zalathar Aug 3, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would have had to update the match to Subcommand::Fix { .. }, but I instead changed it to check builder.kind == Kind::Fix to bring it in line with other uses of builder.kind in this function.

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu assigned Kobzol and unassigned jieyouxu Aug 3, 2026
@Zalathar

Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

The builder.kind assertions are not essential to this PR, so I might just remove them.

But it's a bit alarming to see this assertion fail for unclear reasons. Ah, bootstrap.

@Zalathar

Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

Though actually ... if this clippy::Rustc code is somehow relying on check::Rustc code being hardcoded to Kind::Check, then that could be a problem for this PR. 😕

The old code was accidentally replacing the `fix` subcommand with `check`.
This was already possible via `./x fix -- --allow-dirty`, but forwarding the
argument from bootstrap is more user-friendly.
@Zalathar

Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

For now, let's remove the assertions and see if anything else breaks.

@Kobzol

Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member

Ok yeah the assert is actually a good idea. We want to run the compiler in check mode when you run clippy on rustc_private tools, to generate the .rmeta files. I think that the right solution is moving the kind to check::Rustc, to that even if you have a Clippy builder.kind, you can still run a Rustc check.

@Zalathar

Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

Hmm yeah, when PrepareRustcRmetaSysroot delegates to check::Rustc, it specifically wants to do cargo check, not whatever the ambient subcommand happens to be.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustc_graphviz v0.0.0 (/checkout/compiler/rustc_graphviz)
warning: consider choosing a more descriptive name
  --> compiler/rustc_hashes/src/lib.rs:57:31
   |
57 |     fn from(StableHasherHash([_0, _]): Self::Hash) -> Self {
   |                               ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
   = note: `#[warn(clippy::just_underscores_and_digits)]` on by default

warning: consider choosing a more descriptive name
   --> compiler/rustc_hashes/src/lib.rs:116:31
    |
116 |     fn from(StableHasherHash([_0, _1]): Self::Hash) -> Self {
    |                               ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits

warning: consider choosing a more descriptive name
   --> compiler/rustc_hashes/src/lib.rs:116:35
    |
116 |     fn from(StableHasherHash([_0, _1]): Self::Hash) -> Self {
    |                                   ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits

[RUSTC-TIMING] rustc_hashes test:false 0.122
error: `rustc_hashes` (lib) generated 3 warnings
error: warnings are denied by `build.warnings` configuration
warning: build failed, waiting for other jobs to finish...
warning: this returns a `Result<_, ()>`
   --> compiler/rustc_graphviz/src/lib.rs:396:5
    |
396 |     pub fn new<Name: Into<Cow<'a, str>>>(name: Name) -> Result<Id<'a>, ()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a custom `Error` type instead
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err
    = note: `#[warn(clippy::result_unit_err)]` on by default

warning: redundant reference in `write!` argument
   --> compiler/rustc_graphviz/src/lib.rs:631:40
    |
631 |             write!(text, "[shape={}]", &s.to_dot_string()).unwrap();
    |                                        ^^^^^^^^^^^^^^^^^^ help: remove the redundant `&`: `s.to_dot_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_borrows_in_formatting
    = note: `#[warn(clippy::useless_borrows_in_formatting)]` on by default

[RUSTC-TIMING] rustc_arena test:false 0.180
[RUSTC-TIMING] rustc_graphviz test:false 0.179
error: `rustc_graphviz` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p rustc_graphviz -- ` to apply 1 suggestion)
error: warnings are denied by `build.warnings` configuration
warning: unnecessary closure used with `bool::then`
   --> compiler/rustc_thread_pool/src/broadcast/mod.rs:126:28
    |
126 |         .and_then(|worker| (registry.id() == worker.registry.id()).then(|| worker))
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
    = note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
help: use `then_some` instead
    |
126 -         .and_then(|worker| (registry.id() == worker.registry.id()).then(|| worker))
126 +         .and_then(|worker| (registry.id() == worker.registry.id()).then_some(worker))
    |

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> compiler/rustc_thread_pool/src/registry.rs:903:79
    |
903 |                     self.registry.sleep.no_work_found(&mut idle_state, latch, &self, true)
    |                                                                               ^^^^^ help: change this to: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> compiler/rustc_thread_pool/src/registry.rs:927:71
    |
927 |             self.registry.sleep.no_work_found(&mut idle_state, latch, &self, false);
    |                                                                       ^^^^^ help: change this to: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

[RUSTC-TIMING] rustc_thread_pool test:false 0.731
error: `rustc_thread_pool` (lib) generated 3 warnings (run `cargo clippy --fix --lib -p rustc_thread_pool -- ` to apply 3 suggestions)

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants