@@ -583,21 +583,9 @@ pub async fn main(
583583 }
584584 Err ( err) if err. kind ( ) == DisplayVersion => {
585585 write ! ( process. stdout( ) . lock( ) , "{err}" ) ?;
586- info ! ( "This is the version for the rustup toolchain manager, not the rustc compiler." ) ;
587- 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 ( ) ?;
593- match cfg. active_rustc_version ( ) . await {
594- Ok ( Some ( version) ) => info ! ( "The currently active `rustc` version is `{version}`" ) ,
595- Ok ( None ) => info ! ( "No `rustc` is currently active" ) ,
596- Err ( err) => trace ! ( "Failed to display the current `rustc` version: {err}" ) ,
597- }
586+ display_version ( current_dir, process) . await ?;
598587 return Ok ( ExitCode ( 0 ) ) ;
599588 }
600-
601589 Err ( err) => {
602590 if [
603591 InvalidSubcommand ,
@@ -1891,3 +1879,21 @@ fn output_completion_script(
18911879
18921880 Ok ( ExitCode ( 0 ) )
18931881}
1882+
1883+ async fn display_version ( current_dir : PathBuf , process : & Process ) -> Result < ( ) > {
1884+ info ! ( "This is the version for the rustup toolchain manager, not the rustc compiler." ) ;
1885+ let mut cfg = Cfg :: from_env ( current_dir, true , process) ?;
1886+ cfg. toolchain_override = cfg
1887+ . process
1888+ . args ( )
1889+ . find_map ( |arg| arg. strip_prefix ( '+' ) . map ( ResolvableToolchainName :: try_from) )
1890+ . transpose ( ) ?;
1891+
1892+ match cfg. active_rustc_version ( ) . await {
1893+ Ok ( Some ( version) ) => info ! ( "The currently active `rustc` version is `{version}`" ) ,
1894+ Ok ( None ) => info ! ( "No `rustc` is currently active" ) ,
1895+ Err ( err) => trace ! ( "Failed to display the current `rustc` version: {err}" ) ,
1896+ }
1897+
1898+ Ok ( ( ) )
1899+ }
0 commit comments