Skip to content

Commit 6336caa

Browse files
authored
Unrolled build for rust-lang#120641
Rollup merge of rust-lang#120641 - klensy:copypaste-me, r=notriddle rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order Can be tested by running `cargo doc` with different rust versions on some crate and comparing `doc` folders: files in `trait.impl` and `type.impl` will sometimes have different order of impls.
2 parents 0984bec + cb4e69a commit 6336caa

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/librustdoc/html/render/write_shared.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,17 @@ 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+
// FIXME: this fixes only rustdoc part of instability of trait impls
598+
// for js files, see #120371
599+
// Manually collect to string and sort to make list not depend on order
600+
let mut impls = impls
601+
.iter()
602+
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
603+
.collect::<Vec<_>>();
604+
impls.sort();
605+
606+
let impls = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), impls.join(","));
601607

602608
let mut mydst = dst.clone();
603609
for part in &aliased_type.target_fqp[..aliased_type.target_fqp.len() - 1] {
@@ -702,11 +708,16 @@ else if (window.initSearch) window.initSearch(searchIndex);
702708
continue;
703709
}
704710

705-
let implementors = format!(
706-
r#""{}":{}"#,
707-
krate.name(cx.tcx()),
708-
serde_json::to_string(&implementors).expect("failed serde conversion"),
709-
);
711+
// FIXME: this fixes only rustdoc part of instability of trait impls
712+
// for js files, see #120371
713+
// Manually collect to string and sort to make list not depend on order
714+
let mut implementors = implementors
715+
.iter()
716+
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
717+
.collect::<Vec<_>>();
718+
implementors.sort();
719+
720+
let implementors = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), implementors.join(","));
710721

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

0 commit comments

Comments
 (0)