@@ -87,17 +87,17 @@ impl<T: Into<String>> From<T> for OverrideFile {
8787 }
8888}
8989
90- // Represents the reason why the active toolchain is active .
90+ // Represents the source that determined the current active toolchain.
9191#[ derive( Debug ) ]
92- pub ( crate ) enum ActiveReason {
92+ pub ( crate ) enum ActiveSource {
9393 Default ,
9494 Environment ,
9595 CommandLine ,
9696 OverrideDB ( PathBuf ) ,
9797 ToolchainFile ( PathBuf ) ,
9898}
9999
100- impl Display for ActiveReason {
100+ impl Display for ActiveSource {
101101 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> std:: result:: Result < ( ) , fmt:: Error > {
102102 match self {
103103 Self :: Default => write ! ( f, "it's the default toolchain" ) ,
@@ -486,7 +486,7 @@ impl<'a> Cfg<'a> {
486486 pub ( crate ) async fn maybe_ensure_active_toolchain (
487487 & self ,
488488 force_ensure : Option < bool > ,
489- ) -> Result < Option < ( LocalToolchainName , ActiveReason ) > > {
489+ ) -> Result < Option < ( LocalToolchainName , ActiveSource ) > > {
490490 let should_ensure = if let Some ( force) = force_ensure {
491491 force
492492 } else {
@@ -505,39 +505,39 @@ impl<'a> Cfg<'a> {
505505 }
506506 }
507507
508- pub ( crate ) fn active_toolchain ( & self ) -> Result < Option < ( LocalToolchainName , ActiveReason ) > > {
508+ pub ( crate ) fn active_toolchain ( & self ) -> Result < Option < ( LocalToolchainName , ActiveSource ) > > {
509509 Ok (
510- if let Some ( ( override_config, reason ) ) = self . find_override_config ( ) ? {
511- Some ( ( override_config. into_local_toolchain_name ( ) , reason ) )
510+ if let Some ( ( override_config, source ) ) = self . find_override_config ( ) ? {
511+ Some ( ( override_config. into_local_toolchain_name ( ) , source ) )
512512 } else {
513513 self . get_default ( ) ?
514- . map ( |x| ( x. into ( ) , ActiveReason :: Default ) )
514+ . map ( |x| ( x. into ( ) , ActiveSource :: Default ) )
515515 } ,
516516 )
517517 }
518518
519- fn find_override_config ( & self ) -> Result < Option < ( OverrideCfg , ActiveReason ) > > {
520- let override_config: Option < ( OverrideCfg , ActiveReason ) > =
519+ fn find_override_config ( & self ) -> Result < Option < ( OverrideCfg , ActiveSource ) > > {
520+ let override_config: Option < ( OverrideCfg , ActiveSource ) > =
521521 // First check +toolchain override from the command line
522522 if let Some ( name) = & self . toolchain_override {
523523 let override_config = name. resolve ( & self . get_default_host_triple ( ) ?) ?. into ( ) ;
524- Some ( ( override_config, ActiveReason :: CommandLine ) )
524+ Some ( ( override_config, ActiveSource :: CommandLine ) )
525525 }
526526 // Then check the RUSTUP_TOOLCHAIN environment variable
527527 else if let Some ( name) = & self . env_override {
528528 // Because path based toolchain files exist, this has to support
529529 // custom, distributable, and absolute path toolchains otherwise
530530 // rustup's export of a RUSTUP_TOOLCHAIN when running a process will
531531 // error when a nested rustup invocation occurs
532- Some ( ( name. clone ( ) . into ( ) , ActiveReason :: Environment ) )
532+ Some ( ( name. clone ( ) . into ( ) , ActiveSource :: Environment ) )
533533 }
534534 // Then walk up the directory tree from 'path' looking for either the
535535 // directory in the override database, or a `rust-toolchain{.toml}` file,
536536 // in that order.
537- else if let Some ( ( override_cfg, active_reason ) ) = self . settings_file . with ( |s| {
537+ else if let Some ( ( override_cfg, active_source ) ) = self . settings_file . with ( |s| {
538538 self . find_override_from_dir_walk ( & self . current_dir , s)
539539 } ) ? {
540- Some ( ( override_cfg, active_reason ) )
540+ Some ( ( override_cfg, active_source ) )
541541 }
542542 // Otherwise, there is no override.
543543 else {
@@ -551,13 +551,13 @@ impl<'a> Cfg<'a> {
551551 & self ,
552552 dir : & Path ,
553553 settings : & Settings ,
554- ) -> Result < Option < ( OverrideCfg , ActiveReason ) > > {
554+ ) -> Result < Option < ( OverrideCfg , ActiveSource ) > > {
555555 let mut dir = Some ( dir) ;
556556
557557 while let Some ( d) = dir {
558558 // First check the override database
559559 if let Some ( name) = settings. dir_override ( d) {
560- let reason = ActiveReason :: OverrideDB ( d. to_owned ( ) ) ;
560+ let source = ActiveSource :: OverrideDB ( d. to_owned ( ) ) ;
561561 // Note that `rustup override set` fully resolves it's input
562562 // before writing to settings.toml, so resolving here may not
563563 // be strictly necessary (could instead model as ToolchainName).
@@ -567,7 +567,7 @@ impl<'a> Cfg<'a> {
567567 let toolchain_name = ResolvableToolchainName :: try_from ( name) ?
568568 . resolve ( & get_default_host_triple ( settings, self . process ) ) ?;
569569 let override_cfg = toolchain_name. into ( ) ;
570- return Ok ( Some ( ( override_cfg, reason ) ) ) ;
570+ return Ok ( Some ( ( override_cfg, source ) ) ) ;
571571 }
572572
573573 // Then look for 'rust-toolchain' or 'rust-toolchain.toml'
@@ -651,9 +651,9 @@ impl<'a> Cfg<'a> {
651651 }
652652 }
653653
654- let reason = ActiveReason :: ToolchainFile ( toolchain_file) ;
654+ let source = ActiveSource :: ToolchainFile ( toolchain_file) ;
655655 let override_cfg = OverrideCfg :: from_file ( self , override_file) ?;
656- return Ok ( Some ( ( override_cfg, reason ) ) ) ;
656+ return Ok ( Some ( ( override_cfg, source ) ) ) ;
657657 }
658658
659659 dir = d. parent ( ) ;
@@ -747,8 +747,8 @@ impl<'a> Cfg<'a> {
747747 & self ,
748748 force_non_host : bool ,
749749 verbose : bool ,
750- ) -> Result < ( LocalToolchainName , ActiveReason ) > {
751- if let Some ( ( override_config, reason ) ) = self . find_override_config ( ) ? {
750+ ) -> Result < ( LocalToolchainName , ActiveSource ) > {
751+ if let Some ( ( override_config, source ) ) = self . find_override_config ( ) ? {
752752 let toolchain = override_config. clone ( ) . into_local_toolchain_name ( ) ;
753753 if let OverrideCfg :: Official {
754754 toolchain,
@@ -767,18 +767,18 @@ impl<'a> Cfg<'a> {
767767 )
768768 . await ?;
769769 } else {
770- Toolchain :: with_reason ( self , toolchain. clone ( ) , & reason ) ?;
770+ Toolchain :: with_source ( self , toolchain. clone ( ) , & source ) ?;
771771 }
772- Ok ( ( toolchain, reason ) )
772+ Ok ( ( toolchain, source ) )
773773 } else if let Some ( toolchain) = self . get_default ( ) ? {
774- let reason = ActiveReason :: Default ;
774+ let source = ActiveSource :: Default ;
775775 if let ToolchainName :: Official ( desc) = & toolchain {
776776 self . ensure_installed ( desc, vec ! [ ] , vec ! [ ] , None , force_non_host, verbose)
777777 . await ?;
778778 } else {
779- Toolchain :: with_reason ( self , toolchain. clone ( ) . into ( ) , & reason ) ?;
779+ Toolchain :: with_source ( self , toolchain. clone ( ) . into ( ) , & source ) ?;
780780 }
781- Ok ( ( toolchain. into ( ) , reason ) )
781+ Ok ( ( toolchain. into ( ) , source ) )
782782 } else {
783783 Err ( no_toolchain_error ( self . process ) )
784784 }
0 commit comments