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.
Rename `Kind` to `CompileKind` to reflect that it's intended for
compilation. Additionally change the `Target` variant to have a newtype
`CompileTarget` instead of just being a raw string. This new
`CompileTarget` type has a fallible constructor and handles custom json
target files internally.
Two accessors are available for `CompileTarget`, one is `rustc_target()`
which goes straight to rustc and everything else uses `short_name()`
which is the raw target or file stem for json files. The `short_name` is
used everywhere in Cargo for all purposes like configuration, env vars,
target directory naming, etc.
This commit starts to intern `Unit` structures for a few reasons:
* This primarily makes equality and hashing much faster. We have tons of
hash lookups with units, and they were showing up quite high
in profiles. It turns out `Unit` hashes a *ton* of data, and most of
it is always redundant. To handle this they're all only hashed once
now and hashing/equality are just pointer checks.
* The size of `Unit` is now drastically reduced to just one pointer, so
movement of units throughout the backend should be much more
efficient.
With 'cargo build --build-plan', cargo does not actually run any
commands, but instead prints out what it would have done in the form of
a JSON data structure.
Fixes#3815