Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e4791e0

Browse files
authoredAug 28, 2016
Auto merge of #35984 - jonas-schievink:reproducible-builds, r=eddyb
Steps towards reproducible builds cc #34902 Running `make dist` twice will result in a rustc tarball where only `librustc_back.so`, `librustc_llvm.so` and `librustc_trans.so` differ. Building `libstd` and `libcore` twice with the same compiler and flags produces identical artifacts. The third commit should close #24473
2 parents 6fd13fa + 8766c18 commit e4791e0

File tree

21 files changed

+135
-133
lines changed

21 files changed

+135
-133
lines changed
 

‎src/librustc/infer/freshen.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
3333
use ty::{self, Ty, TyCtxt, TypeFoldable};
3434
use ty::fold::TypeFolder;
35-
use std::collections::hash_map::{self, Entry};
35+
use util::nodemap::FnvHashMap;
36+
use std::collections::hash_map::Entry;
3637

3738
use super::InferCtxt;
3839
use super::unify_key::ToType;
3940

4041
pub struct TypeFreshener<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
4142
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
4243
freshen_count: u32,
43-
freshen_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
44+
freshen_map: FnvHashMap<ty::InferTy, Ty<'tcx>>,
4445
}
4546

4647
impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> {
@@ -49,7 +50,7 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> {
4950
TypeFreshener {
5051
infcx: infcx,
5152
freshen_count: 0,
52-
freshen_map: hash_map::HashMap::new(),
53+
freshen_map: FnvHashMap(),
5354
}
5455
}
5556

‎src/librustc/middle/dead.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use ty::{self, TyCtxt};
2222
use hir::def::Def;
2323
use hir::def_id::{DefId};
2424
use lint;
25+
use util::nodemap::FnvHashSet;
2526

26-
use std::collections::HashSet;
2727
use syntax::{ast, codemap};
2828
use syntax::attr;
2929
use syntax_pos;
@@ -48,7 +48,7 @@ fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4848
struct MarkSymbolVisitor<'a, 'tcx: 'a> {
4949
worklist: Vec<ast::NodeId>,
5050
tcx: TyCtxt<'a, 'tcx, 'tcx>,
51-
live_symbols: Box<HashSet<ast::NodeId>>,
51+
live_symbols: Box<FnvHashSet<ast::NodeId>>,
5252
struct_has_extern_repr: bool,
5353
ignore_non_const_paths: bool,
5454
inherited_pub_visibility: bool,
@@ -61,7 +61,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6161
MarkSymbolVisitor {
6262
worklist: worklist,
6363
tcx: tcx,
64-
live_symbols: box HashSet::new(),
64+
live_symbols: box FnvHashSet(),
6565
struct_has_extern_repr: false,
6666
ignore_non_const_paths: false,
6767
inherited_pub_visibility: false,
@@ -162,7 +162,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
162162
}
163163

164164
fn mark_live_symbols(&mut self) {
165-
let mut scanned = HashSet::new();
165+
let mut scanned = FnvHashSet();
166166
while !self.worklist.is_empty() {
167167
let id = self.worklist.pop().unwrap();
168168
if scanned.contains(&id) {
@@ -395,7 +395,7 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
395395
fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
396396
access_levels: &privacy::AccessLevels,
397397
krate: &hir::Crate)
398-
-> Box<HashSet<ast::NodeId>> {
398+
-> Box<FnvHashSet<ast::NodeId>> {
399399
let worklist = create_and_seed_worklist(tcx, access_levels, krate);
400400
let mut symbol_visitor = MarkSymbolVisitor::new(tcx, worklist);
401401
symbol_visitor.mark_live_symbols();
@@ -413,7 +413,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> {
413413

414414
struct DeadVisitor<'a, 'tcx: 'a> {
415415
tcx: TyCtxt<'a, 'tcx, 'tcx>,
416-
live_symbols: Box<HashSet<ast::NodeId>>,
416+
live_symbols: Box<FnvHashSet<ast::NodeId>>,
417417
}
418418

419419
impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {

‎src/librustc/middle/reachable.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ use hir::def_id::DefId;
2222
use ty::{self, TyCtxt};
2323
use middle::privacy;
2424
use session::config;
25-
use util::nodemap::NodeSet;
25+
use util::nodemap::{NodeSet, FnvHashSet};
2626

27-
use std::collections::HashSet;
2827
use syntax::abi::Abi;
2928
use syntax::ast;
3029
use syntax::attr;
@@ -204,7 +203,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
204203

205204
// Step 2: Mark all symbols that the symbols on the worklist touch.
206205
fn propagate(&mut self) {
207-
let mut scanned = HashSet::new();
206+
let mut scanned = FnvHashSet();
208207
loop {
209208
let search_item = match self.worklist.pop() {
210209
Some(item) => item,

‎src/librustc_metadata/encoder.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,13 @@ fn encode_xrefs<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
862862
xrefs: FnvHashMap<XRef<'tcx>, u32>)
863863
{
864864
let mut xref_positions = vec![0; xrefs.len()];
865+
866+
// Encode XRefs sorted by their ID
867+
let mut sorted_xrefs: Vec<_> = xrefs.into_iter().collect();
868+
sorted_xrefs.sort_by_key(|&(_, id)| id);
869+
865870
rbml_w.start_tag(tag_xref_data);
866-
for (xref, id) in xrefs.into_iter() {
871+
for (xref, id) in sorted_xrefs.into_iter() {
867872
xref_positions[id as usize] = rbml_w.mark_stable_position() as u32;
868873
match xref {
869874
XRef::Predicate(p) => {

‎src/librustc_metadata/loader.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ use rustc::session::Session;
221221
use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch};
222222
use rustc::session::search_paths::PathKind;
223223
use rustc::util::common;
224+
use rustc::util::nodemap::FnvHashMap;
224225

225226
use rustc_llvm as llvm;
226227
use rustc_llvm::{False, ObjectFile, mk_section_iter};
@@ -230,7 +231,6 @@ use syntax_pos::Span;
230231
use rustc_back::target::Target;
231232

232233
use std::cmp;
233-
use std::collections::HashMap;
234234
use std::fmt;
235235
use std::fs;
236236
use std::io;
@@ -413,7 +413,7 @@ impl<'a> Context<'a> {
413413
let rlib_prefix = format!("lib{}", self.crate_name);
414414
let staticlib_prefix = format!("{}{}", staticpair.0, self.crate_name);
415415

416-
let mut candidates = HashMap::new();
416+
let mut candidates = FnvHashMap();
417417
let mut staticlibs = vec!();
418418

419419
// First, find all possible candidate rlibs and dylibs purely based on
@@ -456,7 +456,7 @@ impl<'a> Context<'a> {
456456

457457
let hash_str = hash.to_string();
458458
let slot = candidates.entry(hash_str)
459-
.or_insert_with(|| (HashMap::new(), HashMap::new()));
459+
.or_insert_with(|| (FnvHashMap(), FnvHashMap()));
460460
let (ref mut rlibs, ref mut dylibs) = *slot;
461461
fs::canonicalize(path).map(|p| {
462462
if rlib {
@@ -477,7 +477,7 @@ impl<'a> Context<'a> {
477477
// A Library candidate is created if the metadata for the set of
478478
// libraries corresponds to the crate id and hash criteria that this
479479
// search is being performed for.
480-
let mut libraries = HashMap::new();
480+
let mut libraries = FnvHashMap();
481481
for (_hash, (rlibs, dylibs)) in candidates {
482482
let mut slot = None;
483483
let rlib = self.extract_one(rlibs, CrateFlavor::Rlib, &mut slot);
@@ -527,7 +527,7 @@ impl<'a> Context<'a> {
527527
// read the metadata from it if `*slot` is `None`. If the metadata couldn't
528528
// be read, it is assumed that the file isn't a valid rust library (no
529529
// errors are emitted).
530-
fn extract_one(&mut self, m: HashMap<PathBuf, PathKind>, flavor: CrateFlavor,
530+
fn extract_one(&mut self, m: FnvHashMap<PathBuf, PathKind>, flavor: CrateFlavor,
531531
slot: &mut Option<(Svh, MetadataBlob)>) -> Option<(PathBuf, PathKind)> {
532532
let mut ret: Option<(PathBuf, PathKind)> = None;
533533
let mut error = 0;
@@ -669,8 +669,8 @@ impl<'a> Context<'a> {
669669
// rlibs/dylibs.
670670
let sess = self.sess;
671671
let dylibname = self.dylibname();
672-
let mut rlibs = HashMap::new();
673-
let mut dylibs = HashMap::new();
672+
let mut rlibs = FnvHashMap();
673+
let mut dylibs = FnvHashMap();
674674
{
675675
let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| {
676676
if !loc.exists() {

‎src/librustc_metadata/macro_import.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use creader::CrateReader;
1414
use cstore::CStore;
1515

1616
use rustc::session::Session;
17+
use rustc::util::nodemap::{FnvHashSet, FnvHashMap};
1718

18-
use std::collections::{HashSet, HashMap};
1919
use syntax::parse::token;
2020
use syntax::ast;
2121
use syntax::attr;
@@ -45,13 +45,13 @@ pub fn call_bad_macro_reexport(a: &Session, b: Span) {
4545
span_err!(a, b, E0467, "bad macro reexport");
4646
}
4747

48-
pub type MacroSelection = HashMap<token::InternedString, Span>;
48+
pub type MacroSelection = FnvHashMap<token::InternedString, Span>;
4949

5050
impl<'a> ext::base::MacroLoader for MacroLoader<'a> {
5151
fn load_crate(&mut self, extern_crate: &ast::Item, allows_macros: bool) -> Vec<ast::MacroDef> {
5252
// Parse the attributes relating to macros.
53-
let mut import = Some(HashMap::new()); // None => load all
54-
let mut reexport = HashMap::new();
53+
let mut import = Some(FnvHashMap()); // None => load all
54+
let mut reexport = FnvHashMap();
5555

5656
for attr in &extern_crate.attrs {
5757
let mut used = true;
@@ -120,7 +120,7 @@ impl<'a> MacroLoader<'a> {
120120
}
121121

122122
let mut macros = Vec::new();
123-
let mut seen = HashSet::new();
123+
let mut seen = FnvHashSet();
124124

125125
for mut def in self.reader.read_exported_macros(vi) {
126126
let name = def.ident.name.as_str();

‎src/librustc_resolve/assign_ids.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
use Resolver;
1212
use rustc::session::Session;
13+
use rustc::util::nodemap::FnvHashMap;
1314
use syntax::ast;
1415
use syntax::ext::hygiene::Mark;
1516
use syntax::fold::{self, Folder};
1617
use syntax::ptr::P;
1718
use syntax::util::move_map::MoveMap;
1819
use syntax::util::small_vector::SmallVector;
1920

20-
use std::collections::HashMap;
2121
use std::mem;
2222

2323
impl<'a> Resolver<'a> {
@@ -31,7 +31,7 @@ impl<'a> Resolver<'a> {
3131

3232
struct NodeIdAssigner<'a> {
3333
sess: &'a Session,
34-
macros_at_scope: &'a mut HashMap<ast::NodeId, Vec<Mark>>,
34+
macros_at_scope: &'a mut FnvHashMap<ast::NodeId, Vec<Mark>>,
3535
}
3636

3737
impl<'a> Folder for NodeIdAssigner<'a> {

‎src/librustc_resolve/lib.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ use syntax::ast::{PathSegment, PathParameters, QSelf, TraitItemKind, TraitRef, T
6868
use syntax_pos::Span;
6969
use errors::DiagnosticBuilder;
7070

71-
use std::collections::{HashMap, HashSet};
7271
use std::cell::{Cell, RefCell};
7372
use std::fmt;
7473
use std::mem::replace;
@@ -498,7 +497,7 @@ struct BindingInfo {
498497
}
499498

500499
// Map from the name in a pattern to its binding mode.
501-
type BindingMap = HashMap<ast::Ident, BindingInfo>;
500+
type BindingMap = FnvHashMap<ast::Ident, BindingInfo>;
502501

503502
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
504503
enum PatternSource {
@@ -703,14 +702,14 @@ enum ModulePrefixResult<'a> {
703702
/// One local scope.
704703
#[derive(Debug)]
705704
struct Rib<'a> {
706-
bindings: HashMap<ast::Ident, Def>,
705+
bindings: FnvHashMap<ast::Ident, Def>,
707706
kind: RibKind<'a>,
708707
}
709708

710709
impl<'a> Rib<'a> {
711710
fn new(kind: RibKind<'a>) -> Rib<'a> {
712711
Rib {
713-
bindings: HashMap::new(),
712+
bindings: FnvHashMap(),
714713
kind: kind,
715714
}
716715
}
@@ -773,7 +772,7 @@ pub struct ModuleS<'a> {
773772
// is the NodeId of the local `extern crate` item (otherwise, `extern_crate_id` is None).
774773
extern_crate_id: Option<NodeId>,
775774

776-
resolutions: RefCell<HashMap<(Name, Namespace), &'a RefCell<NameResolution<'a>>>>,
775+
resolutions: RefCell<FnvHashMap<(Name, Namespace), &'a RefCell<NameResolution<'a>>>>,
777776

778777
no_implicit_prelude: Cell<bool>,
779778

@@ -797,7 +796,7 @@ impl<'a> ModuleS<'a> {
797796
parent_link: parent_link,
798797
def: def,
799798
extern_crate_id: None,
800-
resolutions: RefCell::new(HashMap::new()),
799+
resolutions: RefCell::new(FnvHashMap()),
801800
no_implicit_prelude: Cell::new(false),
802801
glob_importers: RefCell::new(Vec::new()),
803802
globs: RefCell::new((Vec::new())),
@@ -930,12 +929,12 @@ impl<'a> NameBinding<'a> {
930929

931930
/// Interns the names of the primitive types.
932931
struct PrimitiveTypeTable {
933-
primitive_types: HashMap<Name, PrimTy>,
932+
primitive_types: FnvHashMap<Name, PrimTy>,
934933
}
935934

936935
impl PrimitiveTypeTable {
937936
fn new() -> PrimitiveTypeTable {
938-
let mut table = PrimitiveTypeTable { primitive_types: HashMap::new() };
937+
let mut table = PrimitiveTypeTable { primitive_types: FnvHashMap() };
939938

940939
table.intern("bool", TyBool);
941940
table.intern("char", TyChar);
@@ -969,7 +968,7 @@ pub struct Resolver<'a> {
969968

970969
// Maps the node id of a statement to the expansions of the `macro_rules!`s
971970
// immediately above the statement (if appropriate).
972-
macros_at_scope: HashMap<NodeId, Vec<Mark>>,
971+
macros_at_scope: FnvHashMap<NodeId, Vec<Mark>>,
973972

974973
graph_root: Module<'a>,
975974

@@ -1043,8 +1042,8 @@ pub struct Resolver<'a> {
10431042
// all imports, but only glob imports are actually interesting).
10441043
pub glob_map: GlobMap,
10451044

1046-
used_imports: HashSet<(NodeId, Namespace)>,
1047-
used_crates: HashSet<CrateNum>,
1045+
used_imports: FnvHashSet<(NodeId, Namespace)>,
1046+
used_crates: FnvHashSet<CrateNum>,
10481047
pub maybe_unused_trait_imports: NodeSet,
10491048

10501049
privacy_errors: Vec<PrivacyError<'a>>,
@@ -1164,7 +1163,7 @@ impl<'a> Resolver<'a> {
11641163
session: session,
11651164

11661165
definitions: Definitions::new(),
1167-
macros_at_scope: HashMap::new(),
1166+
macros_at_scope: FnvHashMap(),
11681167

11691168
// The outermost module has def ID 0; this is not reflected in the
11701169
// AST.
@@ -1199,8 +1198,8 @@ impl<'a> Resolver<'a> {
11991198
make_glob_map: make_glob_map == MakeGlobMap::Yes,
12001199
glob_map: NodeMap(),
12011200

1202-
used_imports: HashSet::new(),
1203-
used_crates: HashSet::new(),
1201+
used_imports: FnvHashSet(),
1202+
used_crates: FnvHashSet(),
12041203
maybe_unused_trait_imports: NodeSet(),
12051204

12061205
privacy_errors: Vec::new(),
@@ -1729,7 +1728,7 @@ impl<'a> Resolver<'a> {
17291728
match type_parameters {
17301729
HasTypeParameters(generics, rib_kind) => {
17311730
let mut function_type_rib = Rib::new(rib_kind);
1732-
let mut seen_bindings = HashMap::new();
1731+
let mut seen_bindings = FnvHashMap();
17331732
for type_parameter in &generics.ty_params {
17341733
let name = type_parameter.ident.name;
17351734
debug!("with_type_parameter_rib: {}", type_parameter.id);
@@ -1793,7 +1792,7 @@ impl<'a> Resolver<'a> {
17931792
self.label_ribs.push(Rib::new(rib_kind));
17941793

17951794
// Add each argument to the rib.
1796-
let mut bindings_list = HashMap::new();
1795+
let mut bindings_list = FnvHashMap();
17971796
for argument in &declaration.inputs {
17981797
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
17991798

@@ -1994,15 +1993,15 @@ impl<'a> Resolver<'a> {
19941993
walk_list!(self, visit_expr, &local.init);
19951994

19961995
// Resolve the pattern.
1997-
self.resolve_pattern(&local.pat, PatternSource::Let, &mut HashMap::new());
1996+
self.resolve_pattern(&local.pat, PatternSource::Let, &mut FnvHashMap());
19981997
}
19991998

20001999
// build a map from pattern identifiers to binding-info's.
20012000
// this is done hygienically. This could arise for a macro
20022001
// that expands into an or-pattern where one 'x' was from the
20032002
// user and one 'x' came from the macro.
20042003
fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap {
2005-
let mut binding_map = HashMap::new();
2004+
let mut binding_map = FnvHashMap();
20062005

20072006
pat.walk(&mut |pat| {
20082007
if let PatKind::Ident(binding_mode, ident, ref sub_pat) = pat.node {
@@ -2062,7 +2061,7 @@ impl<'a> Resolver<'a> {
20622061
fn resolve_arm(&mut self, arm: &Arm) {
20632062
self.value_ribs.push(Rib::new(NormalRibKind));
20642063

2065-
let mut bindings_list = HashMap::new();
2064+
let mut bindings_list = FnvHashMap();
20662065
for pattern in &arm.pats {
20672066
self.resolve_pattern(&pattern, PatternSource::Match, &mut bindings_list);
20682067
}
@@ -2202,7 +2201,7 @@ impl<'a> Resolver<'a> {
22022201
pat_id: NodeId,
22032202
outer_pat_id: NodeId,
22042203
pat_src: PatternSource,
2205-
bindings: &mut HashMap<ast::Ident, NodeId>)
2204+
bindings: &mut FnvHashMap<ast::Ident, NodeId>)
22062205
-> PathResolution {
22072206
// Add the binding to the local ribs, if it
22082207
// doesn't already exist in the bindings map. (We
@@ -2303,7 +2302,7 @@ impl<'a> Resolver<'a> {
23032302
pat_src: PatternSource,
23042303
// Maps idents to the node ID for the
23052304
// outermost pattern that binds them.
2306-
bindings: &mut HashMap<ast::Ident, NodeId>) {
2305+
bindings: &mut FnvHashMap<ast::Ident, NodeId>) {
23072306
// Visit all direct subpatterns of this pattern.
23082307
let outer_pat_id = pat.id;
23092308
pat.walk(&mut |pat| {
@@ -3016,7 +3015,7 @@ impl<'a> Resolver<'a> {
30163015
self.visit_expr(subexpression);
30173016

30183017
self.value_ribs.push(Rib::new(NormalRibKind));
3019-
self.resolve_pattern(pattern, PatternSource::IfLet, &mut HashMap::new());
3018+
self.resolve_pattern(pattern, PatternSource::IfLet, &mut FnvHashMap());
30203019
self.visit_block(if_block);
30213020
self.value_ribs.pop();
30223021

@@ -3026,7 +3025,7 @@ impl<'a> Resolver<'a> {
30263025
ExprKind::WhileLet(ref pattern, ref subexpression, ref block, label) => {
30273026
self.visit_expr(subexpression);
30283027
self.value_ribs.push(Rib::new(NormalRibKind));
3029-
self.resolve_pattern(pattern, PatternSource::WhileLet, &mut HashMap::new());
3028+
self.resolve_pattern(pattern, PatternSource::WhileLet, &mut FnvHashMap());
30303029

30313030
self.resolve_labeled_block(label.map(|l| l.node), expr.id, block);
30323031

@@ -3036,7 +3035,7 @@ impl<'a> Resolver<'a> {
30363035
ExprKind::ForLoop(ref pattern, ref subexpression, ref block, label) => {
30373036
self.visit_expr(subexpression);
30383037
self.value_ribs.push(Rib::new(NormalRibKind));
3039-
self.resolve_pattern(pattern, PatternSource::For, &mut HashMap::new());
3038+
self.resolve_pattern(pattern, PatternSource::For, &mut FnvHashMap());
30403039

30413040
self.resolve_labeled_block(label.map(|l| l.node), expr.id, block);
30423041

@@ -3297,7 +3296,7 @@ impl<'a> Resolver<'a> {
32973296

32983297
fn report_privacy_errors(&self) {
32993298
if self.privacy_errors.len() == 0 { return }
3300-
let mut reported_spans = HashSet::new();
3299+
let mut reported_spans = FnvHashSet();
33013300
for &PrivacyError(span, name, binding) in &self.privacy_errors {
33023301
if !reported_spans.insert(span) { continue }
33033302
if binding.is_extern_crate() {

‎src/librustc_trans/base.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ use type_of;
8080
use value::Value;
8181
use Disr;
8282
use util::sha2::Sha256;
83-
use util::nodemap::{NodeSet, FnvHashSet};
83+
use util::nodemap::{NodeSet, FnvHashMap, FnvHashSet};
8484

8585
use arena::TypedArena;
8686
use libc::c_uint;
8787
use std::ffi::{CStr, CString};
8888
use std::borrow::Cow;
8989
use std::cell::{Cell, RefCell};
90-
use std::collections::HashMap;
9190
use std::ptr;
9291
use std::rc::Rc;
9392
use std::str;
@@ -1915,7 +1914,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
19151914
}
19161915

19171916
if scx.sess().opts.debugging_opts.print_trans_items.is_some() {
1918-
let mut item_to_cgus = HashMap::new();
1917+
let mut item_to_cgus = FnvHashMap();
19191918

19201919
for cgu in &codegen_units {
19211920
for (&trans_item, &linkage) in cgu.items() {

‎src/librustc_typeck/check/intrinsic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use rustc::infer::TypeOrigin;
1616
use rustc::ty::subst::Substs;
1717
use rustc::ty::FnSig;
1818
use rustc::ty::{self, Ty};
19+
use rustc::util::nodemap::FnvHashMap;
1920
use {CrateCtxt, require_same_types};
2021

21-
use std::collections::{HashMap};
2222
use syntax::abi::Abi;
2323
use syntax::ast;
2424
use syntax::parse::token;
@@ -370,7 +370,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
370370
return
371371
}
372372

373-
let mut structural_to_nomimal = HashMap::new();
373+
let mut structural_to_nomimal = FnvHashMap();
374374

375375
let sig = tcx.no_late_bound_regions(i_ty.ty.fn_sig()).unwrap();
376376
if intr.inputs.len() != sig.inputs.len() {
@@ -410,7 +410,7 @@ fn match_intrinsic_type_to_type<'tcx, 'a>(
410410
ccx: &CrateCtxt<'a, 'tcx>,
411411
position: &str,
412412
span: Span,
413-
structural_to_nominal: &mut HashMap<&'a intrinsics::Type, ty::Ty<'tcx>>,
413+
structural_to_nominal: &mut FnvHashMap<&'a intrinsics::Type, ty::Ty<'tcx>>,
414414
expected: &'a intrinsics::Type, t: ty::Ty<'tcx>)
415415
{
416416
use intrinsics::Type::*;

‎src/librustc_typeck/check/method/probe.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use rustc::ty::subst::{Subst, Substs};
2020
use rustc::traits;
2121
use rustc::ty::{self, Ty, ToPolyTraitRef, TraitRef, TypeFoldable};
2222
use rustc::infer::{InferOk, TypeOrigin};
23+
use rustc::util::nodemap::FnvHashSet;
2324
use syntax::ast;
2425
use syntax_pos::{Span, DUMMY_SP};
2526
use rustc::hir;
26-
use std::collections::HashSet;
2727
use std::mem;
2828
use std::ops::Deref;
2929
use std::rc::Rc;
@@ -40,7 +40,7 @@ struct ProbeContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
4040
opt_simplified_steps: Option<Vec<ty::fast_reject::SimplifiedType>>,
4141
inherent_candidates: Vec<Candidate<'tcx>>,
4242
extension_candidates: Vec<Candidate<'tcx>>,
43-
impl_dups: HashSet<DefId>,
43+
impl_dups: FnvHashSet<DefId>,
4444
import_id: Option<ast::NodeId>,
4545

4646
/// Collects near misses when the candidate functions are missing a `self` keyword and is only
@@ -255,7 +255,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
255255
item_name: item_name,
256256
inherent_candidates: Vec::new(),
257257
extension_candidates: Vec::new(),
258-
impl_dups: HashSet::new(),
258+
impl_dups: FnvHashSet(),
259259
import_id: None,
260260
steps: Rc::new(steps),
261261
opt_simplified_steps: opt_simplified_steps,
@@ -574,7 +574,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
574574
expr_id: ast::NodeId)
575575
-> Result<(), MethodError<'tcx>>
576576
{
577-
let mut duplicates = HashSet::new();
577+
let mut duplicates = FnvHashSet();
578578
let opt_applicable_traits = self.tcx.trait_map.get(&expr_id);
579579
if let Some(applicable_traits) = opt_applicable_traits {
580580
for trait_candidate in applicable_traits {
@@ -591,7 +591,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
591591
}
592592

593593
fn assemble_extension_candidates_for_all_traits(&mut self) -> Result<(), MethodError<'tcx>> {
594-
let mut duplicates = HashSet::new();
594+
let mut duplicates = FnvHashSet();
595595
for trait_info in suggest::all_traits(self.ccx) {
596596
if duplicates.insert(trait_info.def_id) {
597597
self.assemble_extension_candidates_for_trait(trait_info.def_id)?;

‎src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ use CrateCtxt;
104104
use TypeAndSubsts;
105105
use lint;
106106
use util::common::{block_query, ErrorReported, indenter, loop_query};
107-
use util::nodemap::{DefIdMap, FnvHashMap, NodeMap};
107+
use util::nodemap::{DefIdMap, FnvHashMap, FnvHashSet, NodeMap};
108108

109109
use std::cell::{Cell, Ref, RefCell};
110-
use std::collections::{HashSet};
111110
use std::mem::replace;
112111
use std::ops::Deref;
113112
use syntax::abi::Abi;
@@ -2045,7 +2044,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
20452044
.filter_map(|t| self.default(t).map(|d| (t, d)))
20462045
.collect();
20472046

2048-
let mut unbound_tyvars = HashSet::new();
2047+
let mut unbound_tyvars = FnvHashSet();
20492048

20502049
debug!("select_all_obligations_and_apply_defaults: defaults={:?}", default_map);
20512050

@@ -2192,7 +2191,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
21922191
// table then apply defaults until we find a conflict. That default must be the one
21932192
// that caused conflict earlier.
21942193
fn find_conflicting_default(&self,
2195-
unbound_vars: &HashSet<Ty<'tcx>>,
2194+
unbound_vars: &FnvHashSet<Ty<'tcx>>,
21962195
default_map: &FnvHashMap<&Ty<'tcx>, type_variable::Default<'tcx>>,
21972196
conflict: Ty<'tcx>)
21982197
-> Option<type_variable::Default<'tcx>> {

‎src/librustc_typeck/check/wfcheck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use middle::region::{CodeExtent};
1616
use rustc::infer::TypeOrigin;
1717
use rustc::traits;
1818
use rustc::ty::{self, Ty, TyCtxt};
19+
use rustc::util::nodemap::FnvHashSet;
1920

20-
use std::collections::HashSet;
2121
use syntax::ast;
2222
use syntax_pos::Span;
2323
use errors::DiagnosticBuilder;
@@ -456,7 +456,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
456456
assert_eq!(ty_predicates.parent, None);
457457
let variances = self.tcx().item_variances(item_def_id);
458458

459-
let mut constrained_parameters: HashSet<_> =
459+
let mut constrained_parameters: FnvHashSet<_> =
460460
variances[ast_generics.lifetimes.len()..]
461461
.iter().enumerate()
462462
.filter(|&(_, &variance)| variance != ty::Bivariant)
@@ -519,7 +519,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
519519

520520
fn reject_shadowing_type_parameters(tcx: TyCtxt, span: Span, generics: &ty::Generics) {
521521
let parent = tcx.lookup_generics(generics.parent.unwrap());
522-
let impl_params: HashSet<_> = parent.types.iter().map(|tp| tp.name).collect();
522+
let impl_params: FnvHashSet<_> = parent.types.iter().map(|tp| tp.name).collect();
523523

524524
for method_param in &generics.types {
525525
if impl_params.contains(&method_param.name) {

‎src/librustc_typeck/collect.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ use rustc::ty::util::IntTypeExt;
7373
use rscope::*;
7474
use rustc::dep_graph::DepNode;
7575
use util::common::{ErrorReported, MemoizationMap};
76-
use util::nodemap::{NodeMap, FnvHashMap};
76+
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
7777
use {CrateCtxt, write_ty_to_tcx};
7878

7979
use rustc_const_math::ConstInt;
8080

8181
use std::cell::RefCell;
82-
use std::collections::HashSet;
8382
use std::collections::hash_map::Entry::{Occupied, Vacant};
8483
use std::rc::Rc;
8584

@@ -1927,9 +1926,9 @@ fn compute_object_lifetime_default<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
19271926
{
19281927
let inline_bounds = from_bounds(ccx, param_bounds);
19291928
let where_bounds = from_predicates(ccx, param_id, &where_clause.predicates);
1930-
let all_bounds: HashSet<_> = inline_bounds.into_iter()
1931-
.chain(where_bounds)
1932-
.collect();
1929+
let all_bounds: FnvHashSet<_> = inline_bounds.into_iter()
1930+
.chain(where_bounds)
1931+
.collect();
19331932
return if all_bounds.len() > 1 {
19341933
ty::ObjectLifetimeDefault::Ambiguous
19351934
} else if all_bounds.len() == 0 {
@@ -2146,7 +2145,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
21462145
// The trait reference is an input, so find all type parameters
21472146
// reachable from there, to start (if this is an inherent impl,
21482147
// then just examine the self type).
2149-
let mut input_parameters: HashSet<_> =
2148+
let mut input_parameters: FnvHashSet<_> =
21502149
ctp::parameters_for(&impl_scheme.ty, false).into_iter().collect();
21512150
if let Some(ref trait_ref) = impl_trait_ref {
21522151
input_parameters.extend(ctp::parameters_for(trait_ref, false));
@@ -2175,15 +2174,15 @@ fn enforce_impl_lifetimes_are_constrained<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
21752174
let impl_predicates = ccx.tcx.lookup_predicates(impl_def_id);
21762175
let impl_trait_ref = ccx.tcx.impl_trait_ref(impl_def_id);
21772176

2178-
let mut input_parameters: HashSet<_> =
2177+
let mut input_parameters: FnvHashSet<_> =
21792178
ctp::parameters_for(&impl_scheme.ty, false).into_iter().collect();
21802179
if let Some(ref trait_ref) = impl_trait_ref {
21812180
input_parameters.extend(ctp::parameters_for(trait_ref, false));
21822181
}
21832182
ctp::identify_constrained_type_params(
21842183
&impl_predicates.predicates.as_slice(), impl_trait_ref, &mut input_parameters);
21852184

2186-
let lifetimes_in_associated_types: HashSet<_> = impl_items.iter()
2185+
let lifetimes_in_associated_types: FnvHashSet<_> = impl_items.iter()
21872186
.map(|item| ccx.tcx.impl_or_trait_item(ccx.tcx.map.local_def_id(item.id)))
21882187
.filter_map(|item| match item {
21892188
ty::TypeTraitItem(ref assoc_ty) => assoc_ty.ty,

‎src/librustc_typeck/constrained_type_params.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use rustc::ty::{self, Ty};
1212
use rustc::ty::fold::{TypeFoldable, TypeVisitor};
13-
use std::collections::HashSet;
13+
use rustc::util::nodemap::FnvHashSet;
1414

1515
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
1616
pub enum Parameter {
@@ -71,7 +71,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
7171

7272
pub fn identify_constrained_type_params<'tcx>(predicates: &[ty::Predicate<'tcx>],
7373
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
74-
input_parameters: &mut HashSet<Parameter>)
74+
input_parameters: &mut FnvHashSet<Parameter>)
7575
{
7676
let mut predicates = predicates.to_owned();
7777
setup_constraining_predicates(&mut predicates, impl_trait_ref, input_parameters);
@@ -120,7 +120,7 @@ pub fn identify_constrained_type_params<'tcx>(predicates: &[ty::Predicate<'tcx>]
120120
/// think of any.
121121
pub fn setup_constraining_predicates<'tcx>(predicates: &mut [ty::Predicate<'tcx>],
122122
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
123-
input_parameters: &mut HashSet<Parameter>)
123+
input_parameters: &mut FnvHashSet<Parameter>)
124124
{
125125
// The canonical way of doing the needed topological sort
126126
// would be a DFS, but getting the graph and its ownership

‎src/librustdoc/clean/inline.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! Support for inlining external documentation into the current AST.
1212
13-
use std::collections::HashSet;
1413
use std::iter::once;
1514

1615
use syntax::ast;
@@ -21,6 +20,7 @@ use rustc::hir::def::Def;
2120
use rustc::hir::def_id::DefId;
2221
use rustc::hir::print as pprust;
2322
use rustc::ty::{self, TyCtxt};
23+
use rustc::util::nodemap::FnvHashSet;
2424

2525
use rustc_const_eval::lookup_const_by_id;
2626

@@ -425,7 +425,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
425425
.into_iter()
426426
.map(|meth| meth.name.to_string())
427427
.collect()
428-
}).unwrap_or(HashSet::new());
428+
}).unwrap_or(FnvHashSet());
429429

430430
ret.push(clean::Item {
431431
inner: clean::ImplItem(clean::Impl {
@@ -461,7 +461,7 @@ fn build_module<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
461461
// If we're reexporting a reexport it may actually reexport something in
462462
// two namespaces, so the target may be listed twice. Make sure we only
463463
// visit each node at most once.
464-
let mut visited = HashSet::new();
464+
let mut visited = FnvHashSet();
465465
for item in tcx.sess.cstore.item_children(did) {
466466
match item.def {
467467
cstore::DlDef(Def::ForeignMod(did)) => {

‎src/librustdoc/clean/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ use rustc::hir::print as pprust;
4343
use rustc::ty::subst::Substs;
4444
use rustc::ty;
4545
use rustc::middle::stability;
46+
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
4647

4748
use rustc::hir;
4849

49-
use std::collections::{HashMap, HashSet};
5050
use std::path::PathBuf;
5151
use std::rc::Rc;
5252
use std::sync::Arc;
@@ -121,7 +121,7 @@ pub struct Crate {
121121
pub access_levels: Arc<AccessLevels<DefId>>,
122122
// These are later on moved into `CACHEKEY`, leaving the map empty.
123123
// Only here so that they can be filtered through the rustdoc passes.
124-
pub external_traits: HashMap<DefId, Trait>,
124+
pub external_traits: FnvHashMap<DefId, Trait>,
125125
}
126126

127127
struct CrateNum(ast::CrateNum);
@@ -1010,7 +1010,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>,
10101010
// Note that associated types also have a sized bound by default, but we
10111011
// don't actually know the set of associated types right here so that's
10121012
// handled in cleaning associated types
1013-
let mut sized_params = HashSet::new();
1013+
let mut sized_params = FnvHashSet();
10141014
where_predicates.retain(|pred| {
10151015
match *pred {
10161016
WP::BoundPredicate { ty: Generic(ref g), ref bounds } => {
@@ -1656,9 +1656,9 @@ impl From<ast::FloatTy> for PrimitiveType {
16561656
struct SubstAlias<'a, 'tcx: 'a> {
16571657
tcx: &'a ty::TyCtxt<'a, 'tcx, 'tcx>,
16581658
// Table type parameter definition -> substituted type
1659-
ty_substs: HashMap<Def, hir::Ty>,
1659+
ty_substs: FnvHashMap<Def, hir::Ty>,
16601660
// Table node id of lifetime parameter definition -> substituted lifetime
1661-
lt_substs: HashMap<ast::NodeId, hir::Lifetime>,
1661+
lt_substs: FnvHashMap<ast::NodeId, hir::Lifetime>,
16621662
}
16631663

16641664
impl<'a, 'tcx: 'a, 'b: 'tcx> Folder for SubstAlias<'a, 'tcx> {
@@ -1727,8 +1727,8 @@ impl Clean<Type> for hir::Ty {
17271727
let item = tcx.map.expect_item(node_id);
17281728
if let hir::ItemTy(ref ty, ref generics) = item.node {
17291729
let provided_params = &path.segments.last().unwrap().parameters;
1730-
let mut ty_substs = HashMap::new();
1731-
let mut lt_substs = HashMap::new();
1730+
let mut ty_substs = FnvHashMap();
1731+
let mut lt_substs = FnvHashMap();
17321732
for (i, ty_param) in generics.ty_params.iter().enumerate() {
17331733
let ty_param_def = tcx.expect_def(ty_param.id);
17341734
if let Some(ty) = provided_params.types().get(i).cloned()
@@ -2384,7 +2384,7 @@ impl Clean<ImplPolarity> for hir::ImplPolarity {
23842384
pub struct Impl {
23852385
pub unsafety: hir::Unsafety,
23862386
pub generics: Generics,
2387-
pub provided_trait_methods: HashSet<String>,
2387+
pub provided_trait_methods: FnvHashSet<String>,
23882388
pub trait_: Option<Type>,
23892389
pub for_: Type,
23902390
pub items: Vec<Item>,
@@ -2410,7 +2410,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
24102410
.map(|meth| meth.name.to_string())
24112411
.collect()
24122412
})
2413-
}).unwrap_or(HashSet::new());
2413+
}).unwrap_or(FnvHashSet());
24142414

24152415
ret.push(Item {
24162416
name: None,

‎src/librustdoc/core.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc::middle::privacy::AccessLevels;
1818
use rustc::ty::{self, TyCtxt};
1919
use rustc::hir::map as hir_map;
2020
use rustc::lint;
21+
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
2122
use rustc_trans::back::link;
2223
use rustc_resolve as resolve;
2324
use rustc_metadata::cstore::CStore;
@@ -28,7 +29,6 @@ use errors;
2829
use errors::emitter::ColorConfig;
2930

3031
use std::cell::{RefCell, Cell};
31-
use std::collections::{HashMap, HashSet};
3232
use std::rc::Rc;
3333

3434
use visit_ast::RustdocVisitor;
@@ -45,13 +45,13 @@ pub enum MaybeTyped<'a, 'tcx: 'a> {
4545
NotTyped(&'a session::Session)
4646
}
4747

48-
pub type ExternalPaths = HashMap<DefId, (Vec<String>, clean::TypeKind)>;
48+
pub type ExternalPaths = FnvHashMap<DefId, (Vec<String>, clean::TypeKind)>;
4949

5050
pub struct DocContext<'a, 'tcx: 'a> {
5151
pub map: &'a hir_map::Map<'tcx>,
5252
pub maybe_typed: MaybeTyped<'a, 'tcx>,
5353
pub input: Input,
54-
pub populated_crate_impls: RefCell<HashSet<ast::CrateNum>>,
54+
pub populated_crate_impls: RefCell<FnvHashSet<ast::CrateNum>>,
5555
pub deref_trait_did: Cell<Option<DefId>>,
5656
// Note that external items for which `doc(hidden)` applies to are shown as
5757
// non-reachable while local items aren't. This is because we're reusing
@@ -61,7 +61,7 @@ pub struct DocContext<'a, 'tcx: 'a> {
6161
/// Later on moved into `html::render::CACHE_KEY`
6262
pub renderinfo: RefCell<RenderInfo>,
6363
/// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
64-
pub external_traits: RefCell<HashMap<DefId, clean::Trait>>,
64+
pub external_traits: RefCell<FnvHashMap<DefId, clean::Trait>>,
6565
}
6666

6767
impl<'b, 'tcx> DocContext<'b, 'tcx> {
@@ -178,10 +178,10 @@ pub fn run_core(search_paths: SearchPaths,
178178
map: &tcx.map,
179179
maybe_typed: Typed(tcx),
180180
input: input,
181-
populated_crate_impls: RefCell::new(HashSet::new()),
181+
populated_crate_impls: RefCell::new(FnvHashSet()),
182182
deref_trait_did: Cell::new(None),
183183
access_levels: RefCell::new(access_levels),
184-
external_traits: RefCell::new(HashMap::new()),
184+
external_traits: RefCell::new(FnvHashMap()),
185185
renderinfo: RefCell::new(Default::default()),
186186
};
187187
debug!("crate: {:?}", ctxt.map.krate());

‎src/librustdoc/html/render.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub use self::ExternalLocation::*;
3737
use std::ascii::AsciiExt;
3838
use std::cell::RefCell;
3939
use std::cmp::Ordering;
40-
use std::collections::{BTreeMap, HashMap, HashSet};
40+
use std::collections::BTreeMap;
4141
use std::default::Default;
4242
use std::error;
4343
use std::fmt::{self, Display, Formatter};
@@ -61,6 +61,7 @@ use rustc::middle::privacy::AccessLevels;
6161
use rustc::middle::stability;
6262
use rustc::session::config::get_unstable_features_setting;
6363
use rustc::hir;
64+
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
6465

6566
use clean::{self, Attributes, GetDefId};
6667
use doctree;
@@ -114,9 +115,9 @@ pub struct SharedContext {
114115
/// `true`.
115116
pub include_sources: bool,
116117
/// The local file sources we've emitted and their respective url-paths.
117-
pub local_sources: HashMap<PathBuf, String>,
118+
pub local_sources: FnvHashMap<PathBuf, String>,
118119
/// All the passes that were run on this crate.
119-
pub passes: HashSet<String>,
120+
pub passes: FnvHashSet<String>,
120121
/// The base-URL of the issue tracker for when an item has been tagged with
121122
/// an issue number.
122123
pub issue_tracker_base_url: Option<String>,
@@ -211,43 +212,43 @@ pub struct Cache {
211212
/// Mapping of typaram ids to the name of the type parameter. This is used
212213
/// when pretty-printing a type (so pretty printing doesn't have to
213214
/// painfully maintain a context like this)
214-
pub typarams: HashMap<DefId, String>,
215+
pub typarams: FnvHashMap<DefId, String>,
215216

216217
/// Maps a type id to all known implementations for that type. This is only
217218
/// recognized for intra-crate `ResolvedPath` types, and is used to print
218219
/// out extra documentation on the page of an enum/struct.
219220
///
220221
/// The values of the map are a list of implementations and documentation
221222
/// found on that implementation.
222-
pub impls: HashMap<DefId, Vec<Impl>>,
223+
pub impls: FnvHashMap<DefId, Vec<Impl>>,
223224

224225
/// Maintains a mapping of local crate node ids to the fully qualified name
225226
/// and "short type description" of that node. This is used when generating
226227
/// URLs when a type is being linked to. External paths are not located in
227228
/// this map because the `External` type itself has all the information
228229
/// necessary.
229-
pub paths: HashMap<DefId, (Vec<String>, ItemType)>,
230+
pub paths: FnvHashMap<DefId, (Vec<String>, ItemType)>,
230231

231232
/// Similar to `paths`, but only holds external paths. This is only used for
232233
/// generating explicit hyperlinks to other crates.
233-
pub external_paths: HashMap<DefId, (Vec<String>, ItemType)>,
234+
pub external_paths: FnvHashMap<DefId, (Vec<String>, ItemType)>,
234235

235236
/// This map contains information about all known traits of this crate.
236237
/// Implementations of a crate should inherit the documentation of the
237238
/// parent trait if no extra documentation is specified, and default methods
238239
/// should show up in documentation about trait implementations.
239-
pub traits: HashMap<DefId, clean::Trait>,
240+
pub traits: FnvHashMap<DefId, clean::Trait>,
240241

241242
/// When rendering traits, it's often useful to be able to list all
242243
/// implementors of the trait, and this mapping is exactly, that: a mapping
243244
/// of trait ids to the list of known implementors of the trait
244-
pub implementors: HashMap<DefId, Vec<Implementor>>,
245+
pub implementors: FnvHashMap<DefId, Vec<Implementor>>,
245246

246247
/// Cache of where external crate documentation can be found.
247-
pub extern_locations: HashMap<ast::CrateNum, (String, ExternalLocation)>,
248+
pub extern_locations: FnvHashMap<ast::CrateNum, (String, ExternalLocation)>,
248249

249250
/// Cache of where documentation for primitives can be found.
250-
pub primitive_locations: HashMap<clean::PrimitiveType, ast::CrateNum>,
251+
pub primitive_locations: FnvHashMap<clean::PrimitiveType, ast::CrateNum>,
251252

252253
// Note that external items for which `doc(hidden)` applies to are shown as
253254
// non-reachable while local items aren't. This is because we're reusing
@@ -260,7 +261,7 @@ pub struct Cache {
260261
parent_stack: Vec<DefId>,
261262
parent_is_trait_impl: bool,
262263
search_index: Vec<IndexItem>,
263-
seen_modules: HashSet<DefId>,
264+
seen_modules: FnvHashSet<DefId>,
264265
seen_mod: bool,
265266
stripped_mod: bool,
266267
deref_trait_did: Option<DefId>,
@@ -277,9 +278,9 @@ pub struct Cache {
277278
/// Later on moved into `CACHE_KEY`.
278279
#[derive(Default)]
279280
pub struct RenderInfo {
280-
pub inlined: HashSet<DefId>,
281+
pub inlined: FnvHashSet<DefId>,
281282
pub external_paths: ::core::ExternalPaths,
282-
pub external_typarams: HashMap<DefId, String>,
283+
pub external_typarams: FnvHashMap<DefId, String>,
283284
pub deref_trait_did: Option<DefId>,
284285
}
285286

@@ -377,10 +378,10 @@ impl ToJson for IndexItemFunctionType {
377378
thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default());
378379
thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> =
379380
RefCell::new(Vec::new()));
380-
thread_local!(static USED_ID_MAP: RefCell<HashMap<String, usize>> =
381+
thread_local!(static USED_ID_MAP: RefCell<FnvHashMap<String, usize>> =
381382
RefCell::new(init_ids()));
382383

383-
fn init_ids() -> HashMap<String, usize> {
384+
fn init_ids() -> FnvHashMap<String, usize> {
384385
[
385386
"main",
386387
"search",
@@ -407,7 +408,7 @@ pub fn reset_ids(embedded: bool) {
407408
*s.borrow_mut() = if embedded {
408409
init_ids()
409410
} else {
410-
HashMap::new()
411+
FnvHashMap()
411412
};
412413
});
413414
}
@@ -432,7 +433,7 @@ pub fn derive_id(candidate: String) -> String {
432433
pub fn run(mut krate: clean::Crate,
433434
external_html: &ExternalHtml,
434435
dst: PathBuf,
435-
passes: HashSet<String>,
436+
passes: FnvHashSet<String>,
436437
css_file_extension: Option<PathBuf>,
437438
renderinfo: RenderInfo) -> Result<(), Error> {
438439
let src_root = match krate.src.parent() {
@@ -443,7 +444,7 @@ pub fn run(mut krate: clean::Crate,
443444
src_root: src_root,
444445
passes: passes,
445446
include_sources: true,
446-
local_sources: HashMap::new(),
447+
local_sources: FnvHashMap(),
447448
issue_tracker_base_url: None,
448449
layout: layout::Layout {
449450
logo: "".to_string(),
@@ -513,22 +514,22 @@ pub fn run(mut krate: clean::Crate,
513514
.collect();
514515

515516
let mut cache = Cache {
516-
impls: HashMap::new(),
517+
impls: FnvHashMap(),
517518
external_paths: external_paths,
518-
paths: HashMap::new(),
519-
implementors: HashMap::new(),
519+
paths: FnvHashMap(),
520+
implementors: FnvHashMap(),
520521
stack: Vec::new(),
521522
parent_stack: Vec::new(),
522523
search_index: Vec::new(),
523524
parent_is_trait_impl: false,
524-
extern_locations: HashMap::new(),
525-
primitive_locations: HashMap::new(),
526-
seen_modules: HashSet::new(),
525+
extern_locations: FnvHashMap(),
526+
primitive_locations: FnvHashMap(),
527+
seen_modules: FnvHashSet(),
527528
seen_mod: false,
528529
stripped_mod: false,
529530
access_levels: krate.access_levels.clone(),
530531
orphan_methods: Vec::new(),
531-
traits: mem::replace(&mut krate.external_traits, HashMap::new()),
532+
traits: mem::replace(&mut krate.external_traits, FnvHashMap()),
532533
deref_trait_did: deref_trait_did,
533534
typarams: external_typarams,
534535
};
@@ -574,7 +575,7 @@ pub fn run(mut krate: clean::Crate,
574575

575576
/// Build the search index from the collected metadata
576577
fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
577-
let mut nodeid_to_pathid = HashMap::new();
578+
let mut nodeid_to_pathid = FnvHashMap();
578579
let mut crate_items = Vec::with_capacity(cache.search_index.len());
579580
let mut crate_paths = Vec::<Json>::new();
580581

@@ -2515,7 +2516,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
25152516
#[derive(Copy, Clone)]
25162517
enum AssocItemLink<'a> {
25172518
Anchor(Option<&'a str>),
2518-
GotoSource(DefId, &'a HashSet<String>),
2519+
GotoSource(DefId, &'a FnvHashSet<String>),
25192520
}
25202521

25212522
impl<'a> AssocItemLink<'a> {

‎src/librustdoc/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use std::cell::{RefCell, Cell};
12-
use std::collections::{HashMap, HashSet};
1312
use std::env;
1413
use std::ffi::OsString;
1514
use std::io::prelude::*;
@@ -29,6 +28,7 @@ use rustc::session::{self, config};
2928
use rustc::session::config::{get_unstable_features_setting, OutputType,
3029
OutputTypes, Externs};
3130
use rustc::session::search_paths::{SearchPaths, PathKind};
31+
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
3232
use rustc_back::dynamic_lib::DynamicLibrary;
3333
use rustc_back::tempdir::TempDir;
3434
use rustc_driver::{driver, Compilation};
@@ -107,8 +107,8 @@ pub fn run(input: &str,
107107
map: &map,
108108
maybe_typed: core::NotTyped(&sess),
109109
input: input,
110-
external_traits: RefCell::new(HashMap::new()),
111-
populated_crate_impls: RefCell::new(HashSet::new()),
110+
external_traits: RefCell::new(FnvHashMap()),
111+
populated_crate_impls: RefCell::new(FnvHashSet()),
112112
deref_trait_did: Cell::new(None),
113113
access_levels: Default::default(),
114114
renderinfo: Default::default(),

‎src/librustdoc/visit_ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! Rust AST Visitor. Extracts useful information and massages it into a form
1212
//! usable for clean
1313
14-
use std::collections::HashSet;
1514
use std::mem;
1615

1716
use syntax::abi;
@@ -23,6 +22,7 @@ use syntax_pos::Span;
2322
use rustc::hir::map as hir_map;
2423
use rustc::hir::def::Def;
2524
use rustc::middle::privacy::AccessLevel;
25+
use rustc::util::nodemap::FnvHashSet;
2626

2727
use rustc::hir;
2828

@@ -42,14 +42,14 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
4242
pub module: Module,
4343
pub attrs: hir::HirVec<ast::Attribute>,
4444
pub cx: &'a core::DocContext<'a, 'tcx>,
45-
view_item_stack: HashSet<ast::NodeId>,
45+
view_item_stack: FnvHashSet<ast::NodeId>,
4646
inlining_from_glob: bool,
4747
}
4848

4949
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
5050
pub fn new(cx: &'a core::DocContext<'a, 'tcx>) -> RustdocVisitor<'a, 'tcx> {
5151
// If the root is reexported, terminate all recursion.
52-
let mut stack = HashSet::new();
52+
let mut stack = FnvHashSet();
5353
stack.insert(ast::CRATE_NODE_ID);
5454
RustdocVisitor {
5555
module: Module::new(None),

0 commit comments

Comments
 (0)
Please sign in to comment.