Commit Graph

76 Commits

Author SHA1 Message Date
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Eric Huss 6c69e9d95b Remove --all-targets restriction for v2 resolver migration check. 2021-03-16 11:42:01 -07:00
Eric Huss 501499c5f9 Add report if `cargo fix --edition` changes features. 2021-03-16 11:39:21 -07:00
Joshua Nelson a5720117fe Make `nightly_features_allowed` a field instead of a function
`nightly_features_allowed()` is no longer doing any work, so it can be
accessed directly. This also renames the `enable_nightly_features` field
to `nightly_features_allowed`.
2021-02-24 15:11:31 -05:00
Joshua Nelson 4b096beaed Fix `masquerade_as_nightly_cargo` in work threads
Previously, since `ENABLE_NIGHTLY_FEATURES` and
`NIGHTLY_FEATURES_ENABLED` were thread locals, reading them in any other
thread would always say nightly features were disabled. Now, they are
tied to the `Context` itself, so it is both more clear how the variables
are being set and fixes the behavior within work threads.

Note that `Context` is not thread-safe, so this passes a boolean through
to `BuildOutput::parse`.
2021-02-24 14:43:00 -05:00
Eric Huss c303213748 `cargo fix`: Remove --prepare-for option.
This was deprecated, never officially part of the stable release.
2021-02-19 14:29:45 -08:00
Eric Huss aa61976c5f Make edition transitions easier.
This attempts to centralize all the edition stuff in one place (the
`Edition` enum) so that adding a new edition or stabilizing one should
be relatively little work (and more importantly, we don't miss things).

Importantly, this changes `cargo new` to default to the latest stable.
It also changes the `cargo fix --edition-idiom` behavior to only apply
idioms for the *current* edition.
2021-02-19 14:29:44 -08: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
Mara Bos bc0c820013 Disable 2018->2021 in cargo fix for now, as 2021 lints are not ready. 2021-01-05 16:30:42 +01:00
Mara Bos a836b92e8e Use edition enum in cargo fix, and add edition 2021. 2021-01-05 16:00:46 +01:00
Eric Huss d5541331cf Some minor clippy fixes. 2020-10-22 10:40:16 -07:00
Eric Huss 5a096da9d7 Fix windows. 2020-05-13 16:24:20 -07:00
Eric Huss 62711bd385 Forbid certain macros in the codebase. 2020-05-13 16:22:51 -07:00
Eric Huss ce86e866e9 Add context to some fs errors. 2020-05-11 14:10:10 -07:00
Eric Huss e4918c45ba Remove Config from CompileOptions. 2020-03-19 15:34:12 -07:00
Eric Huss d47a9545db Use Option::as_deref 2020-03-15 18:51:38 -07:00
Jane Lusby b0351e4d87 Close the front door for clippy but open the back 2020-03-12 19:27:48 -07: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
Diogo Sousa e509851813 Fix unused configuration key warning for a few keys under `build`.
Recently cargo started to warn about configuration keys that he doesn't know
about.  However, there are a few keys under `build` that were used in a
dynamic way (`rustc`, `rustdoc`, and `rustc_wrapper`) by
`Config::maybe_get_tool()`.

Since these keys are not known to exist when `Config` is deserialized, cargo
was emitting unused warnings.

This commit makes those config keys explicit.  Note that by doing so there is a
small breaking change: before it was possible to have `build.rustc_wrapper` in
the configuration file (even though the documented key uses kebak-case), and
now that key will be ignored.  (Good thing we have warnings for unrecognized
keys!)
2019-11-10 15:18:16 +00:00
Eric Huss 91a59e6089 Fix `cargo fix` not showing colors. 2019-10-28 12:00:09 -07:00
Jane Lusby 79480cc21c remove unnecessary is wrapper struct 2019-08-04 12:34:39 -07:00
Jane Lusby f4dcb2bd97 remove clippy_hackery 2019-08-04 12:34:18 -07:00
Alex Crichton daa1bce283 Enable pipelined compilation by default
This commit enables pipelined compilation by default in Cargo now that
the requisite support has been stablized in rust-lang/rust#62766. This
involved minor updates in a number of locations here and there, but
nothing of meat has changed from the original implementation (just
tweaks to how rustc is called).
2019-07-31 14:56:24 -07:00
Jane Lusby 03feb61f75 apply the correct changes 2019-07-18 15:52:05 -07:00
Jane Lusby f3d3318f9f minor fixes 2019-07-18 13:52:28 -07:00
Jane Lusby c0c672924a missing wiring 2019-07-16 11:25:19 -07:00
Jane Lusby abd91493e0 centralize diagnostic server stuff 2019-07-16 10:52:40 -07:00
Jane Lusby 6fb65f1e4f some changes, ill clean this up in a hot sec 2019-06-26 10:45:24 -07:00
Jane Lusby d076f44d73 allow clippy path override via env variable 2019-06-25 14:46:06 -07:00
Jane Lusby ad909aca50 add warning to cargo incase clippy is missing
This is only a warning because rustup(?) already warns and is much more
verbose about how to recover from the error, so I would like to call
into the clippy-driver shim or w/e is outputting nice error messages.

But incase rustup is not available or some other shenanigans occur,
cargo will also output the warning so the error isn't a mystery.
2019-06-25 14:44:09 -07:00
Jane Lusby 65afb3f6c3 use json instead of shitty hack 2019-06-24 22:04:24 -07:00
Jane Lusby 4f64aaabc2 nailed it 2019-06-24 19:04:56 -07:00
Jane Lusby 0a943be3a6 initial attempt at argument passthrough 2019-06-24 18:53:56 -07:00
Jane Lusby c057a0665b initial working version of cargo fix --clippy 2019-06-24 16:50:07 -07:00
Eric Huss 247063c35b Update some fix comments. 2019-06-22 10:07:54 -07:00
Eric Huss dcd4999d42 Add message caching. 2019-05-20 15:22:32 -07:00
Alex Crichton 842da62afb Remove no longer needed fields in `BuildConfig`
Now the fields are just all represented as `rustc_wrapper` which
internally contains all process configuration that's later passed down
to `Rustc` as necessary.
2019-04-01 10:22:23 -07:00
Jane Lusby 47c82f05c9 remove unnecessary rustc env for cargo fix 2019-03-29 17:40:34 -07:00
Jane Lusby bccc0ee4e3 actually fix it so cargo fix kinda works with new wrapper stuff 2019-03-29 17:40:34 -07:00
Alexander Regueiro f7c91ba622
Various cosmetic improvements. 2019-02-20 10:58:27 +00:00
Dale Wijnand f5ef4939b2
Update src/cargo/ops/fix.rs
Fix typo.

Co-Authored-By: ehuss <eric@huss.org>
2019-01-03 06:53:14 -08:00
Eric Huss e6efbb1f96 Add a high-level overview of how `fix` works.
The fix code is pretty well commented, but I think it would be helpful to have an overview of how the pieces fit together.
2019-01-02 21:52:03 -08:00
bors a3a3c254bd Auto merge of #6419 - ehuss:fix-show-errors, r=alexcrichton
Display errors when `cargo fix` fails.

It can be difficult to figure out what's wrong when a user reports that `cargo fix` fails. It can be hard to figure out which suggestion caused a compile error, especially if the error is in another file/location.
2018-12-14 00:11:15 +00:00
Eric Huss 41519fbf10 cargo fix: fix targets with shared sources.
If `cargo fix` attempts to fix multiple targets concurrently that have shared
source files, it would apply fixes multiple times causing corruption of the
source code. Fix this by locking on the package path instead of the target
filename, essentially serializing all targets within a package.
2018-12-13 14:29:26 -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
Dale Wijnand 54c4214251
Remove trailing extern crate usage 2018-12-13 15:21:32 +00: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