Closed
Description
Lines 1095 to 1106 in c7ce69f
The proper fix is to check if we're going through the cargo run
entrypoint instead of x.py, and if so, download rustfmt from the nightly toolchain listed in src/stage0.json
:
Lines 8 to 11 in c7ce69f
Ideally we would eventually be able to move this into rustup, but that requires not only for rustup to add and release this feature, but also for all contributors to start using it. It shouldn't be too much extra work for bootstrap to do it itself in the meantime.
Activity
jyn514 commentedon Mar 20, 2022
@rustbot label: +A-rustbuild +C-enhancement
bjorn3 commentedon Mar 20, 2022
You can use
rustup run <toolchain> rustfmt
. Or set theRUSTUP_TOOLCHAIN
env var.jyn514 commentedon Mar 20, 2022
Ah, interesting idea. Right now
rustup component add --toolchain nightly-2022-02-23 rustfmt
gives an error if the toolchain isn't already installed, but @kinnison suggests that rustup could support--profile none
which would avoid installing an unused toolchain.install --profile empty
rust-lang/rustup#2970jyn514 commentedon Mar 20, 2022
I do wonder to what extent we can depend on rustup vs. supporting a pre-installed host toolchain. @cuviper is probably not running
x.py fmt --check
a whole lot while building from source, but it does make me slightly uncomfortable to have commands we know will fail if you usecargo run
without rustup.cc @Mark-Simulacrum
Mark-Simulacrum commentedon Mar 20, 2022
I would prefer to avoid a dependency on rustup specifically being available for any of our commands; I suspect that manually downloading the tarball for rustfmt would be better.
In general my operating assumption is that we can reasonably expect rustup for "get me a beta toolchain", but should not look for anything more than that. (And of course, all that really means is that the bootstrap toolchain must be provided somehow - perhaps from the previous version in a distro, for example).
cuviper commentedon Mar 20, 2022
You're right that I don't need
fmt
for distro builds -- and note that it currently isn't supported at all for stable/beta branches:jyn514 commentedon Mar 24, 2022
Only half-related to this issue, but I would love for
cargo fmt
to work out of the box. It looks likecargo fmt -- --unstable-options --skip-children
already works as long as you have the right toolchain installed - I guess we don't use that so we can use @the8472's optimizations to make rustfmt faster? Could we possibly move those to cargo instead of special-casing x.py?Mark-Simulacrum commentedon Mar 24, 2022
My recollection is that we enable unstable rustfmt features in rustfmt.toml and such that mean we couldn't do cargo +beta fmt anyway (and RUSTC_BOOTSTRAP isn't supported by rustfmt).
jyn514 commentedon Mar 24, 2022
Ah right, people would still have to use two separate toolchains for
cargo build
vscargo fmt
(unless we get rustup to support this in rust-toolchain.toml somehow). Probably not worth investing time into, then.Rollup merge of rust-lang#97507 - jyn514:download-rustfmt, r=Mark-Sim…