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 gives an unstable error #9782

Closed
jyn514 opened this issue Aug 12, 2021 · 4 comments · Fixed by #9792
Closed

cargo fix --edition gives an unstable error #9782

jyn514 opened this issue Aug 12, 2021 · 4 comments · Fixed by #9792
Assignees
Labels
A-editions Area: edition-specific issues C-bug Category: bug Command-fix E-easy Experience: Easy

Comments

@jyn514
Copy link
Member

jyn514 commented Aug 12, 2021

Problem
I want to convert a crate in a workspace from 2015 to 2018 edition. Because another crate in the workspace already uses 2018 edition, cargo tries to convert it to 2021 and gives an error that 2021 is still unstable.

$ cargo fix --edition
    Checking boring-sys v1.1.1 (/home/jnelson/src/boring/boring-sys)
    Checking boring v1.1.6 (/home/jnelson/src/boring/boring)
error: cannot migrate boring-sys/src/lib.rs to edition 2021
Edition 2021 is unstable and not allowed in this release, consider trying the nightly release channel.
   Migrating boring/src/lib.rs from 2015 edition to 2018
error: could not compile `boring-sys`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...

Steps

  1. git clone https://github.com/cloudflare/boring/
  2. cd boring
  3. cargo fix --edition

Possible Solution(s)

Only try to migrate crates to the latest stable edition unless the user explicitly opts-in to upgrading to the unstable edition.

Notes

Output of cargo version:

cargo 1.54.0 (5ae8d74b3 2021-06-22)
@jyn514 jyn514 added the C-bug Category: bug label Aug 12, 2021
@ehuss ehuss added A-editions Area: edition-specific issues Command-fix labels Aug 12, 2021
@weihanglo
Copy link
Member

Do we have any expected behavior for opts-in to upgrading to the unstable edition? Like by running cargo +nightly fix it implies upgrading to next unstable edition. Though I am not too fond of my solution here because it's too implicit and inconsistent between stable/nightly.

@weihanglo
Copy link
Member

The alternative solution may look like this:

  • --edition <value> starts accepting values such as 2015, 2018 and 2021.
  • When using --edition without a value, simply migrate to the next stable edition.
    • For workspace, all members migrate to their own next edition accordingly.
  • When using --edition with a value, migrate to the specified edition.
    • For workspace, all members migrate to the same specified edition.
    • cargo rejects any --edition <value> that tries to downgrade to a previous edition.

Hope it's not too overkill.

@ehuss
Copy link
Contributor

ehuss commented Aug 14, 2021

I think we would prefer to avoid passing specific values to the edition flag, because it can only supporting going to the "next" edition, and I think that would introduce some unwanted complexity. Generally in this case if there are mixed editions in a workspace, it is encouraged to use -p flags to narrow which packages are selected.

I think it would be fine to change the error to a warning, and just ignore the packages that are already on the latest, stable version. That logic would go around here and I think would involve just emitting a Message::EditionAlreadyEnabled instead of an error. It might be nice for the warning to give a hint about using the nightly channel if the next edition is unstable.

Unfortunately, it is probably a little late for that, since 2021 is likely to be stabilized soon, but I think fixing that case is still worthwhile.

@ehuss ehuss added the E-easy Experience: Easy label Aug 14, 2021
@weihanglo
Copy link
Member

@rustbot claim

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 C-bug Category: bug Command-fix E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants