Skip to content

Commit a87c4e0

Browse files
committed
Account for Cargo's new hashing algorithm
See: rust-lang/cargo#14917
1 parent 0977ac5 commit a87c4e0

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ predicates = "3.1"
4646
regex = "1.11"
4747
rewriter = "0.1"
4848
rust-embed = "8.5"
49+
rustc-stable-hash = "0.1"
4950
rustversion = "1.0"
5051
semver = "1.0"
5152
serde = "1.0"

dylint/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if_chain = { workspace = true, optional = true }
2828
log = { workspace = true }
2929
once_cell = { workspace = true }
3030
rewriter = { workspace = true, optional = true }
31+
rustc-stable-hash = { workspace = true, optional = true }
3132
semver = { workspace = true }
3233
serde = { workspace = true }
3334
serde-untagged = { workspace = true, optional = true }
@@ -84,6 +85,7 @@ __cargo_cli = [
8485
"glob",
8586
"hex",
8687
"if_chain",
88+
"rustc-stable-hash",
8789
"serde-untagged",
8890
"toml",
8991
"url",
@@ -105,6 +107,6 @@ workspace = true
105107

106108
# smoelius: When both `__cargo_cli` and `__cargo_lib` are enabled, we treat it as though
107109
# `--features=cargo-lib` was passed but the user forgot to pass `--no-default-features`. This
108-
# approach causes `fs_extra` to look like an unused dependency.
110+
# approach causes `fs_extra` and `rustc-stable-hash` to look like unused dependencies.
109111
[package.metadata.cargo-udeps.ignore]
110-
normal = ["fs_extra"]
112+
normal = ["fs_extra", "rustc-stable-hash"]

dylint/src/library_packages/cargo_cli/util/hex.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// smoelius: This file is a slight modification of:
2-
// https://github.com/rust-lang/cargo/blob/aab416f6e68d555e8c9a0f02098a24946e0725fb/src/cargo/util/hex.rs
2+
// https://github.com/rust-lang/cargo/blob/674e609a0ec2dc431575c48989a7bd1953ff2ab0/src/cargo/util/hex.rs
33

44
#![allow(deprecated)]
55
#![allow(clippy::module_name_repetitions)]
66
#![cfg_attr(dylint_lib = "supplementary", allow(unnamed_constant))]
77

8-
type StableHasher = std::hash::SipHasher;
8+
type StableHasher = rustc_stable_hash::StableSipHasher128;
99

1010
use std::fs::File;
1111
use std::hash::{Hash, Hasher};
@@ -18,7 +18,7 @@ pub fn to_hex(num: u64) -> String {
1818
pub fn hash_u64<H: Hash>(hashable: H) -> u64 {
1919
let mut hasher = StableHasher::new();
2020
hashable.hash(&mut hasher);
21-
hasher.finish()
21+
Hasher::finish(&hasher)
2222
}
2323

2424
pub fn hash_u64_file(mut file: &File) -> std::io::Result<u64> {
@@ -31,7 +31,7 @@ pub fn hash_u64_file(mut file: &File) -> std::io::Result<u64> {
3131
}
3232
hasher.write(&buf[..n]);
3333
}
34-
Ok(hasher.finish())
34+
Ok(Hasher::finish(&hasher))
3535
}
3636

3737
pub fn short_hash<H: Hash>(hashable: &H) -> String {

0 commit comments

Comments
 (0)