rustdoc: trait.impl, type.impl: sort impls to make it not depend on s… · rust-lang/rust@cb4e69a (original) (raw)

Original file line number Diff line number Diff line change
@@ -593,11 +593,17 @@ else if (window.initSearch) window.initSearch(searchIndex);
593 593 ret
594 594 })
595 595 .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
603 +.collect::<Vec<_>>();
604 + impls.sort();
605 +
606 +let impls = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), impls.join(","));
601 607
602 608 let mut mydst = dst.clone();
603 609 for part in &aliased_type.target_fqp[..aliased_type.target_fqp.len() - 1] {
@@ -702,11 +708,16 @@ else if (window.initSearch) window.initSearch(searchIndex);
702 708 continue;
703 709 }
704 710
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
717 +.collect::<Vec<_>>();
718 + implementors.sort();
719 +
720 +let implementors = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), implementors.join(","));
710 721
711 722 let mut mydst = dst.clone();
712 723 for part in &remote_path[..remote_path.len() - 1] {