-
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()
} |
Yes please. I'm always surprised I can't do cfg(false). @rfcbot reviewed |
Added a note about |
Mentioned this in a couple of places for completeness |
probably should also mention |
@rfcbot reviewed In particular, now that we're warning about |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
speaking of which i suppose these are also available in |
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 |
uh oh. according to rust-lang/cargo#5313 injecting a custom |
I'm pretty sure adding new manifest keys is not considered a breaking change. |
Also, it's worth noting that we've introduced and gated new well-known cfg (e.g. |
I agree we should just send bad news for anyone who was using |
current situation of
I think cargo should be made to accept raw identifiers, but this is indeed really out-of-scope for this RFC. |
Thanks for this RFC, I've wanted this for awhile! @rfcbot reviewed |
Another future possibility that addresses the drawback: There could be an allow-by-default lint for using these, so you could |
note that lint names should be plural if they are nouns |
We discussed this in today's @rust-lang/cargo meeting. We confirmed that we generally want Cargo to implement every |
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. |
Updated the name to |
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: |
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`
This RFC proposes allowing boolean literals as
cfg
predicates, e.g.cfg(true)
andcfg(false)
.Rendered
Tracking: