]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/html/render.rs
Sort auto trait and blanket implementations display
[rust.git] / src / librustdoc / html / render.rs
index 2d7fef56731a25f0c230a88f33f611c8a6628150..86e5efbd7b3a4e98d14e7e1251374e435b03e246 100644 (file)
@@ -45,7 +45,6 @@
 use serialize::json::{ToJson, Json, as_json};
 use syntax::ast;
 use syntax::edition::Edition;
-use syntax::feature_gate::UnstableFeatures;
 use syntax::print::pprust;
 use syntax::source_map::FileName;
 use syntax::symbol::{Symbol, sym};
@@ -56,6 +55,7 @@
 use rustc::hir;
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
 use rustc_data_structures::flock;
+use rustc_feature::UnstableFeatures;
 
 use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability};
 use crate::config::RenderOptions;
@@ -644,10 +644,9 @@ fn write_shared(
     themes.appendChild(but);
 }});"#,
                  as_json(&themes));
-    write(cx.dst.join(&format!("theme{}.js", cx.shared.resource_suffix)),
-          theme_js.as_bytes()
-    )?;
-
+    write_minify(&cx.shared.fs, cx.path("theme.js"),
+                 &theme_js,
+                 options.enable_minification)?;
     write_minify(&cx.shared.fs, cx.path("main.js"),
                  static_files::MAIN_JS,
                  options.enable_minification)?;
@@ -870,7 +869,7 @@ fn to_json_string(&self) -> String {
         v.push_str(&all_indexes.join("\n"));
         // "addSearchOptions" has to be called first so the crate filtering can be set before the
         // search might start (if it's set into the URL for example).
-        v.push_str("addSearchOptions(searchIndex);initSearch(searchIndex);");
+        v.push_str("\naddSearchOptions(searchIndex);initSearch(searchIndex);");
         cx.shared.fs.write(&dst, &v)?;
     }
     if options.enable_index_page {
@@ -2283,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 {