@@ -92,17 +92,17 @@ impl<T: Into<String>> From<T> for OverrideFile {
9292 }
9393}
9494
95- // Represents the reason why the active toolchain is active .
95+ // Represents the source that determined the current active toolchain.
9696#[ derive( Debug ) ]
97- pub ( crate ) enum ActiveReason {
97+ pub ( crate ) enum ActiveSource {
9898 Default ,
9999 Environment ,
100100 CommandLine ,
101101 OverrideDB ( PathBuf ) ,
102102 ToolchainFile ( PathBuf ) ,
103103}
104104
105- impl Display for ActiveReason {
105+ impl Display for ActiveSource {
106106 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> std:: result:: Result < ( ) , fmt:: Error > {
107107 match self {
108108 Self :: Default => write ! ( f, "it's the default toolchain" ) ,
@@ -505,7 +505,7 @@ impl<'a> Cfg<'a> {
505505 pub ( crate ) async fn maybe_ensure_active_toolchain (
506506 & self ,
507507 force_ensure : Option < bool > ,
508- ) -> Result < Option < ( LocalToolchainName , ActiveReason ) > > {
508+ ) -> Result < Option < ( LocalToolchainName , ActiveSource ) > > {
509509 let should_ensure = if let Some ( force) = force_ensure {
510510 force
511511 } else {
@@ -524,39 +524,39 @@ impl<'a> Cfg<'a> {
524524 }
525525 }
526526
527- pub ( crate ) fn active_toolchain ( & self ) -> Result < Option < ( LocalToolchainName , ActiveReason ) > > {
527+ pub ( crate ) fn active_toolchain ( & self ) -> Result < Option < ( LocalToolchainName , ActiveSource ) > > {
528528 Ok (
529- if let Some ( ( override_config, reason ) ) = self . find_override_config ( ) ? {
530- Some ( ( override_config. into_local_toolchain_name ( ) , reason ) )
529+ if let Some ( ( override_config, source ) ) = self . find_override_config ( ) ? {
530+ Some ( ( override_config. into_local_toolchain_name ( ) , source ) )
531531 } else {
532532 self . get_default ( ) ?
533- . map ( |x| ( x. into ( ) , ActiveReason :: Default ) )
533+ . map ( |x| ( x. into ( ) , ActiveSource :: Default ) )
534534 } ,
535535 )
536536 }
537537
538- fn find_override_config ( & self ) -> Result < Option < ( OverrideCfg , ActiveReason ) > > {
539- let override_config: Option < ( OverrideCfg , ActiveReason ) > =
538+ fn find_override_config ( & self ) -> Result < Option < ( OverrideCfg , ActiveSource ) > > {
539+ let override_config: Option < ( OverrideCfg , ActiveSource ) > =
540540 // First check +toolchain override from the command line
541541 if let Some ( name) = & self . toolchain_override {
542542 let override_config = name. resolve ( & self . get_default_host_triple ( ) ?) ?. into ( ) ;
543- Some ( ( override_config, ActiveReason :: CommandLine ) )
543+ Some ( ( override_config, ActiveSource :: CommandLine ) )
544544 }
545545 // Then check the RUSTUP_TOOLCHAIN environment variable
546546 else if let Some ( name) = & self . env_override {
547547 // Because path based toolchain files exist, this has to support
548548 // custom, distributable, and absolute path toolchains otherwise
549549 // rustup's export of a RUSTUP_TOOLCHAIN when running a process will
550550 // error when a nested rustup invocation occurs
551- Some ( ( name. clone ( ) . into ( ) , ActiveReason :: Environment ) )
551+ Some ( ( name. clone ( ) . into ( ) , ActiveSource :: Environment ) )
552552 }
553553 // Then walk up the directory tree from 'path' looking for either the
554554 // directory in the override database, or a `rust-toolchain{.toml}` file,
555555 // in that order.
556- else if let Some ( ( override_cfg, active_reason ) ) = self . settings_file . with ( |s| {
556+ else if let Some ( ( override_cfg, active_source ) ) = self . settings_file . with ( |s| {
557557 self . find_override_from_dir_walk ( & self . current_dir , s)
558558 } ) ? {
559- Some ( ( override_cfg, active_reason ) )
559+ Some ( ( override_cfg, active_source ) )
560560 }
561561 // Otherwise, there is no override.
562562 else {
@@ -570,13 +570,13 @@ impl<'a> Cfg<'a> {
570570 & self ,
571571 dir : & Path ,
572572 settings : & Settings ,
573- ) -> Result < Option < ( OverrideCfg , ActiveReason ) > > {
573+ ) -> Result < Option < ( OverrideCfg , ActiveSource ) > > {
574574 let mut dir = Some ( dir) ;
575575
576576 while let Some ( d) = dir {
577577 // First check the override database
578578 if let Some ( name) = settings. dir_override ( d) {
579- let reason = ActiveReason :: OverrideDB ( d. to_owned ( ) ) ;
579+ let source = ActiveSource :: OverrideDB ( d. to_owned ( ) ) ;
580580 // Note that `rustup override set` fully resolves it's input
581581 // before writing to settings.toml, so resolving here may not
582582 // be strictly necessary (could instead model as ToolchainName).
@@ -586,7 +586,7 @@ impl<'a> Cfg<'a> {
586586 let toolchain_name = ResolvableToolchainName :: try_from ( name) ?
587587 . resolve ( & get_default_host_triple ( settings, self . process ) ) ?;
588588 let override_cfg = toolchain_name. into ( ) ;
589- return Ok ( Some ( ( override_cfg, reason ) ) ) ;
589+ return Ok ( Some ( ( override_cfg, source ) ) ) ;
590590 }
591591
592592 // Then look for 'rust-toolchain' or 'rust-toolchain.toml'
@@ -670,9 +670,9 @@ impl<'a> Cfg<'a> {
670670 }
671671 }
672672
673- let reason = ActiveReason :: ToolchainFile ( toolchain_file) ;
673+ let source = ActiveSource :: ToolchainFile ( toolchain_file) ;
674674 let override_cfg = OverrideCfg :: from_file ( self , override_file) ?;
675- return Ok ( Some ( ( override_cfg, reason ) ) ) ;
675+ return Ok ( Some ( ( override_cfg, source ) ) ) ;
676676 }
677677
678678 dir = d. parent ( ) ;
@@ -766,8 +766,8 @@ impl<'a> Cfg<'a> {
766766 & self ,
767767 force_non_host : bool ,
768768 verbose : bool ,
769- ) -> Result < ( LocalToolchainName , ActiveReason ) > {
770- if let Some ( ( override_config, reason ) ) = self . find_override_config ( ) ? {
769+ ) -> Result < ( LocalToolchainName , ActiveSource ) > {
770+ if let Some ( ( override_config, source ) ) = self . find_override_config ( ) ? {
771771 let toolchain = override_config. clone ( ) . into_local_toolchain_name ( ) ;
772772 if let OverrideCfg :: Official {
773773 toolchain,
@@ -786,18 +786,18 @@ impl<'a> Cfg<'a> {
786786 )
787787 . await ?;
788788 } else {
789- Toolchain :: with_reason ( self , toolchain. clone ( ) , & reason ) ?;
789+ Toolchain :: with_source ( self , toolchain. clone ( ) , & source ) ?;
790790 }
791- Ok ( ( toolchain, reason ) )
791+ Ok ( ( toolchain, source ) )
792792 } else if let Some ( toolchain) = self . get_default ( ) ? {
793- let reason = ActiveReason :: Default ;
793+ let source = ActiveSource :: Default ;
794794 if let ToolchainName :: Official ( desc) = & toolchain {
795795 self . ensure_installed ( desc, vec ! [ ] , vec ! [ ] , None , force_non_host, verbose)
796796 . await ?;
797797 } else {
798- Toolchain :: with_reason ( self , toolchain. clone ( ) . into ( ) , & reason ) ?;
798+ Toolchain :: with_source ( self , toolchain. clone ( ) . into ( ) , & source ) ?;
799799 }
800- Ok ( ( toolchain. into ( ) , reason ) )
800+ Ok ( ( toolchain. into ( ) , source ) )
801801 } else {
802802 Err ( no_toolchain_error ( self . process ) )
803803 }
0 commit comments