Skip to content

Remove validation for custom toolchains when reading rust-toolchain.toml #4250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,7 @@ impl OverrideCfg {
.transpose()?,
}
}
ToolchainName::Custom(name) => {
if file.toolchain.targets.is_some()
|| file.toolchain.components.is_some()
|| file.toolchain.profile.is_some()
{
bail!(
"toolchain options are ignored for a custom toolchain ({})",
name
)
}
Self::Custom(name)
}
ToolchainName::Custom(name) => Self::Custom(name),
})
}

Expand Down
67 changes: 67 additions & 0 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2954,3 +2954,70 @@ async fn warn_on_duplicate_rust_toolchain_file() {
)
.await;
}

#[tokio::test]
async fn custom_toolchain_with_components_toolchains_profile_does_not_err() {
let cx = CliTestContext::new(Scenario::SimpleV2).await;

let cwd = cx.config.current_dir();
let toolchain_file = cwd.join("rust-toolchain.toml");

// install a toolchain so we can make a custom toolchain that links to it
cx.config
.expect_stderr_ok(
&[
"rustup",
"toolchain",
"install",
"nightly",
"--profile=minimal",
"--component=cargo",
],
for_host!(
"\
info: syncing channel updates for 'nightly-{0}'
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
info: downloading component 'cargo'
info: downloading component 'rustc'
info: installing component 'cargo'
info: installing component 'rustc'
info: default toolchain set to 'nightly-{0}'"
),
)
.await;

// link the toolchain
let toolchains = cx.config.rustupdir.join("toolchains");
raw::symlink_dir(
&toolchains.join(for_host!("nightly-{0}")),
&toolchains.join("my-custom"),
)
.expect("failed to symlink");

raw::write_file(
&toolchain_file,
r#"
[toolchain]
channel = "my-custom"
components = ["rustc-dev"]
targets = ["x86_64-unknown-linux-gnu"]
profile = "minimal"
"#,
)
.unwrap();

cx.config
.expect_stdout_ok(
&["rustup", "show", "active-toolchain"],
&format!("my-custom (overridden by '{0}')", toolchain_file.display(),),
)
.await;

cx.config
.expect_stdout_ok(&["rustc", "--version"], "1.3.0 (hash-nightly-2)")
.await;

cx.config
.expect_stdout_ok(&["cargo", "--version"], "1.3.0 (hash-nightly-2)")
.await;
}