Warn on unused patches.
Adds a warning when a `[patch]` entry fails to match anything.
I've hit this several times in the past, and it always takes me
5 minutes of confusion to figure out what's wrong.
Fixes#6444
Fix metabuild compile errors with --message-format=json.
If an error occurs while compiling a metabuild target with `--message-format=json`, it would panic because it was unable to serialize `Target`. This change makes it so that it places a fake "metabuild.rs" string in the `src_path` in this situation.
I'm very unhappy with this solution, but I'm unable to think of something better. Changing `src_path` to an `Option` (or something) would break existing tools (this might break, but maybe not catastrophically?). I tried implementing something that resets the `src_path` to the correct path in the target dir after the workspace is configured, but it felt very brittle – you have to fix up after all dependencies are downloaded, and there's not a good place to ensure that happens correctly. Any alternate ideas?
This adds a `with_json_contains_unordered` to help with tests.
If an error occurs while compiling a metabuild target with
`--message-format=json`, it would panic because it was unable to serialize
`Target`. This change makes it so that it places a fake "metabuild.rs" string in
the `src_path` in this situation.
I'm very unhappy with this solution, but I'm unable to think of something
better. Changing `src_path` to an `Option` (or something) would break existing
tools. I tried implementing something that resets the `src_path` to the correct
path in the target dir after the workspace is configured, but it felt very
brittle – you have to fix up after all dependencies are downloaded, and there's
not a good way to ensure that happens correctly.
This adds a `with_json_contains_unordered` to help with tests.
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.
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.
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.
There are some very rare circumstances that can cause a double panic during
development. For example, `.with_json("")` will panic, and then the drop
will also panic.
This makes the deny(warnings) in the testsuite conditional on a new
"deny-warnings" feature, that is then enabled in CI.
Ideally I could use the (reasonably well established) CI env var (like
we do for proptests), but I don't know how to get the attribute to be
defined in terms of an env var.
Add dev-dependencies test on cargo_metadata_with_deps_and_version
Hi, this just add some test for `dev-dependencies` on metadata with some registery update for others tests `+https://github.com/rust-lang/crates.io-index` (let me know if I should do another PR), cheers
Fix built-in aliases taking arguments.
The built-in aliases weren't parsing their arguments. Change implementation to treat built-in aliases the same as user aliases.
Fixes#6381
Include executable in JSON output.
Fixes#5426
Rebase of @patriksvensson's #5517
CC @matklad
I didn't really get into the issue or the code, I just interatively rebased Patrik's branch and then massaged and cleaned up the code until the tests passed. So please double check it for code correctness, test case correctness and test case coverage.
Particularly the branch changed an if condition according to [this suggestion](https://github.com/rust-lang/cargo/pull/5517#issuecomment-388557248) by Aleksey. I rolled that back because at one point it helped fix a series of tests. But let me know if that should be included here.
ConflictStoreTrie: Faster filtered search
This is an optimization that I was thinking of doing in #6283. I did not then as this is optimizing a not particularly hot path. I wish to do it now as it is stuck in my head, and I need that head space for more important things.
This also "accidentally" fixes the [indeterminacy](https://github.com/rust-lang/cargo/pull/6283#issuecomment-443358988) introduced in #6283, by replacing the `HashMap.iter().find()` like code with `BTreeMap.iter().find()` like code. This is not strictly needed, as @alexcrichton pointed out (In most use cases the index will change between any two invocations anyway), but does make it much easier to deal with (fuzz) test cases.