Skip to content

Do not allow none as custom toolchain name#3174

Closed
ashutoshvarma wants to merge 1 commit intorust-lang:masterfrom
ashutoshvarma:feat/no-none-custom-toolchain-name
Closed

Do not allow none as custom toolchain name#3174
ashutoshvarma wants to merge 1 commit intorust-lang:masterfrom
ashutoshvarma:feat/no-none-custom-toolchain-name

Conversation

@ashutoshvarma
Copy link

Fix #3130

Throws when none is used for custom toolchain name.

Copy link
Member

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

impl<'a> CustomToolchain<'a> {
pub fn new(toolchain: &'a Toolchain<'a>) -> Result<CustomToolchain<'a>> {
if toolchain.is_custom() {
if toolchain.is_custom() && toolchain.name() != "none" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rbtcollins Do you think we need to move this special name into is_custom_name fn? Or we can just determine it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not a custom name, right? the whole point is that we're not allowing it as a name for custom toolchains.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not a custom name, right?

Actually, in the current is_custom_name fn we treat it as a custom name.

ToolchainDesc::from_str(name).is_err()

So it's more like a special case and probably we can put it into is_custom_name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @hi-rustin that this is perhaps the wrong place.

A quick look at the code shows that we haven't integrated the "none" value of a toolchain systematically into the code. We shouldn't need to patch it here and there and everywhere.

We have things like resolve_toolchain(&name) that might be a decent place to flat out prohibit 'none' as a toolchain name, irrespective of custom-or-not

@0xPoe 0xPoe requested a review from jyn514 January 18, 2023 15:19
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me; I think if you prevent creating a toolchain with this name that's enough and you don't need to also change other parts of rustup. In fact I would prefer not to for compatibility with people who happened to already have this name in an old version of rustup and then upgraded their install.

expect_ok(config, &["rustup", "update", "nightly"]);
expect_ok(config, &["rustup", "default", "nightly"]);
expect_stdout_ok(config, &["rustup", "show"], "custom");
// should not allow 'none' for custom toolchain name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make this a separate test? Thanks!

impl<'a> CustomToolchain<'a> {
pub fn new(toolchain: &'a Toolchain<'a>) -> Result<CustomToolchain<'a>> {
if toolchain.is_custom() {
if toolchain.is_custom() && toolchain.name() != "none" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @hi-rustin that this is perhaps the wrong place.

A quick look at the code shows that we haven't integrated the "none" value of a toolchain systematically into the code. We shouldn't need to patch it here and there and everywhere.

We have things like resolve_toolchain(&name) that might be a decent place to flat out prohibit 'none' as a toolchain name, irrespective of custom-or-not

@rbtcollins
Copy link
Contributor

I have a large refactoring of our toolchain name handling that will obsolete this.

@rbtcollins
Copy link
Contributor

See #3340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustup allows rustup toolchain link none

4 participants