You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 9, 2023. It is now read-only.
In dtolnay/cargo-expand#39 I need to look for any rustfmt that may be installed on the system.
Currently what happens is that if the user has rustup component add rustfmt --toolchain stable but is running cargo +nightly expand, then somehow Cargo sets up the subcommand environment such that simply running Command::new("rustfmt") will end up running a shim that only tells you there is no rustfmt installed for the nightly toolchain. The thing is, I don't care whether the rustfmt I run is from the same toolchain as the cargo-expand binary. I would happily run the stable toolchain's rustfmt from the nightly toolchain's cargo-expand if I knew the path to the right binary.
use std::process::Command;let which_rustfmt = find_installed_component("rustfmt");match which_rustfmt {None => {/* there is no rustfmt on any toolchain */}Some(rustfmt) => {Command::new(rustfmt).args(...).spawn();}}
This will be relevant to other Cargo subcommands too, so the implementation should go in a crate rather than directly in cargo-expand.