diff options
| author | Alona Enraght-Moony <code@alona.page> | 2024-10-18 20:28:32 +0000 |
|---|---|---|
| committer | Alona Enraght-Moony <code@alona.page> | 2024-10-19 01:05:58 +0000 |
| commit | 3cf8a61a7ad803b3c785d1052dc4dc9fecb7a92f (patch) | |
| tree | 19a016aced9fca11ca7e7f450d0403c0e0bce665 /src/librustdoc/html/static_files.rs | |
| parent | b0c2d2e5b00339014cba0a31f634af8c146458ed (diff) | |
| download | rust-3cf8a61a7ad803b3c785d1052dc4dc9fecb7a92f.tar.gz rust-3cf8a61a7ad803b3c785d1052dc4dc9fecb7a92f.zip | |
rustdoc: Switch from FxHash to sha256 for static file hashing.
Diffstat (limited to 'src/librustdoc/html/static_files.rs')
| -rw-r--r-- | src/librustdoc/html/static_files.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 6157598ba38..9e0803f5d3f 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -3,12 +3,9 @@ //! All the static files are included here for centralized access in case anything other than the //! HTML rendering code (say, the theme checker) needs to access one of these files. -use std::hash::Hasher; use std::path::{Path, PathBuf}; use std::{fmt, str}; -use rustc_data_structures::fx::FxHasher; - pub(crate) struct StaticFile { pub(crate) filename: PathBuf, pub(crate) bytes: &'static [u8], @@ -64,9 +61,11 @@ pub(crate) fn static_filename(filename: &str, contents: &[u8]) -> PathBuf { } fn static_suffix(bytes: &[u8]) -> String { - let mut hasher = FxHasher::default(); - hasher.write(bytes); - format!("-{:016x}", hasher.finish()) + use sha2::Digest; + let bytes = sha2::Sha256::digest(bytes); + let mut digest = format!("-{bytes:x}"); + digest.truncate(9); + digest } macro_rules! static_files { |
