Skip to content

Commit 5314588

Browse files
committed
Sort sidebar implementations on foreign types with natord::compare
1 parent 9cd60bd commit 5314588

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,12 @@ dependencies = [
23682368
name = "miropt-test-tools"
23692369
version = "0.1.0"
23702370

2371+
[[package]]
2372+
name = "natord"
2373+
version = "1.0.9"
2374+
source = "registry+https://github.com/rust-lang/crates.io-index"
2375+
checksum = "308d96db8debc727c3fd9744aac51751243420e46edf401010908da7f8d5e57c"
2376+
23712377
[[package]]
23722378
name = "new_debug_unreachable"
23732379
version = "1.0.6"
@@ -4725,6 +4731,7 @@ dependencies = [
47254731
"indexmap",
47264732
"itertools",
47274733
"minifier",
4734+
"natord",
47284735
"pulldown-cmark 0.9.6",
47294736
"regex",
47304737
"rinja",

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tracing = "0.1"
2525
tracing-tree = "0.3.0"
2626
threadpool = "1.8.1"
2727
unicode-segmentation = "1.9"
28+
natord = "1.0.9"
2829

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

src/librustdoc/html/render/sidebar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ fn sidebar_trait<'a>(
297297
.filter_map(|i| super::extract_for_impl_name(&i.impl_item, cx))
298298
.map(|(name, id)| Link::new(id, name)),
299299
);
300-
foreign_impls.sort();
300+
foreign_impls.sort_by(|a, b| natord::compare(&a.name, &b.name));
301301
}
302302

303303
blocks.extend(

tests/rustdoc/sidebar/sidebar-links-to-foreign-impl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
//@ has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types'
88
//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32'
99
//@ has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32'
10+
//@ has - '//*[@id="impl-Foo-for-u8"]//h3[@class="code-header"]' 'impl Foo for u8'
1011
//@ has - "//*[@class=\"sidebar-elems\"]//section//a[@href=\"#impl-Foo-for-%26str\"]" "&'a str"
1112
//@ has - "//*[@id=\"impl-Foo-for-%26str\"]//h3[@class=\"code-header\"]" "impl<'a> Foo for &'a str"
1213
pub trait Foo {}
1314

1415
impl Foo for u32 {}
16+
impl Foo for u8 {}
1517

1618
impl<'a> Foo for &'a str {}

0 commit comments

Comments
 (0)