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

Implement RFC 2523, #[cfg(version(..))] #71314

Merged
merged 4 commits into from
May 3, 2020
Merged

Conversation

mibac138
Copy link
Contributor

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

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 19, 2020
@petrochenkov petrochenkov self-assigned this Apr 19, 2020
@pickfire
Copy link
Contributor

As per the RFC, should not it be #[cfg(version(1.27))] rather than #[cfg(version("1.27"))]?

@mibac138
Copy link
Contributor Author

mibac138 commented Apr 20, 2020

@pickfire I did try to implement it that way but the parser was emitting an error (expected ',', found '.' whenever I specified a full verison, so 1.42.0 errors, 1.42 doesn't) and I don't know what can I do prevent that.

@pickfire
Copy link
Contributor

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.

@bors

This comment has been minimized.

@pickfire
Copy link
Contributor

@mibac138 I believe accepting 1.27.0 requires changing the parser.

@mibac138 mibac138 force-pushed the cfg-version branch 2 times, most recently from 8d1d438 to d6deea6 Compare April 24, 2020 07:38
@rust-highfive

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2020
fn bar() -> bool { true }

#[cfg(version("1.65536.2"))]
fn version_check_bug() {}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@rust-highfive

This comment has been minimized.

@petrochenkov petrochenkov added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 29, 2020
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2020
@petrochenkov
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented May 2, 2020

📌 Commit 77fb1263c7044f3b78675f76a8f1d05e73abbff7 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 2, 2020
@bors
Copy link
Contributor

bors commented May 2, 2020

☔ The latest upstream changes (presumably #69274) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 2, 2020
@mibac138
Copy link
Contributor Author

mibac138 commented May 3, 2020

Thank you @petrochenkov and @pickfire for your reviews and help! I found them helpful :)

I have rebased my PR and resolved the merge conflict.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 3, 2020

📌 Commit 8a77d1c has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 3, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2020
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
@bors bors merged commit ffe0a1c into rust-lang:master May 3, 2020
@mibac138 mibac138 deleted the cfg-version branch May 3, 2020 12:09
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 8, 2020
Adjust cfg(version) to lang team decision

See rust-lang#64796 (comment) for details

r? @petrochenkov who reviewed the original PR (rust-lang#71314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants