-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Allow boolean literals as cfg
predicates
#3695
Conversation
Also worth noting that, in addition to |
This is simple, straightforward, solves an existing problem, and has no compatibility issues. @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
the RFC should mention somewhere that the raw identifiers rustc --cfg false --check-cfg 'cfg(r#false, values(none()))' 1.rs
# ^~~~~~~~~~~ // 1.rs
#![deny(warnings)]
#[expect(unexpected_cfgs)]
mod a {
#[cfg(r#true)]
pub fn foo() {}
}
mod b {
#[cfg(r#false)]
pub fn bar() {}
}
fn main() {
b::bar()
} |
All reactions
-
👍 4 reactions
Sorry, something went wrong.
Yes please. I'm always surprised I can't do cfg(false). @rfcbot reviewed |
All reactions
-
❤️ 1 reaction
Sorry, something went wrong.
Added a note about |
All reactions
-
❤️ 2 reactions
Sorry, something went wrong.
Mentioned this in a couple of places for completeness |
All reactions
Sorry, something went wrong.
probably should also mention |
All reactions
-
👍 2 reactions
Sorry, something went wrong.
@rfcbot reviewed In particular, now that we're warning about |
All reactions
Sorry, something went wrong.
🔔 This is now entering its final comment period, as per the review above. 🔔 |
All reactions
Sorry, something went wrong.
speaking of which i suppose these are also available in |
All reactions
Sorry, something went wrong.
Would changing Cargo need a separate RFC? Currently, Cargo seems to accept these:
so changing that could maybe break code - not sure if you can pass custom |
All reactions
-
👀 1 reaction
Sorry, something went wrong.
uh oh. according to rust-lang/cargo#5313 injecting a custom |
All reactions
Sorry, something went wrong.
I'm pretty sure adding new manifest keys is not considered a breaking change. |
All reactions
Sorry, something went wrong.
Also, it's worth noting that we've introduced and gated new well-known cfg (e.g. |
All reactions
-
👍 2 reactions
Sorry, something went wrong.
I agree we should just send bad news for anyone who was using |
All reactions
-
👍 15 reactions
Sorry, something went wrong.
current situation of
I think cargo should be made to accept raw identifiers, but this is indeed really out-of-scope for this RFC. |
All reactions
Sorry, something went wrong.
Thanks for this RFC, I've wanted this for awhile! @rfcbot reviewed |
All reactions
Sorry, something went wrong.
Another future possibility that addresses the drawback: There could be an allow-by-default lint for using these, so you could |
All reactions
-
👍 2 reactions
Sorry, something went wrong.
note that lint names should be plural if they are nouns |
All reactions
-
👍 1 reaction
Sorry, something went wrong.
We discussed this in today's @rust-lang/cargo meeting. We confirmed that we generally want Cargo to implement every |
All reactions
-
👍 1 reaction
Sorry, something went wrong.
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
All reactions
-
🎉 6 reactions
Sorry, something went wrong.
Updated the name to |
All reactions
Sorry, something went wrong.
d8e55c5
to
673e6a5
Compare
The team has accepted this RFC, and it's now been merged. Thanks to @clubby789 for writing this up and pushing it forward. For further updates, follow the tracking issue: |
All reactions
-
🚀 3 reactions
Sorry, something went wrong.
Implement RFC3695 Allow boolean literals as cfg predicates This PR implements rust-lang/rfcs#3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`. r? `@nnethercote` *(or anyone with parser knowledge)* cc `@clubby789`
Implement RFC3695 Allow boolean literals as cfg predicates This PR implements rust-lang/rfcs#3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`. r? `@nnethercote` *(or anyone with parser knowledge)* cc `@clubby789`
Rollup merge of rust-lang#131034 - Urgau:cfg-true-false, r=nnethercote Implement RFC3695 Allow boolean literals as cfg predicates This PR implements rust-lang/rfcs#3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`. r? `@nnethercote` *(or anyone with parser knowledge)* cc `@clubby789`
kennytm
joshtriplett
lolbinarycat
Successfully merging this pull request may close these issues.
None yet
This RFC proposes allowing boolean literals as
cfg
predicates, e.g.cfg(true)
andcfg(false)
.Rendered
Tracking: