You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature(SourceId): use stable hash from rustc-stable-hash (#14917)
### What does this PR try to resolve?
This helps `-Ztrim-paths` build a stable cross-platform path for the
registry and git sources. Sources files then can be found from the same
path when debugging.
It also helps cache registry index all at once for all platforms,
for example the use case in
#14795
(despite they should use `cargo vendor` instead IMO).
Some caveats:
* Newer cargo will need to re-download files for global caches
(index files, git/registry sources).
The old cache is still kept and used when running with older cargoes.
* Absolute paths on windows iarenot really covered by the
"cross-platform" hash,
because path prefix components like `C:` are always there.
That means hashes of some sources kind,
like local registry and local path,
are not going to be real cross-platform stable.
#### Security concern
There might be hash collisions if you have two registries under the same
domain. This won't happen to crates.io, as the infra would have to
intentionally put another registry on index.crates.io to collide.
We don't consider this is an actual threat model, so we are not going to
use any cryptographically secure hash algorithm like BLAKE3.
At least, the current unstable SipHash isn't in a better situation.
We might switch to a cryptographic secure one when needed.
See also
<#13171 (comment)>
### How should we test and review this PR?
We have an FCP in
<#14795 (comment)>.
This PR implements the proposal,
The path-length concern in
<#14795 (comment)>
is automatically addressed
because we don't need cryptographically secure hash for now.
### Additional information
See more information and benchmark results in
<#14116>.
0 commit comments