Skip to content
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

Let toolchain describe a minimal supported rust version #594

Closed
1 task done
WorldSEnder opened this issue Oct 6, 2021 · 1 comment · Fixed by #595
Closed
1 task done

Let toolchain describe a minimal supported rust version #594

WorldSEnder opened this issue Oct 6, 2021 · 1 comment · Fixed by #595
Assignees
Milestone

Comments

@WorldSEnder
Copy link
Contributor

WorldSEnder commented Oct 6, 2021

Feature Description

[tasks.rustc-version-stable]
toolchain = "1.56" # required because we're using edition 2021

Unfortunately, by the time 1.57 stabilizes, the above will suddenly complain to devs using the latest stable release.

Describe The Solution You'd Like

Support a version check for the toolchain. Multiple syntaxes come to mind:

[tasks.rustc-version-stable]
toolchain = ">= 1.56"
toolchain = "stable >= 1.56"
toolchain = { channel = "stable", version = ">= 1.56" }
toolchain = { channel = "stable", feature = ["edition_2021"] } # optional, but most specific and declarative

The first two could perhaps be a short version of the second.

The last is probably too much to ask, but could use names from specific RFCs. Just don't know how to get rustc to tell me which ones are supported, and maintaining that list here is not such a good idea?


  • I am willing to implement this in a PR

It seems parsing the output of rustc --version is already done in rust_info, so perhaps it could be a good idea to reuse that and put it into the public interface there?

fn has_toolchain(toolchain: &str) -> bool {
Command::new("rustup")
.args(&["run", toolchain, "rustc"])
.stderr(Stdio::null())
.stdout(Stdio::null())
.status()
.expect("Failed to check rustup toolchain")
.success()
}

would then parse the output of --version additionally to checking succeeding and do the version comparison.


For a real world example, consider https://github.com/yewstack/yew/blob/master/packages/yew-macro/Makefile.toml#L1-L5 which sets toolchain = "1.51", to enforce support of const_generics. Changing this to toolchain = ">= 1.51" would run into less problems.

@sagiegurari
Copy link
Owner

thanks a lot for the idea.
how about:

[tasks.rustc-version-stable]
toolchain = { channel = "stable", min_version = "1.56" }

this way

  • we don't need to parse the version
  • we are consistent with install_crate attribute which has min_version as well. so better do the same everywhere.

this sounds like a good approach and if you want implement the PR that would be great.

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

Successfully merging a pull request may close this issue.

2 participants