Skip to content

Commit 98286b2

Browse files
committed
Remove Cargo feature indirection
1 parent 12175a9 commit 98286b2

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/cli/rustup_mode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<utils::ExitCode
895895
// Check for update only if rustup does **not** have the no-self-update feature,
896896
// and auto-self-update is configured to **enable**
897897
// and has **no** no-self-update parameter.
898-
let self_update = !self_update::NEVER_SELF_UPDATE
898+
let self_update = !cfg!(feature = "no-self-update")
899899
&& self_update_mode == SelfUpdateMode::Enable
900900
&& !opts.no_self_update;
901901

@@ -920,7 +920,7 @@ async fn update(
920920
// Update only if rustup does **not** have the no-self-update feature,
921921
// and auto-self-update is configured to **enable**
922922
// and has **no** no-self-update parameter.
923-
let self_update = !self_update::NEVER_SELF_UPDATE
923+
let self_update = !cfg!(feature = "no-self-update")
924924
&& self_update_mode == SelfUpdateMode::Enable
925925
&& !opts.no_self_update;
926926
let force_non_host = opts.force_non_host;
@@ -997,11 +997,11 @@ async fn update(
997997
cfg.tmp_cx.clean();
998998
}
999999

1000-
if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly {
1000+
if !cfg!(feature = "no-self-update") && self_update_mode == SelfUpdateMode::CheckOnly {
10011001
check_rustup_update(cfg.process).await?;
10021002
}
10031003

1004-
if self_update::NEVER_SELF_UPDATE {
1004+
if cfg!(feature = "no-self-update") {
10051005
info!("self-update is disabled for this build of rustup");
10061006
info!("any updates to rustup will need to be fetched with your system package manager")
10071007
}
@@ -1774,7 +1774,7 @@ fn set_auto_self_update(
17741774
cfg: &mut Cfg<'_>,
17751775
auto_self_update_mode: SelfUpdateMode,
17761776
) -> Result<utils::ExitCode> {
1777-
if self_update::NEVER_SELF_UPDATE {
1777+
if cfg!(feature = "no-self-update") {
17781778
let mut args = cfg.process.args_os();
17791779
let arg0 = args.next().map(PathBuf::from);
17801780
let arg0 = arg0

src/cli/self_update.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ impl InstallOpts<'_> {
246246
}
247247
}
248248

249-
#[cfg(feature = "no-self-update")]
250-
pub(crate) const NEVER_SELF_UPDATE: bool = true;
251-
#[cfg(not(feature = "no-self-update"))]
252-
pub(crate) const NEVER_SELF_UPDATE: bool = false;
253-
254249
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
255250
#[serde(rename_all = "kebab-case")]
256251
pub enum SelfUpdateMode {
@@ -955,7 +950,7 @@ async fn maybe_install_rust(
955950
}
956951

957952
pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result<utils::ExitCode> {
958-
if NEVER_SELF_UPDATE {
953+
if cfg!(feature = "no-self-update") {
959954
error!("self-uninstall is disabled for this build of rustup");
960955
error!("you should probably use your system package manager to uninstall rustup");
961956
return Ok(utils::ExitCode(1));
@@ -1073,7 +1068,7 @@ pub(crate) async fn update(cfg: &Cfg<'_>) -> Result<utils::ExitCode> {
10731068
common::warn_if_host_is_emulated(cfg.process);
10741069

10751070
use common::SelfUpdatePermission::*;
1076-
let update_permitted = if NEVER_SELF_UPDATE {
1071+
let update_permitted = if cfg!(feature = "no-self-update") {
10771072
HardFail
10781073
} else {
10791074
common::self_update_permitted(true)?

0 commit comments

Comments
 (0)