@@ -302,7 +302,7 @@ impl<'a> Cfg<'a> {
302
302
let notify_clone = notify_handler. clone ( ) ;
303
303
let tmp_cx = temp:: Context :: new (
304
304
rustup_dir. join ( "tmp" ) ,
305
- dist_root_server. as_str ( ) ,
305
+ & dist_root_server,
306
306
Box :: new ( move |n| ( notify_clone) ( n. into ( ) ) ) ,
307
307
) ;
308
308
let dist_root = dist_root_server + "/dist" ;
@@ -319,7 +319,7 @@ impl<'a> Cfg<'a> {
319
319
notify_handler,
320
320
toolchain_override : None ,
321
321
env_override,
322
- dist_root_url : dist_root,
322
+ dist_root_url : dist_root. to_string ( ) ,
323
323
current_dir,
324
324
process,
325
325
} ;
@@ -940,25 +940,22 @@ impl<'a> Cfg<'a> {
940
940
}
941
941
}
942
942
943
- fn dist_root_server ( process : & Process ) -> String {
944
- match process. var ( "RUSTUP_DIST_SERVER" ) {
945
- Ok ( s ) if !s . is_empty ( ) => {
946
- trace ! ( "`RUSTUP_DIST_SERVER` has been set to `{s}`" ) ;
947
- s
948
- }
949
- _ => {
943
+ fn dist_root_server ( process : & Process ) -> Cow < ' static , str > {
944
+ process
945
+ . var ( "RUSTUP_DIST_SERVER" )
946
+ . ok ( )
947
+ . and_then ( utils :: if_not_empty )
948
+ . inspect ( |s| trace ! ( "`RUSTUP_DIST_SERVER` has been set to `{s}`" ) )
949
+ . or_else ( || {
950
950
// For backward compatibility
951
951
process
952
952
. var ( "RUSTUP_DIST_ROOT" )
953
953
. ok ( )
954
954
. and_then ( utils:: if_not_empty)
955
955
. inspect ( |url| trace ! ( "`RUSTUP_DIST_ROOT` has been set to `{url}`" ) )
956
- . map_or ( Cow :: Borrowed ( dist:: DEFAULT_DIST_ROOT ) , Cow :: Owned )
957
- . as_ref ( )
958
- . trim_end_matches ( "/dist" )
959
- . to_owned ( )
960
- }
961
- }
956
+ . map ( |s| s. trim_end_matches ( "/dist" ) . to_owned ( ) )
957
+ } )
958
+ . map_or ( Cow :: Borrowed ( dist:: DEFAULT_DIST_SERVER ) , Cow :: Owned )
962
959
}
963
960
964
961
impl < ' a > Debug for Cfg < ' a > {
0 commit comments