Skip to content

Commit bfdac61

Browse files
committed
tools: use -Zinstall-upgrade instead of a crate when unstable is enabled
1 parent 027d398 commit bfdac61

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
instead of being cached during the workspace's initialization. It's possible
2020
to use the `WorkspaceBuilder::fetch_registry_index_during_builds` method to
2121
revert to the old behavior.
22+
- When the `unstable` feature flag is enabled rustwide will use Cargo's
23+
`-Zinstall-upgrade` to update its tools instead of the
24+
`cargo-install-upgrade` crate. This will speed up the workspace
25+
initialization.
2226

2327
## [0.2.0] - 2019-09-06
2428

src/tools/binary_crates.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::cmd::{Binary, Command, Runnable};
2-
use crate::tools::{Tool, CARGO_INSTALL_UPDATE};
2+
use crate::tools::Tool;
33
use crate::{Toolchain, Workspace};
44
use failure::Error;
55
use std::path::PathBuf;
@@ -58,11 +58,25 @@ impl Tool for BinaryCrate {
5858
Ok(())
5959
}
6060

61+
#[cfg(not(feature = "unstable"))]
6162
fn update(&self, workspace: &Workspace, _fast_install: bool) -> Result<(), Error> {
62-
Command::new(workspace, &CARGO_INSTALL_UPDATE)
63+
Command::new(workspace, &crate::tools::CARGO_INSTALL_UPDATE)
6364
.args(&[self.crate_name])
6465
.timeout(None)
6566
.run()?;
6667
Ok(())
6768
}
69+
70+
#[cfg(feature = "unstable")]
71+
fn update(&self, workspace: &Workspace, fast_install: bool) -> Result<(), Error> {
72+
let mut cmd = Command::new(workspace, &Toolchain::MAIN.cargo())
73+
.args(&["-Zinstall-upgrade", "install", self.crate_name])
74+
.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
75+
.timeout(None);
76+
if fast_install {
77+
cmd = cmd.args(&["--debug"]);
78+
}
79+
cmd.run()?;
80+
Ok(())
81+
}
6882
}

src/tools/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::path::PathBuf;
1111

1212
pub(crate) static RUSTUP: Rustup = Rustup;
1313

14+
#[cfg(not(feature = "unstable"))]
1415
pub(crate) static CARGO_INSTALL_UPDATE: BinaryCrate = BinaryCrate {
1516
crate_name: "cargo-update",
1617
binary: "cargo-install-update",
@@ -31,6 +32,7 @@ pub(crate) static GIT_CREDENTIAL_NULL: BinaryCrate = BinaryCrate {
3132

3233
static INSTALLABLE_TOOLS: &[&dyn Tool] = &[
3334
&RUSTUP,
35+
#[cfg(not(feature = "unstable"))]
3436
&CARGO_INSTALL_UPDATE,
3537
&RUSTUP_TOOLCHAIN_INSTALL_MASTER,
3638
&GIT_CREDENTIAL_NULL,

0 commit comments

Comments
 (0)