File tree 2 files changed +16
-9
lines changed
2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -899,13 +899,7 @@ async fn which(
899
899
binary : & str ,
900
900
toolchain : Option < ResolvableToolchainName > ,
901
901
) -> Result < utils:: ExitCode > {
902
- let binary_path = if let Some ( toolchain) = toolchain {
903
- let desc = toolchain. resolve ( & cfg. get_default_host_triple ( ) ?) ?;
904
- Toolchain :: new ( cfg, desc. into ( ) ) ?. binary_file ( binary)
905
- } else {
906
- let ( toolchain, _) = cfg. find_or_install_active_toolchain ( ) . await ?;
907
- toolchain. binary_file ( binary)
908
- } ;
902
+ let binary_path = cfg. resolve_toolchain ( toolchain) . await ?. binary_file ( binary) ;
909
903
910
904
utils:: assert_is_file ( & binary_path) ?;
911
905
Original file line number Diff line number Diff line change @@ -726,6 +726,19 @@ impl<'a> Cfg<'a> {
726
726
. rustc_version ( ) )
727
727
}
728
728
729
+ pub ( crate ) async fn resolve_toolchain (
730
+ & self ,
731
+ name : Option < ResolvableToolchainName > ,
732
+ ) -> Result < Toolchain < ' _ > > {
733
+ Ok ( match name {
734
+ Some ( name) => {
735
+ let desc = name. resolve ( & self . get_default_host_triple ( ) ?) ?;
736
+ Toolchain :: new ( self , desc. into ( ) ) ?
737
+ }
738
+ None => self . find_or_install_active_toolchain ( ) . await ?. 0 ,
739
+ } )
740
+ }
741
+
729
742
pub ( crate ) async fn local_toolchain (
730
743
& self ,
731
744
name : Option < ResolvableLocalToolchainName > ,
@@ -740,7 +753,7 @@ impl<'a> Cfg<'a> {
740
753
} )
741
754
}
742
755
743
- pub ( crate ) async fn find_or_install_active_toolchain (
756
+ async fn find_or_install_active_toolchain (
744
757
& ' a self ,
745
758
) -> Result < ( Toolchain < ' a > , ActiveReason ) > {
746
759
self . maybe_find_or_install_active_toolchain ( & self . current_dir )
@@ -749,7 +762,7 @@ impl<'a> Cfg<'a> {
749
762
}
750
763
751
764
#[ cfg_attr( feature = "otel" , tracing:: instrument( skip_all) ) ]
752
- pub ( crate ) async fn maybe_find_or_install_active_toolchain (
765
+ async fn maybe_find_or_install_active_toolchain (
753
766
& ' a self ,
754
767
path : & Path ,
755
768
) -> Result < Option < ( Toolchain < ' a > , ActiveReason ) > > {
You can’t perform that action at this time.
0 commit comments