diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-12-11 04:32:59 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-11 04:32:59 +0900 |
| commit | 071acdf88e32beadea00788b28b0c67aa73b6768 (patch) | |
| tree | 60537f1e4bc93c64637cace2af9980d6780b2f2d | |
| parent | a7f930748cefc33808686b7f748a503a445579f1 (diff) | |
| parent | 9e3e421ab3203387836c273dca69b9d77f85d486 (diff) | |
| download | rust-071acdf88e32beadea00788b28b0c67aa73b6768.tar.gz rust-071acdf88e32beadea00788b28b0c67aa73b6768.zip | |
Rollup merge of #67152 - GuillaumeGomez:sort-auto-impls, r=kinnison
Sort auto trait and blanket implementations display Fixes #63042 r? @kinnison
| -rw-r--r-- | src/librustdoc/html/format.rs | 11 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 23 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 4cde868201e..fd620d467de 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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() } @@ -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. diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e245764b302..86e5efbd7b3 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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 { |
