Skip to content

Commit 37bfef2

Browse files
committed
feat(config)!: use unqualified names for default_toolchain
1 parent e45dd83 commit 37bfef2

8 files changed

Lines changed: 26 additions & 15 deletions

File tree

src/cli/rustup_mode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,13 +881,13 @@ async fn default_(
881881
cfg.set_default(Some(&toolchain_name.into()))?;
882882
}
883883
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
884-
let desc = toolchain.resolve(&cfg.default_host_tuple()?)?;
884+
let desc = toolchain.clone().resolve(&cfg.default_host_tuple()?)?;
885885
let status = cfg
886886
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
887887
.await?
888888
.status;
889889

890-
cfg.set_default(Some(&desc.clone().into()))?;
890+
cfg.set_default(Some(&toolchain.into()))?;
891891

892892
writeln!(cfg.process.stdout().lock())?;
893893

@@ -1085,7 +1085,7 @@ async fn update(
10851085
force_non_host,
10861086
)?;
10871087
}
1088-
let desc = name.resolve(&cfg.default_host_tuple()?)?;
1088+
let desc = name.clone().resolve(&cfg.default_host_tuple()?)?;
10891089

10901090
let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();
10911091
let targets = opts.target.iter().map(|s| &**s).collect::<Vec<_>>();
@@ -1128,7 +1128,7 @@ async fn update(
11281128
if opts.default
11291129
|| (cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed))
11301130
{
1131-
cfg.set_default(Some(&desc.into()))?;
1131+
cfg.set_default(Some(&name.into()))?;
11321132
}
11331133
}
11341134
exit_code &= self_update_mode.update(should_self_update, &dl_cfg).await?;

src/cli/self_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl InstallOpts<'_> {
272272

273273
check_proxy_sanity(cfg.process, components, &desc)?;
274274

275-
cfg.set_default(Some(&desc.clone().into()))?;
275+
cfg.set_default(Some(&partial_desc.into()))?;
276276
writeln!(cfg.process.stdout().lock())?;
277277
common::show_channel_update(cfg, PackageUpdate::Toolchain(desc), Ok(status))?;
278278
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'a> Cfg<'a> {
384384
Ok(cfg)
385385
}
386386

387-
pub(crate) fn set_default(&self, toolchain: Option<&ToolchainName>) -> Result<()> {
387+
pub(crate) fn set_default(&self, toolchain: Option<&ResolvableToolchainName>) -> Result<()> {
388388
self.settings_file.with_mut(|s| {
389389
s.default_toolchain = toolchain.map(|t| t.to_string());
390390
Ok(())

src/toolchain/names.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ impl ResolvableLocalToolchainName {
304304
}
305305
}
306306

307+
from_variant!(
308+
PartialToolchainDesc,
309+
ResolvableToolchainName,
310+
ResolvableToolchainName::Official
311+
);
312+
from_variant!(
313+
CustomToolchainName,
314+
ResolvableToolchainName,
315+
ResolvableToolchainName::Custom
316+
);
317+
307318
try_from_str!(ResolvableLocalToolchainName);
308319

309320
impl Display for ResolvableLocalToolchainName {

tests/suite/cli_exact.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn update_once() {
2323
info: syncing channel updates for nightly-[HOST_TUPLE]
2424
info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2)
2525
info: downloading 4 components
26-
info: default toolchain set to nightly-[HOST_TUPLE]
26+
info: default toolchain set to nightly
2727
2828
"#]]);
2929
cx.config
@@ -322,7 +322,7 @@ async fn default() {
322322
info: syncing channel updates for nightly-[HOST_TUPLE]
323323
info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2)
324324
info: downloading 4 components
325-
info: default toolchain set to nightly-[HOST_TUPLE]
325+
info: default toolchain set to nightly
326326
327327
"#]]);
328328
cx.config

tests/suite/cli_rustup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async fn default() {
290290
info: syncing channel updates for nightly-[HOST_TUPLE]
291291
info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2)
292292
info: downloading 4 components
293-
info: default toolchain set to nightly-[HOST_TUPLE]
293+
info: default toolchain set to nightly
294294
295295
"#]])
296296
.is_ok();
@@ -327,7 +327,7 @@ async fn default_override() {
327327
.await
328328
.with_stderr(snapbox::str![[r#"
329329
info: using existing install for stable-[HOST_TUPLE]
330-
info: default toolchain set to stable-[HOST_TUPLE]
330+
info: default toolchain set to stable
331331
info: note that the toolchain 'nightly-[HOST_TUPLE]' is currently in use (directory override for '[..]')
332332
333333
"#]])
@@ -4032,7 +4032,7 @@ async fn custom_toolchain_with_components_toolchains_profile_does_not_err() {
40324032
info: syncing channel updates for nightly-[HOST_TUPLE]
40334033
info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2)
40344034
info: downloading 2 components
4035-
info: default toolchain set to nightly-[HOST_TUPLE]
4035+
info: default toolchain set to nightly
40364036
40374037
"#]])
40384038
.is_ok();

tests/suite/cli_rustup_ui/rustup_default.stderr.term.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/suite/cli_self_upd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async fn install_bins_to_cargo_home() {
7474
info: syncing channel updates for stable-[HOST_TUPLE]
7575
info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0)
7676
info: downloading 4 components
77-
info: default toolchain set to stable-[HOST_TUPLE]
77+
info: default toolchain set to stable
7878
7979
"#]])
8080
.is_ok();
@@ -118,7 +118,7 @@ async fn proxies_are_relative_symlinks() {
118118
info: syncing channel updates for stable-[HOST_TUPLE]
119119
info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0)
120120
info: downloading 4 components
121-
info: default toolchain set to stable-[HOST_TUPLE]
121+
info: default toolchain set to stable
122122
...
123123
"#]])
124124
.is_ok();
@@ -974,7 +974,7 @@ async fn reinstall_specifying_different_toolchain() {
974974
.await
975975
.with_stderr(snapbox::str![[r#"
976976
...
977-
info: default toolchain set to nightly-[HOST_TUPLE]
977+
info: default toolchain set to nightly
978978
...
979979
"#]])
980980
.is_ok();

0 commit comments

Comments
 (0)