Skip to content

Commit 5d0b5ac

Browse files
committed
config: extract setting of toolchain override in rustup help mode
1 parent cbded6e commit 5d0b5ac

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/cli/rustup_mode.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@ pub async fn main(
585585
write!(process.stdout().lock(), "{err}")?;
586586
info!("This is the version for the rustup toolchain manager, not the rustc compiler.");
587587
let mut cfg = Cfg::from_env(current_dir, true, process)?;
588+
cfg.toolchain_override = cfg
589+
.process
590+
.args()
591+
.find_map(|arg| arg.strip_prefix('+').map(ResolvableToolchainName::try_from))
592+
.transpose()?;
588593
match cfg.active_rustc_version().await {
589594
Ok(Some(version)) => info!("The currently active `rustc` version is `{version}`"),
590595
Ok(None) => info!("No `rustc` is currently active"),

src/config.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,6 @@ impl<'a> Cfg<'a> {
700700

701701
#[tracing::instrument(level = "trace")]
702702
pub(crate) async fn active_rustc_version(&mut self) -> Result<Option<String>> {
703-
if let Some(t) = self.process.args().find(|x| x.starts_with('+')) {
704-
trace!("Fetching rustc version from toolchain `{}`", t);
705-
self.toolchain_override = Some(ResolvableToolchainName::try_from(&t[1..])?);
706-
}
707-
708703
let Some((name, _)) = self.maybe_ensure_active_toolchain(None).await? else {
709704
return Ok(None);
710705
};

0 commit comments

Comments
 (0)