Skip to content

Conversation

@onur-ozkan
Copy link
Contributor

Instead of resolving rustfmt path from RUSTFMT or PATH envs, use the one located in the same directory as cargo-fmt. So that cargo-fmt uses the expected version of rustfmt to avoid accidental use of unrelated versions.

Fixes #137666

Instead of resolving `rustfmt` path from RUSTFMT or PATH envs, use the one
located in the same directory as `cargo-fmt`. So that `cargo-fmt` uses the
expected version of `rustfmt` to avoid accidental use of unrelated versions.

Signed-off-by: onur-ozkan <[email protected]>
@rustbot
Copy link
Collaborator

rustbot commented May 16, 2025

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

@rustbot
Copy link
Collaborator

rustbot commented May 16, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 16, 2025
@Kobzol
Copy link
Member

Kobzol commented May 16, 2025

Now that I think about it, I did some local testing again, and I think that the current behavior sort of... makes sense? cargo-fmt is from the nightly toolchain, but it seems like its intended behavior indeed should be to resolve rustfmt from either RUSTFMT or PATH, even though that rustfmt might actually be from a different toolchain.

And when it is invoked through cargo +nightly fmt, everything works as expected (it invokes the nightly rustfmt). So I think that my original issue was actually a red herring and it's fine. But I'll let Mark take a look.

@onur-ozkan
Copy link
Contributor Author

FWIW clippy also follows this approach.

@Mark-Simulacrum
Copy link
Member

Yeah, current behavior seems probably right here? Regardless, this should go through the rustfmt repo, not rust-lang/rust.

@onur-ozkan
Copy link
Contributor Author

Sure, the reason I opened the PR here was that I saw more recent commits to rustfmt in this repo.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo-fmt reports weird version on nightly

4 participants