From 61ad9fe1a3a34d358c3922d77557f626e4a21232 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Thu, 16 Apr 2015 12:14:45 +0200 Subject: [PATCH] Use BTreeMap in build_sidebar_items This ensures that later when generating HTML, the JSON will be sorted aswell. We now have a deterministic build of sidebar-items.js --- src/librustdoc/html/render.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 5f4a3e74b6589..54fbdc28968e4 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -37,7 +37,7 @@ pub use self::ExternalLocation::*; use std::ascii::OwnedAsciiExt; use std::cell::RefCell; use std::cmp::Ordering; -use std::collections::{HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap, HashSet}; use std::default::Default; use std::fmt; use std::fs::{self, File}; @@ -1319,8 +1319,9 @@ impl Context { } } - fn build_sidebar_items(&self, m: &clean::Module) -> HashMap> { - let mut map = HashMap::new(); + fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap> { + // BTreeMap instead of HashMap to get a sorted output + let mut map = BTreeMap::new(); for item in &m.items { if self.ignore_private_item(item) { continue }