Skip to content

Add -Zfix-edition #15596

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Add -Zfix-edition #15596

wants to merge 5 commits into from

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented May 24, 2025

This adds a new cargo fix -Zfix-edition permanently unstable flag to assist with edition migration testing, particularly with crater.

The commits and given documentation should explain how it works, but there will be forthcoming edition documentation (on the forge) once all the pieces with crater come together.

Warning

Draft as this is stacked on top of #15595

ehuss added 4 commits May 24, 2025 13:56
This adds support for the "future" edition which was added to rustc in
rust-lang/rust#137606.

To enable support for unstable editions, this introduces a new
`unstable-edition` cargo feature. The intent is that instead of having a
new feature for each edition that we reuse this feature for all new
editions. I don't see a particular reason we should have a separate one
for each edition, and this helps a bit with scalability and simplifies
some of the edition process.

This also includes a change to rework `supports_compat_lint` explained
in the comment.
This factors out the code to reload a workspace since I will be needing
to reuse this elsewhere.

There is some risk with this method not getting updated correctly in the
future as new fields are added to Workspace (and it may be missing some
things now), but that is an issue with the existing code.
This adds support for parsing the `-Zfix-edition` flag.
This adds the `EditionFixMode` enum to control the behavior of
`cargo fix --edition`. The main intent is to provide a way to force
`cargo fix` to migrate to a specific edition, instead of just going to
the "next".

This will be needed for `-Zfix-edition` in order to force it to use the
"future" edition, which is never the "next" edition.

This requires being able to serialize and deserialize this setting as it
is conveyed through an environment variable to the recursive cargo
invocation.
@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces Command-fix labels May 24, 2025
@ehuss ehuss changed the title Fix edition Add -Zfix-edition May 24, 2025
@ehuss ehuss force-pushed the fix-edition branch 2 times, most recently from 08b0aa2 to 9617f3b Compare May 24, 2025 22:33
@rustbot rustbot added the A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. label May 24, 2025
[package]
name = "foo"
edition = "future"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

I can't tell, is the trailing whitespace on this line intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's just an artifact of how the str! macro works (which handles automatic updates). There isn't a blank line here.

Copy link

@traviscross traviscross May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be the same answer, but just in case it was ambiguous, what stood out here wasn't the blank line, but that (unlike the blank lines above) the line contains 12 space characters ( ).

This adds the implementation for the behavior of `cargo fix
-Zfix-edition`.
@rustbot
Copy link
Collaborator

rustbot commented May 25, 2025

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

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces Command-fix S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants