Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,22 +2122,22 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
items: &[clean::Item],
before: &str,
filter: impl Fn(&clean::Item) -> bool,
write: impl Fn(&mut Buffer, &Symbol),
write: impl Fn(&mut Buffer, &str),
after: &str,
) {
let mut items = items
.iter()
.filter_map(|m| match m.name {
Some(ref name) if filter(m) => Some(name),
Some(ref name) if filter(m) => Some(name.as_str()),
_ => None,
})
.collect::<Vec<_>>();

if !items.is_empty() {
items.sort();
items.sort_unstable();
out.push_str(before);
for item in items.into_iter() {
write(out, item);
write(out, &item);
}
out.push_str(after);
}
Expand Down
9 changes: 7 additions & 2 deletions src/test/rustdoc-gui/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {

/// Woohoo! A trait!
pub trait AnotherOne {
/// Some func 3.
fn func3();

/// Some func 1.
fn func1();

fn another();
fn why_not();

/// Some func 2.
fn func2();

/// Some func 3.
fn func3();
fn hello();
}

/// Check for "i" signs in lists!
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc-gui/trait-sidebar-item-order.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
goto: file://|DOC_PATH|/trait.AnotherOne.html
assert: (".sidebar-links a:nth-of-type(1)", "another")
assert: (".sidebar-links a:nth-of-type(2)", "func1")
assert: (".sidebar-links a:nth-of-type(3)", "func2")
assert: (".sidebar-links a:nth-of-type(4)", "func3")
assert: (".sidebar-links a:nth-of-type(5)", "hello")
assert: (".sidebar-links a:nth-of-type(6)", "why_not")