-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement RFC 2523, #[cfg(version(..))]
#71314
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
As per the RFC, should not it be |
@pickfire I did try to implement it that way but the parser was emitting an error ( |
I think that is because it is not a valid integer to be parsed. It could be a float with 1.27 but not 1.27.0 which means nothing. Maybe we should ask around, I am not quite sure on the rust internals. |
This comment has been minimized.
This comment has been minimized.
@mibac138 I believe accepting |
8d1d438
to
d6deea6
Compare
This comment has been minimized.
This comment has been minimized.
fn bar() -> bool { true } | ||
|
||
#[cfg(version("1.65536.2"))] | ||
fn version_check_bug() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, do we need this? Or maybe we can try another crate semver
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this it's unlikely for anyone to run into this, but I wanted to explicitly document this problem. I have thought about using semver
, however if I were to use semver::Version
I'd need to make sure the version contains major, minor and patch versions, and if I were to use semver::VersionReq
I'd need to check if the version literal doesn't contain things like >=1.0
, <1.5
, >1.2, <1.3
which the RFC only mentions as possible future work (However, as a first iteration, version(1.27.0) is simple and covers most use cases.
). Unless it's okay to implement this using VersionReq
and adding support for >
, <
, etc. syntax I think it's simpler to just use version_check
despite this bug which I believe is unlikely to affect anyone.
This comment has been minimized.
This comment has been minimized.
Thanks! |
📌 Commit 77fb1263c7044f3b78675f76a8f1d05e73abbff7 has been approved by |
☔ The latest upstream changes (presumably #69274) made this pull request unmergeable. Please resolve the merge conflicts. |
Thank you @petrochenkov and @pickfire for your reviews and help! I found them helpful :) I have rebased my PR and resolved the merge conflict. |
@bors r+ |
📌 Commit 8a77d1c has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#71165 (`slice::fill`: use `T` instead of generic arg) - rust-lang#71314 (Implement RFC 2523, `#[cfg(version(..))]`) - rust-lang#71542 (Implement `confusable_idents` lint.) - rust-lang#71806 (typo) - rust-lang#71813 (Decode qualifs for associated const defaults) Failed merges: r? @ghost
Adjust cfg(version) to lang team decision See rust-lang#64796 (comment) for details r? @petrochenkov who reviewed the original PR (rust-lang#71314)
Hi! This is my first contribution to rust, I hope I didn't miss anything. I tried to implement this feature so that
#[cfg(version(1.44.0))]
works but the parser was printing an error that I wasn't sure how to fix so I just opted for implementing#[cfg(version("1.44.0"))]
(note the quotes).Tracking issue: #64796