mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
Rollup merge of #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.
This commit is contained in:
commit
a2d3eed58d
|
@ -593,11 +593,17 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|||
ret
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let impls = format!(
|
||||
r#""{}":{}"#,
|
||||
krate.name(cx.tcx()),
|
||||
serde_json::to_string(&impls).expect("failed serde conversion"),
|
||||
);
|
||||
|
||||
// FIXME: this fixes only rustdoc part of instability of trait impls
|
||||
// for js files, see #120371
|
||||
// Manually collect to string and sort to make list not depend on order
|
||||
let mut impls = impls
|
||||
.iter()
|
||||
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
|
||||
.collect::<Vec<_>>();
|
||||
impls.sort();
|
||||
|
||||
let impls = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), impls.join(","));
|
||||
|
||||
let mut mydst = dst.clone();
|
||||
for part in &aliased_type.target_fqp[..aliased_type.target_fqp.len() - 1] {
|
||||
|
@ -702,11 +708,16 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|||
continue;
|
||||
}
|
||||
|
||||
let implementors = format!(
|
||||
r#""{}":{}"#,
|
||||
krate.name(cx.tcx()),
|
||||
serde_json::to_string(&implementors).expect("failed serde conversion"),
|
||||
);
|
||||
// FIXME: this fixes only rustdoc part of instability of trait impls
|
||||
// for js files, see #120371
|
||||
// Manually collect to string and sort to make list not depend on order
|
||||
let mut implementors = implementors
|
||||
.iter()
|
||||
.map(|i| serde_json::to_string(i).expect("failed serde conversion"))
|
||||
.collect::<Vec<_>>();
|
||||
implementors.sort();
|
||||
|
||||
let implementors = format!(r#""{}":[{}]"#, krate.name(cx.tcx()), implementors.join(","));
|
||||
|
||||
let mut mydst = dst.clone();
|
||||
for part in &remote_path[..remote_path.len() - 1] {
|
||||
|
|
Loading…
Reference in a new issue