cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Implement RFC3695: Allow boolean literals as cfg predicates

Open Urgau opened this issue 1 year ago • 3 comments

What does this PR try to resolve?

This PR implements https://github.com/rust-lang/rfcs/pull/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.2.0 has we are changing CfgExpr enum in a semver incompatible change.

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.

  • [ ] Create and link the tracking issue for the Cargo side

Urgau avatar Oct 06 '24 14:10 Urgau

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 avatar Oct 06 '24 14:10 rustbot

A more generalized search: https://github.com/search?q=%2F%28%3F-i%29cfg%5C%28.*%5Cb%28true%7Cfalse%29%5Cb%2F+language%3ATOML&type=code&ref=advsearch

epage avatar Oct 08 '24 16:10 epage

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

bors avatar Oct 08 '24 21:10 bors

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

bors avatar Oct 31 '24 21:10 bors

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

bors avatar Nov 06 '24 17:11 bors

:umbrella: The latest upstream changes (presumably ed31dad4307145f82a17eebe56a17a4d801a3382) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Nov 15 '24 20:11 bors

:umbrella: The latest upstream changes (presumably 10c255ad07766377c269058d40405bc17d79b50e) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Nov 26 '24 20:11 bors

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

Urgau avatar Dec 01 '24 10:12 Urgau

:umbrella: The latest upstream changes (possibly 081d7bac633bbc72883fb74fb4993bb1b1a2df4a) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Dec 20 '24 15:12 rustbot

Therefore this PR is blocked on enough time having passed to being able to unconditional apply to new logic.

weihanglo avatar Dec 23 '24 22:12 weihanglo

  • Do we have any discussion of “enough time” elsewhere like on Zulip?

Not that I'm aware.

I'm planning on issuing after the holidays a call-for-testing and then directly propose a T-lang stabilization. This could mean only 1 or 2 releases with the future compact warning, not sure if you (T-cargo) would be comfortable with that.

We could also wait and stabilize both at the same time, but I don't think that's required.

Urgau avatar Dec 24 '24 14:12 Urgau

:umbrella: The latest upstream changes (possibly 3a4abacae12aac2d826d169d4f77df723ae3b3b9) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Jan 09 '25 22:01 rustbot

:umbrella: The latest upstream changes (possibly 1566e4c346b1dd511492e760e9c02a12d6b1f61c) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Feb 20 '25 23:02 rustbot

We are currently having a T-lang FCP of the feature in https://github.com/rust-lang/rust/pull/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

Urgau avatar Mar 26 '25 17:03 Urgau

Thanks @Urgau for continuing to drive this!

epage avatar Mar 26 '25 18:03 epage

RFC3695 has now passed it's T-lang stabilization final comment period over at https://github.com/rust-lang/rust/pull/138632#issuecomment-2788152230

Urgau avatar Apr 09 '25 16:04 Urgau

Is this ready to go?

ehuss avatar Apr 17 '25 14:04 ehuss

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.

Urgau avatar Apr 17 '25 15:04 Urgau

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 avatar Apr 22 '25 16:04 epage