Auto merge of #11044 - Eh2406:file_hash, r=weihanglo
Auto merge of #11044 - Eh2406:file_hash, r=weihanglo

Cache index files based on contents hash

Since #10507 Cargo has known how to read registry cached files whose index version starts with the hash of the file contents. Git makes it very cheap to determine the hash of a file. This PR switches cargo to start writing the new format.

Cargoes from before #10507 will not know how to read, and therefore overwrite, cached files written by Cargos after this PR.

Cargos after this PR can still read, and will consider up-to-date cached files written by all older Cargos.

As I'm writing this out I'm thinking that there may not be any point in writing a file that has both. An alternative implementation just writes the file contents hash. 🤔

eminence/cargo,rustyhorde/cargo,rust-lang/cargo,eminence/cargo,rustyhorde/cargo,rust-lang/cargo,rustyhorde/cargo,rust-lang/cargo,eminence/cargo,rust-lang/cargo,eminence/cargo,rustyhorde/cargo