Skip to content

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.

@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 ( ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. Yea, that's a little awkward also due to defining inline. I went ahead and removed it.

@rustbot

This comment has been minimized.

@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
ehuss added 3 commits May 25, 2025 08:18
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.
This adds the implementation for the behavior of `cargo fix
-Zfix-edition`.
@ehuss ehuss marked this pull request as ready for review May 25, 2025 15:25
@rustbot
Copy link
Collaborator

rustbot commented May 25, 2025

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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2025
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

The implementation looks reasonable with those tests. I didn't really follow closely enough to understand whether it fits edition testing's nees, but you know better than me so 👍🏾.

Feel free to merge it with or without addressing line breaking issue.


## `fix-edition`

`-Zfix-edition` is a permanently unstable flag to assist with testing edition migrations, particularly with the use of crater. It only works with the `cargo fix` subcommand. It takes two different forms:
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to have any line wrap here, or follow https://sembr.org/?
I am forgetting what the style we currently adopt.

Choose a reason for hiding this comment

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

On the Reference and other documents we're just unwrapping now.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. Thanks for the clarification. I'll merge as-is.

@weihanglo weihanglo added this pull request to the merge queue May 26, 2025
Merged via the queue into rust-lang:master with commit 6ffc01f May 26, 2025
23 checks passed
bors added a commit to rust-lang/rust that referenced this pull request May 31, 2025
Update cargo

12 commits in 68db37499f2de8acef704c73d9031be6fbcbaee4..64a12460708cf146e16cc61f28aba5dc2463bbb4
2025-05-22 14:27:15 +0000 to 2025-05-30 18:25:08 +0000
- chore: remove HTML comments and inline guide (rust-lang/cargo#15613)
- Add .git-blame-ignore-revs (rust-lang/cargo#15612)
- refactor: cleanup for `CompileMode` (rust-lang/cargo#15608)
- refactor: separate "global" mode from CompileMode (rust-lang/cargo#15601)
- fix(doc): pass `toolchain-shared-resources` to get doc styled (rust-lang/cargo#15605)
- fix(embedded): Resolve multiple bugs in frontmatter parser (rust-lang/cargo#15573)
- chore: Upgrade schemars (rust-lang/cargo#15602)
- Update gix & socket2 (rust-lang/cargo#15600)
- Add `-Zfix-edition` (rust-lang/cargo#15596)
- chore(toml): disable `toml`'s default features, unless necessary (rust-lang/cargo#15598)
- docs(README): fix the link to the changelog in the Cargo book (rust-lang/cargo#15597)
- Add the future edition (rust-lang/cargo#15595)

r? ghost
@rustbot rustbot added this to the 1.89.0 milestone May 31, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request May 31, 2025
Update cargo

12 commits in 68db37499f2de8acef704c73d9031be6fbcbaee4..64a12460708cf146e16cc61f28aba5dc2463bbb4
2025-05-22 14:27:15 +0000 to 2025-05-30 18:25:08 +0000
- chore: remove HTML comments and inline guide (rust-lang/cargo#15613)
- Add .git-blame-ignore-revs (rust-lang/cargo#15612)
- refactor: cleanup for `CompileMode` (rust-lang/cargo#15608)
- refactor: separate "global" mode from CompileMode (rust-lang/cargo#15601)
- fix(doc): pass `toolchain-shared-resources` to get doc styled (rust-lang/cargo#15605)
- fix(embedded): Resolve multiple bugs in frontmatter parser (rust-lang/cargo#15573)
- chore: Upgrade schemars (rust-lang/cargo#15602)
- Update gix & socket2 (rust-lang/cargo#15600)
- Add `-Zfix-edition` (rust-lang/cargo#15596)
- chore(toml): disable `toml`'s default features, unless necessary (rust-lang/cargo#15598)
- docs(README): fix the link to the changelog in the Cargo book (rust-lang/cargo#15597)
- Add the future edition (rust-lang/cargo#15595)

r? ghost
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. 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.

4 participants