Skip to content

Commit 49cf657

Browse files
committed
Rename do_pre_install_options_sanity_checks() to InstallOpts::validate()
1 parent b9f150c commit 49cf657

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/cli/self_update.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,38 @@ impl<'a> InstallOpts<'a> {
136136

137137
Ok(())
138138
}
139+
140+
fn validate(&self) -> Result<()> {
141+
common::warn_if_host_is_emulated();
142+
143+
// Verify that the installation options are vaguely sane
144+
(|| {
145+
let host_triple = self
146+
.default_host_triple
147+
.as_ref()
148+
.map(dist::TargetTriple::new)
149+
.unwrap_or_else(TargetTriple::from_host_or_build);
150+
let partial_channel = match &self.default_toolchain {
151+
None | Some(MaybeOfficialToolchainName::None) => {
152+
ResolvableToolchainName::try_from("stable")?
153+
}
154+
Some(MaybeOfficialToolchainName::Some(s)) => s.into(),
155+
};
156+
let resolved = partial_channel.resolve(&host_triple)?;
157+
debug!("Successfully resolved installation toolchain as: {resolved}");
158+
Ok(())
159+
})()
160+
.map_err(|e: Box<dyn std::error::Error>| {
161+
anyhow!(
162+
"Pre-checks for host and toolchain failed: {}\n\
163+
If you are unsure of suitable values, the 'stable' toolchain is the default.\n\
164+
Valid host triples look something like: {}",
165+
e,
166+
TargetTriple::from_host_or_build()
167+
)
168+
})?;
169+
Ok(())
170+
}
139171
}
140172

141173
#[cfg(feature = "no-self-update")]
@@ -424,7 +456,7 @@ pub(crate) async fn install(
424456
do_pre_install_sanity_checks(no_prompt)?;
425457
}
426458

427-
do_pre_install_options_sanity_checks(&opts)?;
459+
opts.validate()?;
428460

429461
if !process()
430462
.var_os("RUSTUP_INIT_SKIP_EXISTENCE_CHECKS")
@@ -658,38 +690,6 @@ fn do_pre_install_sanity_checks(no_prompt: bool) -> Result<()> {
658690
Ok(())
659691
}
660692

661-
fn do_pre_install_options_sanity_checks(opts: &InstallOpts<'_>) -> Result<()> {
662-
common::warn_if_host_is_emulated();
663-
664-
// Verify that the installation options are vaguely sane
665-
(|| {
666-
let host_triple = opts
667-
.default_host_triple
668-
.as_ref()
669-
.map(dist::TargetTriple::new)
670-
.unwrap_or_else(TargetTriple::from_host_or_build);
671-
let partial_channel = match &opts.default_toolchain {
672-
None | Some(MaybeOfficialToolchainName::None) => {
673-
ResolvableToolchainName::try_from("stable")?
674-
}
675-
Some(MaybeOfficialToolchainName::Some(s)) => s.into(),
676-
};
677-
let resolved = partial_channel.resolve(&host_triple)?;
678-
debug!("Successfully resolved installation toolchain as: {resolved}");
679-
Ok(())
680-
})()
681-
.map_err(|e: Box<dyn std::error::Error>| {
682-
anyhow!(
683-
"Pre-checks for host and toolchain failed: {}\n\
684-
If you are unsure of suitable values, the 'stable' toolchain is the default.\n\
685-
Valid host triples look something like: {}",
686-
e,
687-
TargetTriple::from_host_or_build()
688-
)
689-
})?;
690-
Ok(())
691-
}
692-
693693
fn pre_install_msg(no_modify_path: bool) -> Result<String> {
694694
let cargo_home = utils::cargo_home()?;
695695
let cargo_home_bin = cargo_home.join("bin");

0 commit comments

Comments
 (0)