Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort auto trait and blanket implementations display #67152

Merged
merged 1 commit into from
Dec 11, 2019
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
11 changes: 11 additions & 0 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ impl Buffer {
}
}

crate fn new() -> Buffer {
Buffer {
for_html: false,
buffer: String::new(),
}
}

crate fn is_empty(&self) -> bool {
self.buffer.is_empty()
}
Expand Down Expand Up @@ -106,6 +113,10 @@ impl Buffer {
write!(self, "{:#}", t);
}
}

crate fn is_for_html(&self) -> bool {
self.for_html
}
}

/// Wrapper struct for properly emitting a function or method declaration.
Expand Down
23 changes: 17 additions & 6 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2282,12 +2282,23 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut Buffer,
fn render_impls(cx: &Context, w: &mut Buffer,
traits: &[&&Impl],
containing_item: &clean::Item) {
for i in traits {
let did = i.trait_did().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
render_impl(w, cx, i, assoc_link,
RenderMode::Normal, containing_item.stable_since(), true, None, false, true);
}
let mut impls = traits.iter()
.map(|i| {
let did = i.trait_did().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
let mut buffer = if w.is_for_html() {
Buffer::html()
} else {
Buffer::new()
};
render_impl(&mut buffer, cx, i, assoc_link,
RenderMode::Normal, containing_item.stable_since(),
true, None, false, true);
buffer.into_inner()
})
.collect::<Vec<_>>();
impls.sort();
w.write_str(&impls.join(""));
}

fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool) -> String {
Expand Down