@@ -293,21 +293,7 @@ impl<'a> Cfg<'a> {
293
293
. map ( |t| t. resolve ( & default_host_triple) )
294
294
. transpose ( ) ?;
295
295
296
- let dist_root_server = match non_empty_env_var ( "RUSTUP_DIST_SERVER" , process) ? {
297
- Some ( s) => {
298
- trace ! ( "`RUSTUP_DIST_SERVER` has been set to `{s}`" ) ;
299
- s
300
- }
301
- None => {
302
- // For backward compatibility
303
- non_empty_env_var ( "RUSTUP_DIST_ROOT" , process) ?
304
- . inspect ( |url| trace ! ( "`RUSTUP_DIST_ROOT` has been set to `{url}`" ) )
305
- . as_ref ( )
306
- . map ( |root| root. trim_end_matches ( "/dist" ) )
307
- . unwrap_or ( dist:: DEFAULT_DIST_SERVER )
308
- . to_owned ( )
309
- }
310
- } ;
296
+ let dist_root_server = dist_root_server ( process) ?;
311
297
312
298
let notify_clone = notify_handler. clone ( ) ;
313
299
let tmp_cx = temp:: Context :: new (
@@ -950,6 +936,24 @@ impl<'a> Cfg<'a> {
950
936
}
951
937
}
952
938
939
+ pub ( crate ) fn dist_root_server ( process : & Process ) -> Result < String > {
940
+ Ok ( match non_empty_env_var ( "RUSTUP_DIST_SERVER" , process) ? {
941
+ Some ( s) => {
942
+ trace ! ( "`RUSTUP_DIST_SERVER` has been set to `{s}`" ) ;
943
+ s
944
+ }
945
+ None => {
946
+ // For backward compatibility
947
+ non_empty_env_var ( "RUSTUP_DIST_ROOT" , process) ?
948
+ . inspect ( |url| trace ! ( "`RUSTUP_DIST_ROOT` has been set to `{url}`" ) )
949
+ . as_ref ( )
950
+ . map ( |root| root. trim_end_matches ( "/dist" ) )
951
+ . unwrap_or ( dist:: DEFAULT_DIST_SERVER )
952
+ . to_owned ( )
953
+ }
954
+ } )
955
+ }
956
+
953
957
impl < ' a > Debug for Cfg < ' a > {
954
958
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
955
959
let Self {
0 commit comments