Skip to content

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

Merged
merged 3 commits into from
Apr 22, 2025

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Oct 6, 2024

What does this PR try to resolve?

This PR implements rust-lang/rfcs#3695: allow boolean literals as cfg predicates, i.e. cfg(true) and cfg(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>)'] in Cargo.toml/.cargo/config.toml.

Additional information

I had to bump cargo-platform to 0.3.0 has we are changing CfgExpr 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 a Cargo.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) for cfg(true) and cfg(false), I choose to gate the feature under a error and not a warning.

@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2024

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cfg-expr Area: Platform cfg expressions A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 6, 2024
@epage
Copy link
Contributor

epage commented Oct 8, 2024

@bors
Copy link
Contributor

bors commented Oct 8, 2024

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

@bors
Copy link
Contributor

bors commented Oct 31, 2024

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

@bors
Copy link
Contributor

bors commented Nov 6, 2024

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

@bors
Copy link
Contributor

bors commented Nov 15, 2024

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

github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2024
…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
@bors
Copy link
Contributor

bors commented Nov 26, 2024

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

@Urgau
Copy link
Member Author

Urgau commented Dec 1, 2024

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

@rustbot rustbot added S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2024
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@Urgau
Copy link
Member Author

Urgau commented Mar 26, 2025

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. A-unstable Area: nightly unstable support labels Mar 26, 2025
@epage
Copy link
Contributor

epage commented Mar 26, 2025

Thanks @Urgau for continuing to drive this!

@Urgau
Copy link
Member Author

Urgau commented Apr 9, 2025

RFC3695 has now passed it's T-lang stabilization final comment period over at rust-lang/rust#138632 (comment)

@ehuss
Copy link
Contributor

ehuss commented Apr 17, 2025

Is this ready to go?

@Urgau
Copy link
Member Author

Urgau commented Apr 17, 2025

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.

@epage
Copy link
Contributor

epage commented Apr 22, 2025

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.

@epage epage enabled auto-merge April 22, 2025 17:30
@epage epage added this pull request to the merge queue Apr 22, 2025
Merged via the queue into rust-lang:master with commit 69eeb6a Apr 22, 2025
25 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 27, 2025
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
@rustbot rustbot added this to the 1.88.0 milestone Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cfg-expr Area: Platform cfg expressions A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants