Skip to content

Commit afe6341

Browse files
committed
feat(config)!: use unqualified names for default_toolchain
1 parent 501147d commit afe6341

9 files changed

Lines changed: 32 additions & 24 deletions

File tree

src/cli/rustup_mode.rs

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

896-
cfg.set_default(Some(&desc.clone().into()))?;
896+
cfg.set_default(Some(&toolchain.into()))?;
897897

898898
writeln!(cfg.process.stdout().lock())?;
899899

@@ -1091,7 +1091,7 @@ async fn update(
10911091
force_non_host,
10921092
)?;
10931093
}
1094-
let desc = name.resolve(&cfg.default_host_tuple()?)?;
1094+
let desc = name.clone().resolve(&cfg.default_host_tuple()?)?;
10951095

10961096
let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();
10971097
let targets = opts.target.iter().map(|s| &**s).collect::<Vec<_>>();
@@ -1134,7 +1134,7 @@ async fn update(
11341134
if opts.default
11351135
|| (cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed))
11361136
{
1137-
cfg.set_default(Some(&desc.into()))?;
1137+
cfg.set_default(Some(&name.into()))?;
11381138
}
11391139
}
11401140
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
@@ -284,7 +284,7 @@ impl InstallOpts<'_> {
284284

285285
check_proxy_sanity(cfg.process, components, &desc)?;
286286

287-
cfg.set_default(Some(&desc.clone().into()))?;
287+
cfg.set_default(Some(&partial_desc.into()))?;
288288
writeln!(cfg.process.stdout().lock())?;
289289
common::show_channel_update(&cfg, PackageUpdate::Toolchain(desc), Ok(status))?;
290290
}

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,18 @@ impl ResolvableLocalToolchainName {
252252
}
253253
}
254254

255+
impl From<PartialToolchainDesc> for ResolvableToolchainName {
256+
fn from(value: PartialToolchainDesc) -> Self {
257+
Self::Official(value)
258+
}
259+
}
260+
261+
impl From<CustomToolchainName> for ResolvableToolchainName {
262+
fn from(value: CustomToolchainName) -> Self {
263+
Self::Custom(value)
264+
}
265+
}
266+
255267
impl FromStr for ResolvableLocalToolchainName {
256268
type Err = InvalidName;
257269

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_inst_interactive.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,12 @@ rustup home: [RUSTUP_DIR]
781781
782782
installed toolchains
783783
--------------------
784-
beta-[HOST_TUPLE] (active, default)
784+
beta-[HOST_TUPLE]
785785
786786
active toolchain
787787
----------------
788-
name: beta-[HOST_TUPLE]
788+
name: beta-[CROSS_ARCH_I]
789789
active because: it's the default toolchain
790-
installed targets:
791-
[HOST_TUPLE]
792790
793791
"#]]);
794792
}

tests/suite/cli_rustup.rs

Lines changed: 6 additions & 8 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();
@@ -4267,7 +4267,7 @@ fn nightly_manifest_path(cx: &CliTestContext) -> PathBuf {
42674267

42684268
// https://github.com/rust-lang/rustup/issues/3651#issuecomment-5058814392
42694269
#[tokio::test]
4270-
async fn default_stores_qualified_toolchains() {
4270+
async fn default_stores_unqualified_toolchains() {
42714271
let cx = CliTestContext::new(Scenario::SimpleV2).await;
42724272
let redactions = [("[RUSTUP_DIR]", &cx.config.rustupdir.to_string())];
42734273

@@ -4315,14 +4315,12 @@ rustup home: [RUSTUP_DIR]
43154315
43164316
installed toolchains
43174317
--------------------
4318-
beta-[HOST_TUPLE] (active, default)
4318+
beta-[HOST_TUPLE]
43194319
43204320
active toolchain
43214321
----------------
4322-
name: beta-[HOST_TUPLE]
4322+
name: beta-[CROSS_ARCH_I]
43234323
active because: it's the default toolchain
4324-
installed targets:
4325-
[HOST_TUPLE]
43264324
43274325
"#]]);
43284326
}

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)