Skip to content
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

cargo fix --edition needs fixing for Rust 2021 #9047

Closed
2 tasks
m-ou-se opened this issue Jan 5, 2021 · 3 comments · Fixed by #9184
Closed
2 tasks

cargo fix --edition needs fixing for Rust 2021 #9047

m-ou-se opened this issue Jan 5, 2021 · 3 comments · Fixed by #9184
Labels
A-editions Area: edition-specific issues Command-fix

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Jan 5, 2021

The job of cargo fix is getting more complicated, as it will need to handle fixes between three editions instead of two.

See #8922 (comment)

  • Figure out what to do.
  • Implement that.

(To be updated later. Just filing this issue to make sure we won't lose track of this.)

@alexcrichton
Copy link
Member

From the PR linked, I think there's two questions we'll want to answer:

  • What should cargo fix --edition do if you're on the "latest edition". The latest edition may be 2018 as 2021 is in development, and it may be 2021 once it's stabilized. Currently cargo fix --edition if you're already in the 2018 edition prints an error saying you should switch to 2015.

  • What should cargo fix --edition do if you're in the 2015 edition? Should it attempt to jump directly to the 2021 edition? Or should it do everything necessary to switch to 2018, and then recommend going to 2021?

@alexcrichton
Copy link
Member

Ok we discussed this in the cargo meeting today and our conclusions were basically that cargo fix --edition would always move you into the next edition, regardless of everything else. This means if you execute cargo fix --edition and you're in 2015, it always tries to move you to 2018. If you're in 2018 and Cargo has support for 2021, then it will try to move you to 2021 (even if support is gated and/or unimplemented in rustc at the time).

This also solves the question about jumping multiple editions because we'll always be moving only one edition at a time. So I think the fix in Cargo will basically be to implement the "what is the next edition" function to return 2021 when the current edition is 2018, and then we'd fix up tests to account for that new behavior.

We also figured that the current error of "you're in the latest edition you can't fix further" can probably get turned into a warning. Additionally we may wish to review the output of the command to ensure it's clear what edition is being migrated from and which edition is being migrated to.

@ehuss
Copy link
Contributor

ehuss commented Jan 7, 2021

Another thing we discussed is to have cargo fix --edition -Zunstable-options work on 2018 to run the 2021 migration during the time that 2021 is still unstable. That should help to be able to to test it which IIUC is not currently possible.

@ehuss ehuss added A-editions Area: edition-specific issues Command-fix labels Jan 7, 2021
@bors bors closed this as completed in 8eb0e9a Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-editions Area: edition-specific issues Command-fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants