Skip to content

Commit 86a683a

Browse files
committed
Remove Cargo feature indirection
1 parent 6efc30a commit 86a683a

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
@@ -834,7 +834,7 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<utils::ExitCode
834834
// Check for update only if rustup does **not** have the no-self-update feature,
835835
// and auto-self-update is configured to **enable**
836836
// and has **no** no-self-update parameter.
837-
let self_update = !self_update::NEVER_SELF_UPDATE
837+
let self_update = !cfg!(feature = "no-self-update")
838838
&& self_update_mode == SelfUpdateMode::Enable
839839
&& !opts.no_self_update;
840840

@@ -859,7 +859,7 @@ async fn update(
859859
// Update only if rustup does **not** have the no-self-update feature,
860860
// and auto-self-update is configured to **enable**
861861
// and has **no** no-self-update parameter.
862-
let self_update = !self_update::NEVER_SELF_UPDATE
862+
let self_update = !cfg!(feature = "no-self-update")
863863
&& self_update_mode == SelfUpdateMode::Enable
864864
&& !opts.no_self_update;
865865
let force_non_host = opts.force_non_host;
@@ -936,11 +936,11 @@ async fn update(
936936
cfg.tmp_cx.clean();
937937
}
938938

939-
if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly {
939+
if !cfg!(feature = "no-self-update") && self_update_mode == SelfUpdateMode::CheckOnly {
940940
check_rustup_update(cfg.process).await?;
941941
}
942942

943-
if self_update::NEVER_SELF_UPDATE {
943+
if cfg!(feature = "no-self-update") {
944944
info!("self-update is disabled for this build of rustup");
945945
info!("any updates to rustup will need to be fetched with your system package manager")
946946
}
@@ -1714,7 +1714,7 @@ fn set_auto_self_update(
17141714
cfg: &mut Cfg<'_>,
17151715
auto_self_update_mode: SelfUpdateMode,
17161716
) -> Result<utils::ExitCode> {
1717-
if self_update::NEVER_SELF_UPDATE {
1717+
if cfg!(feature = "no-self-update") {
17181718
let mut args = cfg.process.args_os();
17191719
let arg0 = args.next().map(PathBuf::from);
17201720
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)