From d51640d13736e1dbcfe6a4c7ca8e07592f8cbf62 Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Tue, 12 Feb 2019 05:41:54 -0500 Subject: [PATCH 1/2] Tell user if override is set in the environment after `rustup default` --- src/rustup-cli/rustup_mode.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index 960d32940e..5a467b3e79 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -591,6 +591,12 @@ fn default_(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> { println!(); common::show_channel_update(cfg, toolchain.name(), Ok(status))?; } + + let cwd = utils::current_dir()?; + if let Some((toolchain, reason)) = cfg.find_override(&cwd)? { + info!("using override set by current environment"); + info!("{} ({})", toolchain.name(), reason); + } } else { let installed_toolchains = cfg.list_toolchains()?; if installed_toolchains.len() > 0 { From a5dd425af61b286105ede41c93f289e855446c42 Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Mon, 18 Feb 2019 16:00:04 -0500 Subject: [PATCH 2/2] Add default_override test --- src/rustup-cli/rustup_mode.rs | 7 +++++-- tests/cli-rustup.rs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index 5a467b3e79..3493816e16 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -594,8 +594,11 @@ fn default_(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> { let cwd = utils::current_dir()?; if let Some((toolchain, reason)) = cfg.find_override(&cwd)? { - info!("using override set by current environment"); - info!("{} ({})", toolchain.name(), reason); + info!( + "note that the toolchain '{}' is currently in use ({})", + toolchain.name(), + reason + ); } } else { let installed_toolchains = cfg.list_toolchains()?; diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index 0ad0c884f2..015bb4946e 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -249,6 +249,24 @@ info: default toolchain set to 'nightly-{0}' }); } +#[test] +fn default_override() { + setup(&|config| { + expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]); + expect_ok(config, &["rustup", "default", "stable"]); + expect_ok(config, &["rustup", "override", "set", "nightly"]); + expect_stderr_ok( + config, + &["rustup", "default", "stable"], + for_host!( + r"info: using existing install for 'stable-{0}' +info: default toolchain set to 'stable-{0}' +info: note that the toolchain 'nightly-{0}' is currently in use (directory override for" + ), + ); + }); +} + #[test] fn rustup_xz() { setup(&|config| {