Skip to content

Commit e105b2e

Browse files
committed
refactor(dist): rename *ToolchainName::resolve() to _::complete()
1 parent 8630358 commit e105b2e

7 files changed

Lines changed: 29 additions & 26 deletions

File tree

‎src/cli/proxy_mode.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub async fn main(
3838
let (toolchain, source) = cfg
3939
.local_toolchain(match toolchain {
4040
Some(name) => Some((
41-
name.resolve(&cfg)?.resolve(&cfg.default_host_tuple()?)?,
41+
name.resolve(&cfg)?.complete(&cfg.default_host_tuple()?)?,
4242
ActiveSource::CommandLine,
4343
)),
4444

‎src/cli/rustup_mode.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ async fn default_(
940940
cfg.set_default(Some(&toolchain_name.into()))?;
941941
}
942942
MaybePartialToolchainName::Some(PartialToolchainName::Official(toolchain)) => {
943-
let desc = toolchain.clone().resolve(&cfg.default_host_tuple()?)?;
943+
let desc = toolchain.clone().complete(&cfg.default_host_tuple()?)?;
944944
let status = cfg
945945
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
946946
.await?
@@ -1136,15 +1136,15 @@ async fn update(
11361136
// This needs another pass to fix it all up
11371137
if !name.target.is_empty() {
11381138
let host_arch = TargetTuple::from_host_or_build(cfg.process);
1139-
let target_tuple = name.clone().resolve(&host_arch)?.target;
1139+
let target_tuple = name.clone().complete(&host_arch)?.target;
11401140
common::check_non_host_toolchain(
11411141
name.to_string(),
11421142
&host_arch,
11431143
&target_tuple,
11441144
force_non_host,
11451145
)?;
11461146
}
1147-
let desc = name.clone().resolve(&cfg.default_host_tuple()?)?;
1147+
let desc = name.clone().complete(&cfg.default_host_tuple()?)?;
11481148

11491149
let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();
11501150
let targets = opts.target.iter().map(|s| &**s).collect::<Vec<_>>();
@@ -1214,7 +1214,7 @@ async fn run(
12141214
command: Vec<String>,
12151215
install: bool,
12161216
) -> anyhow::Result<ExitStatus> {
1217-
let toolchain = toolchain.resolve(&cfg.default_host_tuple()?)?;
1217+
let toolchain = toolchain.complete(&cfg.default_host_tuple()?)?;
12181218
let toolchain = Toolchain::from_local(toolchain, install, cfg).await?;
12191219
let cmd = toolchain.command(&command[0])?;
12201220
command::run_command_for_dir(cmd, &command[0], &command[1..])
@@ -1228,7 +1228,7 @@ async fn which(
12281228
let (toolchain, _) = cfg
12291229
.local_toolchain(match toolchain {
12301230
Some(name) => Some((
1231-
name.resolve(&cfg.default_host_tuple()?)?.into(),
1231+
name.complete(&cfg.default_host_tuple()?)?.into(),
12321232
ActiveSource::CommandLine, // From --toolchain option
12331233
)),
12341234
None => None,
@@ -1664,7 +1664,7 @@ async fn toolchain_remove(cfg: &Cfg<'_>, opts: UninstallOpts) -> anyhow::Result<
16641664
.map(|(it, _)| it);
16651665

16661666
for toolchain_name in opts.toolchain {
1667-
let toolchain_name = toolchain_name.resolve(&cfg.default_host_tuple()?)?;
1667+
let toolchain_name = toolchain_name.complete(&cfg.default_host_tuple()?)?;
16681668

16691669
if active_toolchain
16701670
.as_ref()
@@ -1700,7 +1700,7 @@ fn pin_active_toolchain(qualified: bool, cfg: &Cfg<'_>) -> anyhow::Result<ExitCo
17001700
let components = match &default {
17011701
PartialToolchainName::Official(desc) => {
17021702
let tc =
1703-
DistributableToolchain::new(cfg, desc.clone().resolve(&default_host)?)?;
1703+
DistributableToolchain::new(cfg, desc.clone().complete(&default_host)?)?;
17041704
let manifest = tc.get_manifest()?;
17051705

17061706
Some(
@@ -1760,7 +1760,7 @@ async fn override_add(
17601760
let toolchain_name = toolchain
17611761
.clone()
17621762
.resolve(cfg)?
1763-
.resolve(&cfg.default_host_tuple()?)?;
1763+
.complete(&cfg.default_host_tuple()?)?;
17641764
match Toolchain::new(cfg, toolchain_name.clone().into()) {
17651765
Ok(_) => {}
17661766
Err(e @ RustupError::ToolchainNotInstalled { .. }) => match &toolchain_name {

‎src/cli/self_update.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl InstallOpts<'_> {
271271
let (components, targets) = (self.components, self.targets);
272272
let toolchain = self.select_toolchain(&mut cfg)?;
273273
if let Some(partial_desc) = toolchain {
274-
let desc = partial_desc.clone().resolve(&cfg.default_host_tuple()?)?;
274+
let desc = partial_desc.clone().complete(&cfg.default_host_tuple()?)?;
275275
let options =
276276
DistOptions::new(components, targets, &desc, cfg.get_profile()?, true, &cfg)?;
277277
let status = if Toolchain::exists(&cfg, &desc.clone().into())? {
@@ -440,7 +440,7 @@ impl InstallOpts<'_> {
440440
}
441441
Some(MaybeOfficialToolchainName::Some(s)) => s.into(),
442442
};
443-
let resolved = partial_channel.resolve(&host_tuple)?;
443+
let resolved = partial_channel.complete(&host_tuple)?;
444444
trace!("Successfully resolved installation toolchain as: {resolved}");
445445
Ok(())
446446
}
@@ -697,7 +697,7 @@ fn check_existence_of_settings_file(process: &Process) -> anyhow::Result<()> {
697697
warn!("{}", settings_file.path.display());
698698
let default_host_tuple = settings_file.with(|s| Ok(default_host_tuple(s, process)))?;
699699
let inferred =
700-
PartialOfficialToolchainName::from_str("stable")?.resolve(&default_host_tuple)?;
700+
PartialOfficialToolchainName::from_str("stable")?.complete(&default_host_tuple)?;
701701
if default_toolchain != inferred.to_string() {
702702
warn!("rustup will install the default toolchain as specified in the settings file,");
703703
warn!("instead of the one inferred from the default host tuple.");

‎src/config.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl OverrideCfg {
253253
Ok(match self {
254254
Self::PathBased(path_based_name) => path_based_name.into(),
255255
Self::Custom(custom_name) => custom_name.into(),
256-
Self::Official { toolchain, .. } => toolchain.resolve(host_tuple)?.into(),
256+
Self::Official { toolchain, .. } => toolchain.complete(host_tuple)?.into(),
257257
})
258258
}
259259

@@ -412,7 +412,7 @@ impl<'a> Cfg<'a> {
412412
// Run some basic checks against the constructed configuration
413413
// For now, that means simply checking that 'stable' can resolve
414414
// for the current configuration.
415-
PartialToolchainName::from_str("stable")?.resolve(
415+
PartialToolchainName::from_str("stable")?.complete(
416416
&cfg.default_host_tuple()
417417
.context("Unable parse configuration")?,
418418
)?;
@@ -589,7 +589,7 @@ impl<'a> Cfg<'a> {
589589
.map(|(desc, source)| {
590590
anyhow::Ok((
591591
ToolchainNameOrPath::Named(ToolchainName::Official(
592-
desc.resolve(&self.default_host_tuple()?)?,
592+
desc.complete(&self.default_host_tuple()?)?,
593593
)),
594594
source,
595595
))
@@ -766,7 +766,7 @@ impl<'a> Cfg<'a> {
766766
}
767767

768768
// XXX: this awkwardness deals with settings file being locked already
769-
let toolchain_name = toolchain_name.resolve(&default_host)?;
769+
let toolchain_name = toolchain_name.complete(&default_host)?;
770770
if !Toolchain::exists(self, &toolchain_name.clone().into())?
771771
&& matches!(toolchain_name, ToolchainName::Custom(_))
772772
{
@@ -860,7 +860,7 @@ impl<'a> Cfg<'a> {
860860
} = override_config
861861
{
862862
self.ensure_installed(
863-
&toolchain.resolve(&default_host)?,
863+
&toolchain.complete(&default_host)?,
864864
components.unwrap_or_default(),
865865
targets.unwrap_or_default(),
866866
profile,
@@ -955,7 +955,7 @@ impl<'a> Cfg<'a> {
955955
let Some(toolchain) = self.get_default_resolvable()? else {
956956
return Ok(None);
957957
};
958-
Ok(Some(toolchain.resolve(&self.default_host_tuple()?)?))
958+
Ok(Some(toolchain.complete(&self.default_host_tuple()?)?))
959959
}
960960

961961
/// Gets the configured default toolchain name in its unresolved form, if any.
@@ -1069,7 +1069,7 @@ impl<'a> Cfg<'a> {
10691069
// against the 'stable' toolchain. This provides early errors
10701070
// if the supplied tuple is insufficient / bad.
10711071
PartialOfficialToolchainName::from_str("stable")?
1072-
.resolve(&TargetTuple::new(host_tuple.clone()))?;
1072+
.complete(&TargetTuple::new(host_tuple.clone()))?;
10731073
self.settings_file.with_mut(|s| {
10741074
s.default_host_tuple = Some(host_tuple);
10751075
Ok(())
@@ -1113,7 +1113,7 @@ impl<'a> Cfg<'a> {
11131113

11141114
let default_host = self.default_host_tuple()?;
11151115
let stable_desc =
1116-
PartialOfficialToolchainName::from_str("stable")?.resolve(&default_host)?;
1116+
PartialOfficialToolchainName::from_str("stable")?.complete(&default_host)?;
11171117
let stable = match DistributableToolchain::new(self, stable_desc) {
11181118
Ok(stable) => stable,
11191119
// If the `stable` toolchain is not installed, we don't notify the user.

‎src/dist/mod.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ pub struct PartialOfficialToolchainName {
207207

208208
impl PartialOfficialToolchainName {
209209
/// Create a toolchain desc using input_host to fill in missing fields
210-
pub(crate) fn resolve(self, input_host: &TargetTuple) -> anyhow::Result<OfficialToolchainName> {
210+
pub(crate) fn complete(
211+
self,
212+
input_host: &TargetTuple,
213+
) -> anyhow::Result<OfficialToolchainName> {
211214
Ok(OfficialToolchainName {
212215
channel: self.channel,
213216
date: self.date,

‎src/toolchain.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'a> Toolchain<'a> {
378378
// toolchains in principle.
379379
for fallback in ["nightly", "beta", "stable"] {
380380
let resolved =
381-
PartialOfficialToolchainName::from_str(fallback)?.resolve(&default_host_tuple)?;
381+
PartialOfficialToolchainName::from_str(fallback)?.complete(&default_host_tuple)?;
382382
if let Ok(fallback) = DistributableToolchain::new(self.cfg, resolved) {
383383
let cmd = fallback.create_fallback_command("cargo", self)?;
384384
return Ok(Some(cmd));

‎src/toolchain/names.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ pub(crate) enum PartialToolchainName {
162162

163163
impl PartialToolchainName {
164164
/// Resolve to a concrete toolchain name
165-
pub fn resolve(self, host: &TargetTuple) -> Result<ToolchainName, anyhow::Error> {
165+
pub fn complete(self, host: &TargetTuple) -> Result<ToolchainName, anyhow::Error> {
166166
Ok(match self {
167167
Self::Custom(c) => ToolchainName::Custom(c),
168-
Self::Official(desc) => ToolchainName::Official(desc.resolve(host)?),
168+
Self::Official(desc) => ToolchainName::Official(desc.complete(host)?),
169169
})
170170
}
171171
}
@@ -329,9 +329,9 @@ pub(crate) enum PartialToolchainNameOrPath {
329329

330330
impl PartialToolchainNameOrPath {
331331
/// Resolve to a concrete toolchain name
332-
pub fn resolve(&self, host: &TargetTuple) -> Result<ToolchainNameOrPath, anyhow::Error> {
332+
pub fn complete(&self, host: &TargetTuple) -> Result<ToolchainNameOrPath, anyhow::Error> {
333333
match self.clone() {
334-
Self::Named(t) => Ok(ToolchainNameOrPath::Named(t.resolve(host)?)),
334+
Self::Named(t) => Ok(ToolchainNameOrPath::Named(t.complete(host)?)),
335335
Self::Path(t) => Ok(ToolchainNameOrPath::Path(t)),
336336
}
337337
}

0 commit comments

Comments
 (0)