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.
Allow user aliases to override built-in aliases
This PR allows user-defined aliases take precedence over built-in ones, with a warning that tells there exists a built-in alias.
This PR does not allow user aliases override built-in subcommands.
```console
$ cat .cargo/config
[alias]
b = "fetch"
build = "fetch"
$ ./target/debug/cargo b
warning: user-defined alias `b` overrides a built-in alias for `build`
$ ./target/debug/cargo build
warning: user-defined alias `build` is ignored, because it is shadowed by a built-in command
Compiling proc-macro2 v0.4.19
Compiling unicode-xid v0.1.0
Compiling cc v1.0.25
(snip)
```
In the current version of Cargo, user aliases cannot override built-in aliases.
This behavior is keeping us from safely adding new built-in aliases without interfering existing user config.
Merging this PR will allow that.
Fixes#6221
Relating to #6218
Fix renaming directory project using build scripts with cross-compiling.
The rename-protection introduced in #4818 checks for paths with a prefix of `/…/target/debug`, but this does not work for paths used during cross-compiling.
This change checks for paths with the full `OUT_DIR` prefix, and the `build/PKG/root-output` file now includes that full `OUT_DIR` instead of `/…/target/debug`.
This also includes a few other changes:
- Support fixing KIND=PATH style paths.
- Support fixing paths in metadata (like `cargo:root=…` or `cargo:include=…` which are common).
- Adds a "version" value to the metadata hash to ensure that cargo doesn't get confused with the new `root-output` file format.
Fixes#6177
Stabilize the `rename-dependency` feature
This commit stabilizes Cargo's `rename-dependency` feature which allows
renaming packages in `Cargo.toml`, enabling importing multiple versions
of a single crate or simply avoiding a `use foo as bar` in `src/lib.rs`.
Closes#5653
Use "test" profile for `cargo build` benchmarks.
When using `cargo build` (without `--release`), build benchmarks using the "test" profile. This was causing some confusion where the benchmark is placed in the `target/debug` directory, and also causing some duplicates that may not be expected. It also makes it easier to debug benchmarks (previously you had to edit the `[profile.bench]` profile).
Closes#5575, closes#6301, closes#4240, closes#4929.
fix: Don't back out changes with `--broken-code`
This commit updates the behavior of `cargo fix` when the `--broken-code`
flag is passed to Cargo. Previously Cargo would always back out
automatically applied changes to files whenever the fixed code failed to
compile. Now, with the `--broken-code` flag, fixed code is left as-is.
This means that if the fixed code can be more easily inspected by
humans to detect bugs and such.
The main use case intended here is that if you're working with a large
code base then lints like the edition idiom lints aren't 100% finished
yet to work as smoothly as `cargo fix`. The idiom lints are often
useful, however, to transition code to be idiomatic (who would have
guessed!) in the new edition.
To ease the experience of using not-quite-ready lints this flag can be
used to hopefully "fix 90% of lint warnings" and then the remaining
compiler errors can be sifted through manually. The intention is that we
have edition documentation indicating this workflow which also
encourages filing bugs for anything that fails to fix, and hopefully
this new behavior will make it easier for us to narrow down what the
minimal test case is too!
This commit updates the behavior of `cargo fix` when the `--broken-code`
flag is passed to Cargo. Previously Cargo would always back out
automatically applied changes to files whenever the fixed code failed to
compile. Now, with the `--broken-code` flag, fixed code is left as-is.
This means that if the fixed code can be more easily inspected by
humans to detect bugs and such.
The main use case intended here is that if you're working with a large
code base then lints like the edition idiom lints aren't 100% finished
yet to work as smoothly as `cargo fix`. The idiom lints are often
useful, however, to transition code to be idiomatic (who would have
guessed!) in the new edition.
To ease the experience of using not-quite-ready lints this flag can be
used to hopefully "fix 90% of lint warnings" and then the remaining
compiler errors can be sifted through manually. The intention is that we
have edition documentation indicating this workflow which also
encourages filing bugs for anything that fails to fix, and hopefully
this new behavior will make it easier for us to narrow down what the
minimal test case is too!
This commit stabilizes Cargo's `rename-dependency` feature which allows
renaming packages in `Cargo.toml`, enabling importing multiple versions
of a single crate or simply avoiding a `use foo as bar` in `src/lib.rs`.
Closes#5653
Don't hardlink rmeta files.
`.rmeta` files shouldn't be needed in the main directory, and since rustc started outputing rmeta files for binaries, there are name collisions between bins and libs of the same name.
Partial fix for #5524.