Skip to content

Commit 5f6f535

Browse files
committed
rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order
1 parent c401f09 commit 5f6f535

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/librustdoc/html/render/write_shared.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,15 @@ else if (window.initSearch) window.initSearch(searchIndex);
593593
ret
594594
})
595595
.collect::<Vec<_>>();
596-
let impls = format!(
597-
r#""{}":{}"#,
598-
krate.name(cx.tcx()),
599-
serde_json::to_string(&impls).expect("failed serde conversion"),
600-
);
596+
597+
// manually collect to string and sort to make list not depend on order
598+
let mut impls = impls
599+
.iter()
600+
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
601+
.collect::<Vec<_>>();
602+
impls.sort();
603+
604+
let impls = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), impls.join(","));
601605

602606
let mut mydst = dst.clone();
603607
for part in &aliased_type.target_fqp[..aliased_type.target_fqp.len() - 1] {
@@ -702,11 +706,14 @@ else if (window.initSearch) window.initSearch(searchIndex);
702706
continue;
703707
}
704708

705-
let implementors = format!(
706-
r#""{}":{}"#,
707-
krate.name(cx.tcx()),
708-
serde_json::to_string(&implementors).expect("failed serde conversion"),
709-
);
709+
// manually collect to string and sort to make list not depend on order
710+
let mut implementors = implementors
711+
.iter()
712+
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
713+
.collect::<Vec<_>>();
714+
implementors.sort();
715+
716+
let implementors = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), implementors.join(","));
710717

711718
let mut mydst = dst.clone();
712719
for part in &remote_path[..remote_path.len() - 1] {

0 commit comments

Comments
 (0)