Skip to content

Commit d708b11

Browse files
committed
--version: Show current toolchain rustc version
1 parent 7f157dc commit d708b11

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/cli/rustup_mode.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ pub fn main() -> Result<utils::ExitCode> {
7575
info!("This is the version for the rustup toolchain manager, not the rustc compiler.");
7676

7777
fn rustc_version() -> std::result::Result<String, Box<dyn std::error::Error>> {
78-
let cmd = Command::new("rustc").arg("--version").output()?;
79-
if cmd.status.success() {
80-
Ok(String::from_utf8_lossy(&cmd.stdout).trim().into())
81-
} else {
82-
Err(String::from_utf8_lossy(&cmd.stderr).into())
83-
}
78+
let cfg = &mut common::set_globals(false, true)?;
79+
let cwd = std::env::current_dir()?;
80+
let toolchain = cfg.find_or_install_override_toolchain_or_default(&cwd)?.0;
81+
Ok(toolchain.rustc_version())
8482
}
8583

8684
match rustc_version() {

0 commit comments

Comments
 (0)