-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement RFC3695: Allow boolean literals as cfg predicates #14649
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
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
☔ The latest upstream changes (presumably #14137) made this pull request unmergeable. Please resolve the merge conflicts. |
6bc170b
to
756003f
Compare
☔ The latest upstream changes (presumably #14752) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #14497) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably ed31dad) made this pull request unmergeable. Please resolve the merge conflicts. |
a7294ad
to
e358842
Compare
…ts (#14671) ### What does this PR try to resolve? This PR tries to address this thread #14649 (comment) in #14649 regarding `cfg(true)`/`cfg(false)` (and keywords more generally) which are wrongly accepted[^1] as ident. To address this, this PR does two things: 1. it introduce a future-incompatibility warning against those (wrongly) accepted keywords as ident 2. it add parsing for raw-idents (`r#true`) add suggest-it in the warning ### How should we test and review this PR? This PR should be reviewed commit-by-commit. Tests are included in preliminary commits. ### Additional information I added a new struct for representing `Ident`s which is rawness aware. Which implied updating `cargo-platform` to `0.2.0` due to the API changes. r? @epage [^1]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ccfb9c894dbf14e791c8ae7e4798efd0
☔ The latest upstream changes (presumably 10c255a) made this pull request unmergeable. Please resolve the merge conflicts. |
The future incompatibility warning was merged in #14671. I tried adding an unstable Cargo feature but that would I mean either making not insignificant refactor to the parsing or evaluation, or adding a hack to transform back, neither felt justified enough for such a temporary mechanism. Therefore this PR is blocked on enough time having passed to being able to unconditional apply to new logic. @rustbot label -S-waiting-on-review +S-blocked-external |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
52d7027
to
d1d013f
Compare
We are currently having a T-lang FCP of the feature in rust-lang/rust#138632 (with 5/5 check-boxes). I'm expecting it to land in 1.88 (it branches at the end of this week), this should let a full release cycle for T-cargo to decide to land this at the same time. The future incompatibility warning landed in 1.85 so it would be 3 release cycles with the warning. @rustbot labels -S-blocked-external -S-waiting-on-author -A-unstable +S-waiting-on-review |
Thanks @Urgau for continuing to drive this! |
RFC3695 has now passed it's T-lang stabilization final comment period over at rust-lang/rust#138632 (comment) |
Is this ready to go? |
From my side yes, I don't know if you also want to do an FCP or if you consider the T-lang FCP to be enough, but either way the changes in this PR are at minimum ready for review. |
Thanks for driving this! We aren't holding our own FCP, relying on the T-compiler FCP Once the test is cleaned up, this should be good to merge on our side. |
Update cargo 10 commits in d811228b14ae2707323f37346aee3f4147e247e6..7918c7eb59614c39f1c4e27e99d557720976bdd7 2025-04-15 15:18:42 +0000 to 2025-04-27 09:44:23 +0000 - overriding-dependencies.md: better readability (rust-lang/cargo#15459) - source-replacement.md: fix typo (rust-lang/cargo#15458) - Stabilize automatic garbage collection. (rust-lang/cargo#14287) - Update doctest xcompile flags (rust-lang/cargo#15455) - fix: Suggest similar looking feature names when feature is missing (rust-lang/cargo#15454) - fix(unit-graph): switch to Package ID Spec (rust-lang/cargo#15447) - chore(deps): update cargo-semver-checks to v0.41.0 (rust-lang/cargo#15446) - Implement RFC3695: Allow boolean literals as cfg predicates (rust-lang/cargo#14649) - chore: remove duplicate word in comment (rust-lang/cargo#15437) - Fix formatting of CliUnstable parsing (rust-lang/cargo#15434) r? ghost
What does this PR try to resolve?
This PR implements rust-lang/rfcs#3695: allow boolean literals as cfg predicates, i.e.
cfg(true)
andcfg(false)
.How should we test and review this PR?
The PR should be reviewed commit by commit and tested by looking at the tests and using
[target.'cfg(<true/false>)']
inCargo.toml
/.cargo/config.toml
.Additional information
I had to bump
cargo-platform
to0.3.0
has we are changingCfgExpr
enum in a semver incompatible change.We currently have (thks to #14671) a forward compatibility warning against
cfg(true/false)
as identifiers instead of keywords.I choose a use aCargo.toml
feature (for the manifest) as well as a unstable CLI flag for the.cargo/config.toml
part.Given the very small (two occurrences on Github Search) forcfg(true)
andcfg(false)
, I choose to gate the feature under a error and not a warning.