Skip to content

Commit ec156b4

Browse files
wesleywiserrami3l
authored andcommitted
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 ec156b4

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-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

+67
Original file line numberDiff line numberDiff line change
@@ -2954,3 +2954,70 @@ 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+
&[
2969+
"rustup",
2970+
"toolchain",
2971+
"install",
2972+
"nightly",
2973+
"--profile=minimal",
2974+
"--component=cargo",
2975+
],
2976+
for_host!(
2977+
"\
2978+
info: syncing channel updates for 'nightly-{0}'
2979+
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
2980+
info: downloading component 'cargo'
2981+
info: downloading component 'rustc'
2982+
info: installing component 'cargo'
2983+
info: installing component 'rustc'
2984+
info: default toolchain set to 'nightly-{0}'"
2985+
),
2986+
)
2987+
.await;
2988+
2989+
// link the toolchain
2990+
let toolchains = cx.config.rustupdir.join("toolchains");
2991+
raw::symlink_dir(
2992+
&toolchains.join(for_host!("nightly-{0}")),
2993+
&toolchains.join("my-custom"),
2994+
)
2995+
.expect("failed to symlink");
2996+
2997+
raw::write_file(
2998+
&toolchain_file,
2999+
r#"
3000+
[toolchain]
3001+
channel = "my-custom"
3002+
components = ["rustc-dev"]
3003+
targets = ["x86_64-unknown-linux-gnu"]
3004+
profile = "minimal"
3005+
"#,
3006+
)
3007+
.unwrap();
3008+
3009+
cx.config
3010+
.expect_stdout_ok(
3011+
&["rustup", "show", "active-toolchain"],
3012+
&format!("my-custom (overridden by '{0}')", toolchain_file.display(),),
3013+
)
3014+
.await;
3015+
3016+
cx.config
3017+
.expect_stdout_ok(&["rustc", "--version"], "1.3.0 (hash-nightly-2)")
3018+
.await;
3019+
3020+
cx.config
3021+
.expect_stdout_ok(&["cargo", "--version"], "1.3.0 (hash-nightly-2)")
3022+
.await;
3023+
}

0 commit comments

Comments
 (0)