Skip to content

Commit 3cf8a61

Browse files
committed
rustdoc: Switch from FxHash to sha256 for static file hashing.
1 parent b0c2d2e commit 3cf8a61

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4608,6 +4608,7 @@ dependencies = [
46084608
"rustdoc-json-types",
46094609
"serde",
46104610
"serde_json",
4611+
"sha2",
46114612
"smallvec",
46124613
"tempfile",
46134614
"threadpool",

src/librustdoc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ tracing = "0.1"
2424
tracing-tree = "0.3.0"
2525
threadpool = "1.8.1"
2626
unicode-segmentation = "1.9"
27+
sha2 = "0.10.8"
2728

2829
[dependencies.tracing-subscriber]
2930
version = "0.3.3"

src/librustdoc/html/static/css/rustdoc.css

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
4444
font-style: normal;
4545
font-weight: 400;
4646
src: local('Fira Sans'),
47-
url("FiraSans-Regular-018c141bf0843ffd.woff2") format("woff2");
47+
url("FiraSans-Regular-0fe48ade.woff2") format("woff2");
4848
font-display: swap;
4949
}
5050
@font-face {
5151
font-family: 'Fira Sans';
5252
font-style: normal;
5353
font-weight: 500;
5454
src: local('Fira Sans Medium'),
55-
url("FiraSans-Medium-8f9a781e4970d388.woff2") format("woff2");
55+
url("FiraSans-Medium-e1aa3f0a.woff2") format("woff2");
5656
font-display: swap;
5757
}
5858

@@ -62,23 +62,23 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
6262
font-style: normal;
6363
font-weight: 400;
6464
src: local('Source Serif 4'),
65-
url("SourceSerif4-Regular-46f98efaafac5295.ttf.woff2") format("woff2");
65+
url("SourceSerif4-Regular-6b053e98.ttf.woff2") format("woff2");
6666
font-display: swap;
6767
}
6868
@font-face {
6969
font-family: 'Source Serif 4';
7070
font-style: italic;
7171
font-weight: 400;
7272
src: local('Source Serif 4 Italic'),
73-
url("SourceSerif4-It-acdfaf1a8af734b1.ttf.woff2") format("woff2");
73+
url("SourceSerif4-It-ca3b17ed.ttf.woff2") format("woff2");
7474
font-display: swap;
7575
}
7676
@font-face {
7777
font-family: 'Source Serif 4';
7878
font-style: normal;
7979
font-weight: 700;
8080
src: local('Source Serif 4 Bold'),
81-
url("SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2") format("woff2");
81+
url("SourceSerif4-Bold-6d4fd4c0.ttf.woff2") format("woff2");
8282
font-display: swap;
8383
}
8484

@@ -89,28 +89,28 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
8989
font-weight: 400;
9090
/* Avoid using locally installed font because bad versions are in circulation:
9191
* see https://github.com/rust-lang/rust/issues/24355 */
92-
src: url("SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2") format("woff2");
92+
src: url("SourceCodePro-Regular-8badfe75.ttf.woff2") format("woff2");
9393
font-display: swap;
9494
}
9595
@font-face {
9696
font-family: 'Source Code Pro';
9797
font-style: italic;
9898
font-weight: 400;
99-
src: url("SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2") format("woff2");
99+
src: url("SourceCodePro-It-fc8b9304.ttf.woff2") format("woff2");
100100
font-display: swap;
101101
}
102102
@font-face {
103103
font-family: 'Source Code Pro';
104104
font-style: normal;
105105
font-weight: 600;
106-
src: url("SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2") format("woff2");
106+
src: url("SourceCodePro-Semibold-aa29a496.ttf.woff2") format("woff2");
107107
font-display: swap;
108108
}
109109

110110
/* Avoid using legacy CJK serif fonts in Windows like Batang. */
111111
@font-face {
112112
font-family: 'NanumBarunGothic';
113-
src: url("NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2") format("woff2");
113+
src: url("NanumBarunGothic-13b3dcba.ttf.woff2") format("woff2");
114114
font-display: swap;
115115
unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF;
116116
}

src/librustdoc/html/static_files.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
//! All the static files are included here for centralized access in case anything other than the
44
//! HTML rendering code (say, the theme checker) needs to access one of these files.
55
6-
use std::hash::Hasher;
76
use std::path::{Path, PathBuf};
87
use std::{fmt, str};
98

10-
use rustc_data_structures::fx::FxHasher;
11-
129
pub(crate) struct StaticFile {
1310
pub(crate) filename: PathBuf,
1411
pub(crate) bytes: &'static [u8],
@@ -64,9 +61,11 @@ pub(crate) fn static_filename(filename: &str, contents: &[u8]) -> PathBuf {
6461
}
6562

6663
fn static_suffix(bytes: &[u8]) -> String {
67-
let mut hasher = FxHasher::default();
68-
hasher.write(bytes);
69-
format!("-{:016x}", hasher.finish())
64+
use sha2::Digest;
65+
let bytes = sha2::Sha256::digest(bytes);
66+
let mut digest = format!("-{bytes:x}");
67+
digest.truncate(9);
68+
digest
7069
}
7170

7271
macro_rules! static_files {

0 commit comments

Comments
 (0)