Commit Graph

28 Commits

Author SHA1 Message Date
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Eric Huss 28850225a1 Updates to `cargo fix --edition`.
* `--edition` always means "next" edition.
* `--edition` when on the most recent edition is not an error, just a warning.
* Support fix to 2021 edition.
2021-02-17 22:12:46 -08:00
Eric Huss 3f2f7e30ff Add a migrating message for `cargo fix --edition`.
This helps indicate which edition you are moving from and to.
2021-02-17 21:36:28 -08:00
Eric Huss 820537c706 Change Fixing to Fixed, and add a verbose "Fixing".
What was previously "Fixing" was a message for after the fixes had
been applied. I think it would be clearer if it said "Fixed",
to indicate that the fixes had actually finished.

The new "Fixing" is posted just before it starts. This is verbose-only
since it is a little noisy.
2021-02-17 20:41:38 -08:00
Eric Huss b3d865e11c Some minor refactoring of `fix` code.
There shouldn't be any functional changes here.

* Some doc comments.
* Construct `FixArgs` at once so it doesn't need to bother with unnecessary Options.
* Remove IdiomEditionMismatch, it is not used.
* Use a general deduping mechanism for fix messages.
2021-02-17 20:11:15 -08:00
Alex Crichton 3a18c89a55 Migrate from the `failure` crate to `anyhow`
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
Eric Huss a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Eric Huss 8e8a9041df Fix links to the permanent home of the edition guide. 2019-02-27 21:52:33 -08:00
Alex Crichton 1fc4ba845c Report fix bugs to Rust instead of Cargo
I originally opted to report bugs to Cargo instead of Rust because I was
afraid of the implementation of `cargo fix` itself. These seem to all be
weeded out now (largely at least), and the overwhelming majority of bugs
are now rust-lang/rust suggestion bugs. Let's suggest reporting bugs
directly there!
2019-01-09 09:42:28 -08:00
Eric Huss 7584dced28 Fix a very minor race condition in `cargo fix`. 2019-01-02 21:46:14 -08:00
Eric Huss fffb05d8fc Display errors when `cargo fix` fails.
It can be difficult to figure out what's wrong when a user reports that
`cargo fix` fails. There's often a large list of warnings, and it can
be hard to figure out which one caused a compile error.
2018-12-13 13:59:06 -08:00
Alex Crichton b8b7faee50 Run `cargo fix --edition-idioms` and fixup output
This gets Cargo passing the `--edition-idioms` lints and more down the
road of the 2018 edition!
2018-12-11 05:45:46 -08:00
Alex Crichton 9ed82b5779 Start using 2018 idioms in Cargo
Remove a number of `extern crate` directives and tweak a number of
imports. Not all `extern crate` is gone yet but this is the bulk of
them!
2018-12-11 05:45:46 -08:00
Alex Crichton fecb724643 Format with `cargo fmt` 2018-12-08 03:19:47 -08:00
Dale Wijnand 04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Diogo Sousa 53421f9ce6 Fix urls for the edition guide. 2018-09-21 17:34:34 +01:00
Dale Wijnand 1ecd081e85
Finish removing PreviewNotFound 2018-09-18 22:05:04 +01:00
Diogo Sousa 6c774e7d17 Fix broken url in diagnostic. 2018-08-16 22:50:10 +01:00
Light Ning 5ae43e0086
Update transitioning url 2018-08-14 11:20:12 +08:00
Matthias Krüger 8798bf0d28 fix a bunch of clippy warnings (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
Special thanks to dwijnand for helping me with this! :)
2018-08-12 10:00:12 +02:00
bors dd97d5a065 Auto merge of #5857 - matthiaskrgr:borrowck_mut, r=alexcrichton
fix borrowck-migrate unused mut warnings.
2018-08-02 20:55:07 +00:00
Matthias Krüger 90d0b120be fix borrowck-migrate unused mut warnings. 2018-08-02 22:34:55 +02:00
Alex Crichton 80f9d318d5 Add a `--edition-idioms` flag to `cargo fix`
This, like `--prepare-for`, will be part of the transition guide which
automatically applies the necessary lint group from the compiler to associated
code.

The `--edition-idioms` flag does not take an argument and will automatically
enable the right lint group based on the edition being compiled for.

cc #52679
2018-08-02 09:19:35 -07:00
Alex Crichton 876a50366b fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes #5813
Closes rust-lang/rust#52754
2018-07-31 14:20:58 -07:00
Alex Crichton fa7a387740 Add more diagnostics to smooth edition transition
This commit adds two diagnostics in particular to ease the transition into the
2018 edition. The current transition process is pretty particular and must be
done carefully, so let's try to automate things to make it as painless as
possible! Notably the new diagnostics are:

* If you `cargo fix --prepare-for 2018` a crate which already has the 2018
  edition enabled, then an error is generated. This is because the compiler
  can't prepare for the 2018 edition if you're already in the 2018 edition, the
  lints won't have a chance to fire. You can only execute `--prepare-for 2018`
  over crates in the 2015 edition.

* If you `cargo fix --prepare-for 2018` and have forgotten the
  `rust_2018_preview` feature, a warning is issued. The lints don't fire unless
  the feature is enabled, so this is intended to warn in this situation to
  ensure that lints fire as much as they can.

After this commit if `cargo fix --prepare-for` exits successfully with zero
warnings then crates should be guaranteed to be compatible!

Closes #5778
2018-07-31 07:28:07 -07:00
Alex Crichton 32a28883a5 Fix a formatting of a cargo fix message 2018-07-23 15:00:28 -07:00
Eh2406 385b54b38f a large number of clippy suggestions 2018-07-21 18:55:14 -04:00
Alex Crichton b02ba3771e Import `cargo fix` directly in to Cargo
This commit imports the `cargo fix` subcommand in rust-lang-nursery/rustfix
directly into Cargo as a subcommand. This should allow us to ease our
distribution story of `cargo fix` as we prepare for the upcoming 2018 edition
release.

It's been attempted here to make the code as idiomatic as possible for Cargo's
own codebase. Additionally all tests from cargo-fix were imported into Cargo's
test suite as well. After this lands and is published in nightly the `cargo-fix`
command in rust-lang-nursery/rustfix will likely be removed.

cc rust-lang/rust#52272
2018-07-16 21:58:58 -07:00