Skip to content

Commit e16e606

Browse files
committed
refactor(config): clean up dist_root_server()
1 parent 4bbd94b commit e16e606

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

src/config.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'a> Cfg<'a> {
302302
let notify_clone = notify_handler.clone();
303303
let tmp_cx = temp::Context::new(
304304
rustup_dir.join("tmp"),
305-
dist_root_server.as_str(),
305+
&dist_root_server,
306306
Box::new(move |n| (notify_clone)(n.into())),
307307
);
308308
let dist_root = dist_root_server + "/dist";
@@ -319,7 +319,7 @@ impl<'a> Cfg<'a> {
319319
notify_handler,
320320
toolchain_override: None,
321321
env_override,
322-
dist_root_url: dist_root,
322+
dist_root_url: dist_root.to_string(),
323323
current_dir,
324324
process,
325325
};
@@ -940,25 +940,22 @@ impl<'a> Cfg<'a> {
940940
}
941941
}
942942

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(|| {
950950
// For backward compatibility
951951
process
952952
.var("RUSTUP_DIST_ROOT")
953953
.ok()
954954
.and_then(utils::if_not_empty)
955955
.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)
962959
}
963960

964961
impl<'a> Debug for Cfg<'a> {

src/dist/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ pub(crate) use triple::*;
4242

4343
pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org";
4444

45-
// Deprecated
46-
pub(crate) static DEFAULT_DIST_ROOT: &str = "https://static.rust-lang.org/dist";
47-
4845
const TOOLSTATE_MSG: &str =
4946
"If you require these components, please install and use the latest successful build version,\n\
5047
which you can find at <https://rust-lang.github.io/rustup-components-history>.\n\nAfter determining \

0 commit comments

Comments
 (0)