@@ -518,42 +518,34 @@ impl<'a> Cfg<'a> {
518
518
& self ,
519
519
) -> Result < Option < ( LocalToolchainName , ActiveReason ) > > {
520
520
Ok (
521
- if let Some ( ( override_config, reason) ) = self . find_override_config ( ) ? {
521
+ match self . find_override_config ( ) ? { Some ( ( override_config, reason) ) => {
522
522
Some ( ( override_config. into_local_toolchain_name ( ) , reason) )
523
- } else {
523
+ } _ => {
524
524
self . get_default ( ) ?
525
525
. map ( |x| ( x. into ( ) , ActiveReason :: Default ) )
526
- } ,
526
+ } } ,
527
527
)
528
528
}
529
529
530
530
fn find_override_config ( & self ) -> Result < Option < ( OverrideCfg , ActiveReason ) > > {
531
531
let override_config: Option < ( OverrideCfg , ActiveReason ) > =
532
532
// First check +toolchain override from the command line
533
- if let Some ( ref name) = self . toolchain_override {
533
+ match self . toolchain_override { Some ( ref name) => {
534
534
let override_config = name. resolve ( & self . get_default_host_triple ( ) ?) ?. into ( ) ;
535
535
Some ( ( override_config, ActiveReason :: CommandLine ) )
536
- }
537
- // Then check the RUSTUP_TOOLCHAIN environment variable
538
- else if let Some ( ref name) = self . env_override {
536
+ } _ => { match self . env_override { Some ( ref name) => {
539
537
// Because path based toolchain files exist, this has to support
540
538
// custom, distributable, and absolute path toolchains otherwise
541
539
// rustup's export of a RUSTUP_TOOLCHAIN when running a process will
542
540
// error when a nested rustup invocation occurs
543
541
Some ( ( name. clone ( ) . into ( ) , ActiveReason :: Environment ) )
544
- }
545
- // Then walk up the directory tree from 'path' looking for either the
546
- // directory in the override database, or a `rust-toolchain{.toml}` file,
547
- // in that order.
548
- else if let Some ( ( override_cfg, active_reason) ) = self . settings_file . with ( |s| {
542
+ } _ => { match self . settings_file . with ( |s| {
549
543
self . find_override_from_dir_walk ( & self . current_dir , s)
550
- } ) ? {
544
+ } ) ? { Some ( ( override_cfg , active_reason ) ) => {
551
545
Some ( ( override_cfg, active_reason) )
552
- }
553
- // Otherwise, there is no override.
554
- else {
546
+ } _ => {
555
547
None
556
- } ;
548
+ } } } } } } ;
557
549
558
550
Ok ( override_config)
559
551
}
@@ -753,15 +745,15 @@ impl<'a> Cfg<'a> {
753
745
force_non_host : bool ,
754
746
verbose : bool ,
755
747
) -> Result < ( LocalToolchainName , ActiveReason ) > {
756
- if let Some ( ( override_config, reason) ) = self . find_override_config ( ) ? {
748
+ match self . find_override_config ( ) ? { Some ( ( override_config, reason) ) => {
757
749
let toolchain = override_config. clone ( ) . into_local_toolchain_name ( ) ;
758
- if let OverrideCfg :: Official {
750
+ match override_config
751
+ { OverrideCfg :: Official {
759
752
toolchain,
760
753
components,
761
754
targets,
762
755
profile,
763
- } = override_config
764
- {
756
+ } => {
765
757
self . ensure_installed (
766
758
& toolchain,
767
759
components,
@@ -771,22 +763,22 @@ impl<'a> Cfg<'a> {
771
763
verbose,
772
764
)
773
765
. await ?;
774
- } else {
766
+ } _ => {
775
767
Toolchain :: with_reason ( self , toolchain. clone ( ) , & reason) ?;
776
- }
768
+ } }
777
769
Ok ( ( toolchain, reason) )
778
- } else if let Some ( toolchain ) = self . get_default ( ) ? {
770
+ } _ => { match self . get_default ( ) ? { Some ( toolchain ) => {
779
771
let reason = ActiveReason :: Default ;
780
- if let ToolchainName :: Official ( desc) = & toolchain {
772
+ match & toolchain { ToolchainName :: Official ( desc) => {
781
773
self . ensure_installed ( desc, vec ! [ ] , vec ! [ ] , None , force_non_host, verbose)
782
774
. await ?;
783
- } else {
775
+ } _ => {
784
776
Toolchain :: with_reason ( self , toolchain. clone ( ) . into ( ) , & reason) ?;
785
- }
777
+ } }
786
778
Ok ( ( toolchain. into ( ) , reason) )
787
- } else {
779
+ } _ => {
788
780
Err ( no_toolchain_error ( self . process ) )
789
- }
781
+ } } } }
790
782
}
791
783
792
784
// Returns a Toolchain matching the given ToolchainDesc, installing it and
@@ -894,11 +886,11 @@ impl<'a> Cfg<'a> {
894
886
self . list_toolchains ( ) ?
895
887
. into_iter ( )
896
888
. filter_map ( |t| {
897
- if let ToolchainName :: Official ( desc) = t {
889
+ match t { ToolchainName :: Official ( desc) => {
898
890
Some ( desc)
899
- } else {
891
+ } _ => {
900
892
None
901
- }
893
+ } }
902
894
} )
903
895
. filter ( ToolchainDesc :: is_tracking)
904
896
. map ( |n| {
0 commit comments