Skip to content

Commit e0a8a6b

Browse files
committed
Remove validation for custom toolchains when reading rust-toolchain.toml
This validation was introduced in e1306b3 However, it breaks a number of scenarios that previously worked without issue such as #4248. As requested by rustup maintainers in that thread, I'm taking out the extra validation added in that commit, leaving the rest of the code as-is. Testing confirms this fixes #4248.
1 parent 7588311 commit e0a8a6b

File tree

2 files changed

+66
-12
lines changed

2 files changed

+66
-12
lines changed

Diff for: src/config.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,7 @@ impl OverrideCfg {
181181
.transpose()?,
182182
}
183183
}
184-
ToolchainName::Custom(name) => {
185-
if file.toolchain.targets.is_some()
186-
|| file.toolchain.components.is_some()
187-
|| file.toolchain.profile.is_some()
188-
{
189-
bail!(
190-
"toolchain options are ignored for a custom toolchain ({})",
191-
name
192-
)
193-
}
194-
Self::Custom(name)
195-
}
184+
ToolchainName::Custom(name) => Self::Custom(name),
196185
})
197186
}
198187

Diff for: tests/suite/cli_rustup.rs

+65
Original file line numberDiff line numberDiff line change
@@ -2954,3 +2954,68 @@ async fn warn_on_duplicate_rust_toolchain_file() {
29542954
)
29552955
.await;
29562956
}
2957+
2958+
#[tokio::test]
2959+
async fn custom_toolchain_with_components_toolchains_profile_does_not_err() {
2960+
let cx = CliTestContext::new(Scenario::SimpleV2).await;
2961+
2962+
let cwd = cx.config.current_dir();
2963+
let toolchain_file = cwd.join("rust-toolchain.toml");
2964+
2965+
// install a toolchain so we can make a custom toolchain that links to it
2966+
cx.config
2967+
.expect_stderr_ok(
2968+
&["rustup", "toolchain", "install", "nightly"],
2969+
&format!(
2970+
"\
2971+
info: syncing channel updates for 'nightly-{0}'
2972+
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
2973+
info: downloading component 'cargo'
2974+
info: downloading component 'rust-docs'
2975+
info: downloading component 'rust-std'
2976+
info: downloading component 'rustc'
2977+
info: installing component 'cargo'
2978+
info: installing component 'rust-docs'
2979+
info: installing component 'rust-std'
2980+
info: installing component 'rustc'
2981+
info: default toolchain set to 'nightly-{0}'",
2982+
this_host_triple(),
2983+
),
2984+
)
2985+
.await;
2986+
2987+
// link the toolchain
2988+
let toolchains = cx.config.rustupdir.join("toolchains");
2989+
raw::symlink_dir(
2990+
&toolchains.join(&format!("nightly-{}", this_host_triple())),
2991+
&toolchains.join("my-custom"),
2992+
)
2993+
.expect("failed to symlink");
2994+
2995+
raw::write_file(
2996+
&toolchain_file,
2997+
r#"
2998+
[toolchain]
2999+
channel = "my-custom"
3000+
components = ["rustc-dev"]
3001+
targets = ["x86_64-unknown-linux-gnu"]
3002+
profile = "minimal"
3003+
"#,
3004+
)
3005+
.unwrap();
3006+
3007+
cx.config
3008+
.expect_stdout_ok(
3009+
&["rustup", "show", "active-toolchain"],
3010+
&format!("my-custom (overridden by '{0}')", toolchain_file.display(),),
3011+
)
3012+
.await;
3013+
3014+
cx.config
3015+
.expect_stdout_ok(&["rustc", "--version"], &"1.3.0 (hash-nightly-2)")
3016+
.await;
3017+
3018+
cx.config
3019+
.expect_stdout_ok(&["cargo", "--version"], &"1.3.0 (hash-nightly-2)")
3020+
.await;
3021+
}

0 commit comments

Comments
 (0)