From ee81739dc1e0f1c4dff9480b52528fb688ef9251 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 10:44:26 +0200 Subject: [PATCH 1/9] Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hack --- src/librustc/dep_graph/cgu_reuse_tracker.rs | 4 +- src/librustc/dep_graph/dep_tracking_map.rs | 2 +- src/librustc/dep_graph/graph.rs | 10 +-- src/librustc/dep_graph/query.rs | 2 +- src/librustc/hir/map/definitions.rs | 8 +-- src/librustc/hir/map/hir_id_validator.rs | 2 +- src/librustc/ich/hcx.rs | 2 +- src/librustc/ich/impls_ty.rs | 2 +- src/librustc/infer/freshen.rs | 2 +- src/librustc/infer/higher_ranked/mod.rs | 2 +- .../infer/lexical_region_resolve/graphviz.rs | 4 +- .../infer/lexical_region_resolve/mod.rs | 2 +- src/librustc/infer/mod.rs | 2 +- src/librustc/infer/region_constraints/mod.rs | 4 +- .../infer/region_constraints/taint.rs | 2 +- src/librustc/lint/context.rs | 6 +- src/librustc/lint/levels.rs | 6 +- src/librustc/middle/dead.rs | 4 +- src/librustc/middle/dependency_format.rs | 4 +- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/lib_features.rs | 4 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 4 +- src/librustc/middle/resolve_lifetime.rs | 16 ++--- src/librustc/middle/stability.rs | 12 ++-- src/librustc/mir/interpret/mod.rs | 4 +- src/librustc/mir/mono.rs | 4 +- src/librustc/session/code_stats.rs | 2 +- src/librustc/session/mod.rs | 4 +- src/librustc/traits/auto_trait.rs | 8 +-- src/librustc/traits/error_reporting.rs | 4 +- src/librustc/traits/select.rs | 10 +-- src/librustc/traits/specialize/mod.rs | 2 +- src/librustc/traits/util.rs | 2 +- src/librustc/ty/context.rs | 14 ++-- src/librustc/ty/fold.rs | 2 +- src/librustc/ty/inhabitedness/mod.rs | 4 +- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/query/on_disk_cache.rs | 30 ++++---- src/librustc/ty/query/plumbing.rs | 4 +- src/librustc/ty/util.rs | 2 +- src/librustc/util/nodemap.rs | 4 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 6 +- src/librustc_borrowck/borrowck/unused.rs | 2 +- src/librustc_borrowck/dataflow.rs | 2 +- src/librustc_codegen_llvm/attributes.rs | 2 +- src/librustc_codegen_llvm/back/link.rs | 2 +- src/librustc_codegen_llvm/back/lto.rs | 4 +- src/librustc_codegen_llvm/back/write.rs | 2 +- src/librustc_codegen_llvm/base.rs | 16 ++--- src/librustc_codegen_llvm/context.rs | 18 ++--- .../debuginfo/metadata.rs | 6 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 6 +- src/librustc_codegen_utils/codegen_backend.rs | 2 +- src/librustc_data_structures/fx.rs | 15 ---- .../obligation_forest/mod.rs | 8 +-- .../snapshot_map/mod.rs | 2 +- .../transitive_relation.rs | 2 +- src/librustc_errors/lib.rs | 8 +-- src/librustc_incremental/assert_dep_graph.rs | 2 +- .../persist/dirty_clean.rs | 2 +- src/librustc_incremental/persist/fs.rs | 12 ++-- src/librustc_incremental/persist/load.rs | 8 +-- src/librustc_incremental/persist/save.rs | 2 +- src/librustc_lint/types.rs | 2 +- src/librustc_metadata/creader.rs | 6 +- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- src/librustc_metadata/locator.rs | 10 +-- src/librustc_metadata/native_libs.rs | 2 +- src/librustc_mir/borrow_check/borrow_set.rs | 10 +-- .../borrow_check/error_reporting.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 8 +-- .../nll/explain_borrow/find_use.rs | 2 +- .../borrow_check/nll/type_check/mod.rs | 4 +- src/librustc_mir/build/matches/mod.rs | 2 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/build/scope.rs | 2 +- src/librustc_mir/dataflow/impls/borrows.rs | 4 +- .../dataflow/move_paths/builder.rs | 2 +- src/librustc_mir/interpret/validity.rs | 2 +- src/librustc_mir/monomorphize/collector.rs | 4 +- src/librustc_mir/monomorphize/partitioning.rs | 14 ++-- src/librustc_mir/transform/check_unsafety.rs | 2 +- .../transform/cleanup_post_borrowck.rs | 4 +- src/librustc_mir/transform/elaborate_drops.rs | 2 +- src/librustc_mir/transform/qualify_consts.rs | 2 +- src/librustc_mir/util/pretty.rs | 2 +- src/librustc_passes/hir_stats.rs | 8 +-- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/lib.rs | 72 +++++++++---------- src/librustc_resolve/resolve_imports.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 4 +- src/librustc_traits/dropck_outlives.rs | 6 +- src/librustc_traits/lowering/environment.rs | 4 +- src/librustc_typeck/check/_match.rs | 2 +- .../check/generator_interior.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 8 +-- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 4 +- src/librustc_typeck/check/wfcheck.rs | 4 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/impl_wf_check.rs | 4 +- src/librustdoc/clean/auto_trait.rs | 18 ++--- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/clean/mod.rs | 16 ++--- src/librustdoc/core.rs | 6 +- src/librustdoc/html/render.rs | 30 ++++---- src/librustdoc/visit_ast.rs | 4 +- src/librustdoc/visit_lib.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/source_map.rs | 4 +- src/libsyntax_pos/hygiene.rs | 2 +- 115 files changed, 318 insertions(+), 333 deletions(-) diff --git a/src/librustc/dep_graph/cgu_reuse_tracker.rs b/src/librustc/dep_graph/cgu_reuse_tracker.rs index 2a0891787f841..8e6983e9ddfe0 100644 --- a/src/librustc/dep_graph/cgu_reuse_tracker.rs +++ b/src/librustc/dep_graph/cgu_reuse_tracker.rs @@ -51,8 +51,8 @@ pub struct CguReuseTracker { impl CguReuseTracker { pub fn new() -> CguReuseTracker { let data = TrackerData { - actual_reuse: FxHashMap(), - expected_reuse: FxHashMap(), + actual_reuse: FxHashMap::default(), + expected_reuse: FxHashMap::default(), }; CguReuseTracker { diff --git a/src/librustc/dep_graph/dep_tracking_map.rs b/src/librustc/dep_graph/dep_tracking_map.rs index 7e46c202a84d4..33b10bcfc8a92 100644 --- a/src/librustc/dep_graph/dep_tracking_map.rs +++ b/src/librustc/dep_graph/dep_tracking_map.rs @@ -36,7 +36,7 @@ impl DepTrackingMap { DepTrackingMap { phantom: PhantomData, graph, - map: FxHashMap(), + map: FxHashMap::default(), } } } diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index f5a46060759dd..971f4e86c5e0c 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -101,11 +101,11 @@ impl DepGraph { DepGraph { data: Some(Lrc::new(DepGraphData { previous_work_products: prev_work_products, - dep_node_debug: Lock::new(FxHashMap()), + dep_node_debug: Lock::new(FxHashMap::default()), current: Lock::new(CurrentDepGraph::new()), previous: prev_graph, colors: Lock::new(DepNodeColorMap::new(prev_graph_node_count)), - loaded_from_cache: Lock::new(FxHashMap()), + loaded_from_cache: Lock::new(FxHashMap::default()), })), fingerprints: Lrc::new(Lock::new(fingerprints)), } @@ -209,7 +209,7 @@ impl DepGraph { |key| OpenTask::Regular(Lock::new(RegularOpenTask { node: key, reads: SmallVec::new(), - read_set: FxHashSet(), + read_set: FxHashSet::default(), })), |data, key, task| data.borrow_mut().complete_task(key, task)) } @@ -353,7 +353,7 @@ impl DepGraph { let (result, open_task) = ty::tls::with_context(|icx| { let task = OpenTask::Anon(Lock::new(AnonOpenTask { reads: SmallVec::new(), - read_set: FxHashSet(), + read_set: FxHashSet::default(), })); let r = { @@ -937,7 +937,7 @@ impl CurrentDepGraph { CurrentDepGraph { nodes: IndexVec::new(), edges: IndexVec::new(), - node_to_node_index: FxHashMap(), + node_to_node_index: FxHashMap::default(), anon_id_seed: stable_hasher.finish(), forbidden_edge, total_read_count: 0, diff --git a/src/librustc/dep_graph/query.rs b/src/librustc/dep_graph/query.rs index ce0b5557a34bf..4aec2af887c88 100644 --- a/src/librustc/dep_graph/query.rs +++ b/src/librustc/dep_graph/query.rs @@ -25,7 +25,7 @@ impl DepGraphQuery { edges: &[(DepNode, DepNode)]) -> DepGraphQuery { let mut graph = Graph::with_capacity(nodes.len(), edges.len()); - let mut indices = FxHashMap(); + let mut indices = FxHashMap::default(); for node in nodes { indices.insert(node.clone(), graph.add_node(node.clone())); } diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index fa4bf1511b874..54d662cce3336 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -421,10 +421,10 @@ impl Definitions { node_to_def_index: NodeMap(), def_index_to_node: [vec![], vec![]], node_to_hir_id: IndexVec::new(), - parent_modules_of_macro_defs: FxHashMap(), - expansions_that_defined: FxHashMap(), - next_disambiguator: FxHashMap(), - def_index_to_span: FxHashMap(), + parent_modules_of_macro_defs: FxHashMap::default(), + expansions_that_defined: FxHashMap::default(), + next_disambiguator: FxHashMap::default(), + def_index_to_span: FxHashMap::default(), } } diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index d61b5313444f3..d8dc75a059029 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -51,7 +51,7 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> { HirIdValidator { hir_map, owner_def_index: None, - hir_ids_seen: FxHashMap(), + hir_ids_seen: FxHashMap::default(), errors: Vec::new(), } } diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 0694c0f05b093..f0ab449b70289 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -370,7 +370,7 @@ impl<'a> HashStable> for Span { // recursing every time. thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap()); + RefCell::new(FxHashMap::default()); } let sub_hash: u64 = CACHE.with(|cache| { diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 43448ad0d15ad..63a3534fb706a 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -32,7 +32,7 @@ for &'gcx ty::List hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap()); + RefCell::new(FxHashMap::default()); } let hash = CACHE.with(|cache| { diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 969d260d97e21..26c252cef0921 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> { TypeFreshener { infcx, freshen_count: 0, - freshen_map: FxHashMap(), + freshen_map: FxHashMap::default(), } } diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index ae1892caa744e..d85a3e84f857a 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -553,7 +553,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let escaping_types = self.type_variables.borrow_mut().types_escaping_snapshot(&snapshot.type_snapshot); - let mut escaping_region_vars = FxHashSet(); + let mut escaping_region_vars = FxHashSet::default(); for ty in &escaping_types { self.tcx.collect_regions(ty, &mut escaping_region_vars); } diff --git a/src/librustc/infer/lexical_region_resolve/graphviz.rs b/src/librustc/infer/lexical_region_resolve/graphviz.rs index b55727d2c84f0..3b92d032bdc5a 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -143,7 +143,7 @@ impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> { map: &'a ConstraintMap<'tcx>) -> ConstraintGraph<'a, 'gcx, 'tcx> { let mut i = 0; - let mut node_ids = FxHashMap(); + let mut node_ids = FxHashMap::default(); { let mut add_node = |node| { if let Vacant(e) = node_ids.entry(node) { @@ -230,7 +230,7 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { type Node = Node; type Edge = Edge<'tcx>; fn nodes(&self) -> dot::Nodes<'_, Node> { - let mut set = FxHashSet(); + let mut set = FxHashSet::default(); for node in self.node_ids.keys() { set.insert(*node); } diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index caba8b514f797..066951c930b80 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -614,7 +614,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { dup_found: bool, } let mut state = WalkState { - set: FxHashSet(), + set: FxHashSet::default(), stack: vec![orig_node_idx], result: Vec::new(), dup_found: false, diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index fbd38ebd78ced..c1c09a7e7fa35 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -534,7 +534,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> { lexical_region_resolutions: RefCell::new(None), selection_cache: traits::SelectionCache::new(), evaluation_cache: traits::EvaluationCache::new(), - reported_trait_errors: RefCell::new(FxHashMap()), + reported_trait_errors: RefCell::new(FxHashMap::default()), tainted_by_errors_flag: Cell::new(false), err_count_on_creation: tcx.sess.err_count(), in_snapshot: Cell::new(false), diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index 525ae03dfaf93..d631ddbf31dc3 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -345,8 +345,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> { RegionConstraintCollector { var_infos: VarInfos::default(), data: RegionConstraintData::default(), - lubs: FxHashMap(), - glbs: FxHashMap(), + lubs: FxHashMap::default(), + glbs: FxHashMap::default(), bound_count: 0, undo_log: Vec::new(), unification_table: ut::UnificationTable::new(), diff --git a/src/librustc/infer/region_constraints/taint.rs b/src/librustc/infer/region_constraints/taint.rs index 4f513cd5d484d..ef7365276f6d2 100644 --- a/src/librustc/infer/region_constraints/taint.rs +++ b/src/librustc/infer/region_constraints/taint.rs @@ -18,7 +18,7 @@ pub(super) struct TaintSet<'tcx> { impl<'tcx> TaintSet<'tcx> { pub(super) fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self { - let mut regions = FxHashSet(); + let mut regions = FxHashSet::default(); regions.insert(initial_region); TaintSet { directions: directions, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 852af2cdaa237..730f85a3dd0bb 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -159,9 +159,9 @@ impl LintStore { pre_expansion_passes: Some(vec![]), early_passes: Some(vec![]), late_passes: Some(vec![]), - by_name: FxHashMap(), - future_incompatible: FxHashMap(), - lint_groups: FxHashMap(), + by_name: FxHashMap::default(), + future_incompatible: FxHashMap::default(), + lint_groups: FxHashMap::default(), } } diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 950754a07ab09..f775ddf210f8e 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -59,7 +59,7 @@ impl LintLevelSets { fn process_command_line(&mut self, sess: &Session) { let store = sess.lint_store.borrow(); - let mut specs = FxHashMap(); + let mut specs = FxHashMap::default(); self.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid); for &(ref lint_name, level) in &sess.opts.lint_opts { @@ -175,7 +175,7 @@ impl<'a> LintLevelsBuilder<'a> { sess, sets, cur: 0, - id_to_set: FxHashMap(), + id_to_set: FxHashMap::default(), warn_about_weird_lints: sess.buffered_lints.borrow().is_some(), } } @@ -195,7 +195,7 @@ impl<'a> LintLevelsBuilder<'a> { /// /// Don't forget to call `pop`! pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush { - let mut specs = FxHashMap(); + let mut specs = FxHashMap::default(); let store = self.sess.lint_store.borrow(); let sess = self.sess; let bad_attr = |span| { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index ea90922b11066..06547796972b1 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -131,7 +131,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } fn mark_live_symbols(&mut self) { - let mut scanned = FxHashSet(); + let mut scanned = FxHashSet::default(); while let Some(id) = self.worklist.pop() { if !scanned.insert(id) { continue @@ -429,7 +429,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, worklist, tcx, tables: &ty::TypeckTables::empty(None), - live_symbols: box FxHashSet(), + live_symbols: box FxHashSet::default(), repr_has_repr_c: false, in_pat: false, inherited_pub_visibility: false, diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 95fb35165e760..8b5c6d147d781 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -94,7 +94,7 @@ pub enum Linkage { pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let sess = &tcx.sess; - let mut fmts = FxHashMap(); + let mut fmts = FxHashMap::default(); for &ty in sess.crate_types.borrow().iter() { let linkage = calculate_type(tcx, ty); verify_ok(tcx, &linkage); @@ -170,7 +170,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - let mut formats = FxHashMap(); + let mut formats = FxHashMap::default(); // Sweep all crates for found dylibs. Add all dylibs, as well as their // dependencies, ensuring there are no conflicts. The only valid case for a diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index c5d028c1735d5..45de958e72eba 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -155,7 +155,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItemCollector<'a, 'tcx> { - let mut item_refs = FxHashMap(); + let mut item_refs = FxHashMap::default(); $( item_refs.insert($name, ($variant as usize, $target)); )* diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index 6055a05158fe0..aaa218926f867 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -31,8 +31,8 @@ pub struct LibFeatures { impl LibFeatures { fn new() -> LibFeatures { LibFeatures { - stable: FxHashMap(), - unstable: FxHashSet(), + stable: FxHashMap::default(), + unstable: FxHashSet::default(), } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 55e5663f030b2..8c3a3fb6dc1d8 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -207,7 +207,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Step 2: Mark all symbols that the symbols on the worklist touch. fn propagate(&mut self) { - let mut scanned = FxHashSet(); + let mut scanned = FxHashSet::default(); while let Some(search_item) = self.worklist.pop() { if !scanned.insert(search_item) { continue diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index a90f03f536ad5..3e49dec4401d8 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -1257,7 +1257,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { let outer_ec = mem::replace(&mut self.expr_and_pat_count, 0); let outer_cx = self.cx; - let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet()); + let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet::default()); self.terminating_scopes.insert(body.value.hir_id.local_id); if let Some(root_id) = self.cx.root_id { @@ -1347,7 +1347,7 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) parent: None, var_parent: None, }, - terminating_scopes: FxHashSet(), + terminating_scopes: FxHashSet::default(), }; let body = tcx.hir.body(body_id); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 2f3fdb7966f25..d959029d1202a 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -393,9 +393,9 @@ fn resolve_lifetimes<'tcx>( let named_region_map = krate(tcx); let mut rl = ResolveLifetimes { - defs: FxHashMap(), - late_bound: FxHashMap(), - object_lifetime_defaults: FxHashMap(), + defs: FxHashMap::default(), + late_bound: FxHashMap::default(), + object_lifetime_defaults: FxHashMap::default(), }; for (k, v) in named_region_map.defs { @@ -692,7 +692,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { debug!("visit_ty: index = {}", index); let mut elision = None; - let mut lifetimes = FxHashMap(); + let mut lifetimes = FxHashMap::default(); let mut type_count = 0; for param in &generics.params { match param.kind { @@ -2017,7 +2017,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { map: self.map, outer_index: ty::INNERMOST, have_bound_regions: false, - lifetimes: FxHashSet(), + lifetimes: FxHashSet::default(), }; gather.visit_ty(input); @@ -2537,14 +2537,14 @@ fn insert_late_bound_lifetimes( decl, generics); let mut constrained_by_input = ConstrainedCollector { - regions: FxHashSet(), + regions: FxHashSet::default(), }; for arg_ty in &decl.inputs { constrained_by_input.visit_ty(arg_ty); } let mut appears_in_output = AllCollector { - regions: FxHashSet(), + regions: FxHashSet::default(), }; intravisit::walk_fn_ret_ty(&mut appears_in_output, &decl.output); @@ -2556,7 +2556,7 @@ fn insert_late_bound_lifetimes( // Subtle point: because we disallow nested bindings, we can just // ignore binders here and scrape up all names we see. let mut appears_in_where_clause = AllCollector { - regions: FxHashSet(), + regions: FxHashSet::default(), }; appears_in_where_clause.visit_generics(generics); diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 9dd13dd2272b0..a5d3e8023bd12 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -401,13 +401,13 @@ impl<'a, 'tcx> Index<'tcx> { let is_staged_api = tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api; - let mut staged_api = FxHashMap(); + let mut staged_api = FxHashMap::default(); staged_api.insert(LOCAL_CRATE, is_staged_api); let mut index = Index { staged_api, - stab_map: FxHashMap(), - depr_map: FxHashMap(), - active_features: FxHashSet(), + stab_map: FxHashMap::default(), + depr_map: FxHashMap::default(), + active_features: FxHashSet::default(), }; let ref active_lib_features = tcx.features().declared_lib_features; @@ -814,7 +814,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } let declared_lang_features = &tcx.features().declared_lang_features; - let mut lang_features = FxHashSet(); + let mut lang_features = FxHashSet::default(); for &(feature, span, since) in declared_lang_features { if let Some(since) = since { // Warn if the user has enabled an already-stable lang feature. @@ -828,7 +828,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } let declared_lib_features = &tcx.features().declared_lib_features; - let mut remaining_lib_features = FxHashMap(); + let mut remaining_lib_features = FxHashMap::default(); for (feature, span) in declared_lib_features { if remaining_lib_features.contains_key(&feature) { // Warn if the user enables a lib feature multiple times. diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 5eee0fba5fb46..a5e37274b8e3d 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -453,8 +453,8 @@ pub struct AllocMap<'tcx, M> { impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> { pub fn new() -> Self { AllocMap { - id_to_type: FxHashMap(), - type_interner: FxHashMap(), + id_to_type: FxHashMap::default(), + type_interner: FxHashMap::default(), next_id: AllocId(0), } } diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 7520695a7cd90..9b31d12981553 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -121,7 +121,7 @@ impl<'tcx> CodegenUnit<'tcx> { pub fn new(name: InternedString) -> CodegenUnit<'tcx> { CodegenUnit { name: name, - items: FxHashMap(), + items: FxHashMap::default(), size_estimate: None, } } @@ -251,7 +251,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> { pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self { CodegenUnitNameBuilder { tcx, - cache: FxHashMap(), + cache: FxHashMap::default(), } } diff --git a/src/librustc/session/code_stats.rs b/src/librustc/session/code_stats.rs index 32865acb298fa..eb9bfe984229b 100644 --- a/src/librustc/session/code_stats.rs +++ b/src/librustc/session/code_stats.rs @@ -60,7 +60,7 @@ pub struct CodeStats { } impl CodeStats { - pub fn new() -> Self { CodeStats { type_sizes: FxHashSet() } } + pub fn new() -> Self { CodeStats { type_sizes: FxHashSet::default() } } pub fn record_type_size(&mut self, kind: DataTypeKind, diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 2b90a27b6a8ce..fccdbcb5c2f87 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1147,7 +1147,7 @@ pub fn build_session_( working_dir, lint_store: RwLock::new(lint::LintStore::new()), buffered_lints: Lock::new(Some(lint::LintBuffer::new())), - one_time_diagnostics: Lock::new(FxHashSet()), + one_time_diagnostics: Lock::new(FxHashSet::default()), plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())), plugin_attributes: OneThread::new(RefCell::new(Vec::new())), crate_types: Once::new(), @@ -1207,7 +1207,7 @@ pub fn build_session_( }, has_global_allocator: Once::new(), has_panic_handler: Once::new(), - driver_lint_caps: FxHashMap(), + driver_lint_caps: FxHashMap::default(), }; validate_commandline_args_with_session_available(&sess); diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 1e5ce15914d6a..06d548909b549 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -131,7 +131,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } return tcx.infer_ctxt().enter(|mut infcx| { - let mut fresh_preds = FxHashSet(); + let mut fresh_preds = FxHashSet::default(); // Due to the way projections are handled by SelectionContext, we need to run // evaluate_predicates twice: once on the original param env, and once on the result of @@ -311,7 +311,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { let mut select = SelectionContext::new(&infcx); - let mut already_visited = FxHashSet(); + let mut already_visited = FxHashSet::default(); let mut predicates = VecDeque::new(); predicates.push_back(ty::Binder::bind(ty::TraitPredicate { trait_ref: ty::TraitRef { @@ -508,8 +508,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { &self, regions: &RegionConstraintData<'cx>, ) -> FxHashMap> { - let mut vid_map: FxHashMap, RegionDeps<'cx>> = FxHashMap(); - let mut finished_map = FxHashMap(); + let mut vid_map: FxHashMap, RegionDeps<'cx>> = FxHashMap::default(); + let mut finished_map = FxHashMap::default(); for constraint in regions.constraints.keys() { match constraint { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index db775beae4f97..4bc2413357181 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1258,7 +1258,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { trait_str); err.span_label(span, format!("the trait `{}` cannot be made into an object", trait_str)); - let mut reported_violations = FxHashSet(); + let mut reported_violations = FxHashSet::default(); for violation in violations { if reported_violations.insert(violation.clone()) { err.note(&violation.error_msg()); @@ -1404,7 +1404,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let cleaned_pred = pred.fold_with(&mut ParamToVarFolder { infcx: self, - var_map: FxHashMap() + var_map: FxHashMap::default() }); let cleaned_pred = super::project::normalize( diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 156a27a7d0abd..9e541799120ae 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -3742,7 +3742,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } } else { // Three or more elements. Use a general deduplication process. - let mut seen = FxHashSet(); + let mut seen = FxHashSet::default(); predicates.retain(|i| seen.insert(i.clone())); } self.infcx() @@ -3791,24 +3791,24 @@ impl<'tcx> TraitObligation<'tcx> { impl<'tcx> SelectionCache<'tcx> { pub fn new() -> SelectionCache<'tcx> { SelectionCache { - hashmap: Lock::new(FxHashMap()), + hashmap: Lock::new(FxHashMap::default()), } } pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap() + *self.hashmap.borrow_mut() = FxHashMap::default() } } impl<'tcx> EvaluationCache<'tcx> { pub fn new() -> EvaluationCache<'tcx> { EvaluationCache { - hashmap: Lock::new(FxHashMap()), + hashmap: Lock::new(FxHashMap::default()), } } pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap() + *self.hashmap.borrow_mut() = FxHashMap::default() } } diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 2c713c0f7f1aa..010b79f7d585b 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -291,7 +291,7 @@ pub struct SpecializesCache { impl SpecializesCache { pub fn new() -> Self { SpecializesCache { - map: FxHashMap() + map: FxHashMap::default() } } diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 7c273fb14db54..81fa1ea02b06b 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -59,7 +59,7 @@ struct PredicateSet<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> { fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PredicateSet<'a, 'gcx, 'tcx> { - PredicateSet { tcx: tcx, set: FxHashSet() } + PredicateSet { tcx: tcx, set: FxHashSet::default() } } fn insert(&mut self, pred: &ty::Predicate<'tcx>) -> bool { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 1bccd05af8323..2325570c40ff6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -462,7 +462,7 @@ impl<'tcx> TypeckTables<'tcx> { adjustments: ItemLocalMap(), pat_binding_modes: ItemLocalMap(), pat_adjustments: ItemLocalMap(), - upvar_capture_map: FxHashMap(), + upvar_capture_map: FxHashMap::default(), closure_kind_origins: ItemLocalMap(), liberated_fn_sigs: ItemLocalMap(), fru_field_types: ItemLocalMap(), @@ -470,7 +470,7 @@ impl<'tcx> TypeckTables<'tcx> { used_trait_imports: Lrc::new(DefIdSet()), tainted_by_errors: false, free_region_map: FreeRegionMap::new(), - concrete_existential_types: FxHashMap(), + concrete_existential_types: FxHashMap::default(), } } @@ -1190,7 +1190,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { None }; - let mut trait_map: FxHashMap<_, Lrc>> = FxHashMap(); + let mut trait_map: FxHashMap<_, Lrc>> = FxHashMap::default(); for (k, v) in resolutions.trait_map { let hir_id = hir.node_to_hir_id(k); let map = trait_map.entry(hir_id.owner).or_default(); @@ -1231,14 +1231,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { extern_providers, on_disk_query_result_cache, ), - rcache: Lock::new(FxHashMap()), + rcache: Lock::new(FxHashMap::default()), selection_cache: traits::SelectionCache::new(), evaluation_cache: traits::EvaluationCache::new(), crate_name: Symbol::intern(crate_name), data_layout, - layout_interner: Lock::new(FxHashSet()), - stability_interner: Lock::new(FxHashSet()), - allocation_interner: Lock::new(FxHashSet()), + layout_interner: Lock::new(FxHashSet::default()), + stability_interner: Lock::new(FxHashSet::default()), + allocation_interner: Lock::new(FxHashSet::default()), alloc_map: Lock::new(interpret::AllocMap::new()), tx_to_llvm_workers: Lock::new(tx), output_filenames: Arc::new(output_filenames.clone()), diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index f54dcfa37e944..cdb0500ec61bf 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -753,7 +753,7 @@ impl LateBoundRegionsCollector { fn new(just_constrained: bool) -> Self { LateBoundRegionsCollector { current_index: ty::INNERMOST, - regions: FxHashSet(), + regions: FxHashSet::default(), just_constrained, } } diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index ef5b223620032..56fe479ffc555 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -113,7 +113,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } fn ty_inhabitedness_forest(self, ty: Ty<'tcx>) -> DefIdForest { - ty.uninhabited_from(&mut FxHashMap(), self) + ty.uninhabited_from(&mut FxHashMap::default(), self) } pub fn is_enum_variant_uninhabited_from(self, @@ -140,7 +140,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let adt_kind = self.adt_def(adt_def_id).adt_kind(); // Compute inhabitedness forest: - variant.uninhabited_from(&mut FxHashMap(), self, substs, adt_kind) + variant.uninhabited_from(&mut FxHashMap::default(), self, substs, adt_kind) } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 45a70be5842fc..aba488095bdec 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1842,7 +1842,7 @@ impl<'a> HashStable> for AdtDef { hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap()); + RefCell::new(FxHashMap::default()); } let hash: Fingerprint = CACHE.with(|cache| { diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index ce580c7803355..7deb8d77c3105 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -136,14 +136,14 @@ impl<'sess> OnDiskCache<'sess> { OnDiskCache { serialized_data: data, file_index_to_stable_id: footer.file_index_to_stable_id, - file_index_to_file: Lock::new(FxHashMap()), + file_index_to_file: Lock::new(FxHashMap::default()), prev_cnums: footer.prev_cnums, cnum_map: Once::new(), source_map: sess.source_map(), - current_diagnostics: Lock::new(FxHashMap()), + current_diagnostics: Lock::new(FxHashMap::default()), query_result_index: footer.query_result_index.into_iter().collect(), prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(), - synthetic_expansion_infos: Lock::new(FxHashMap()), + synthetic_expansion_infos: Lock::new(FxHashMap::default()), alloc_decoding_state: AllocDecodingState::new(footer.interpret_alloc_index), } } @@ -151,15 +151,15 @@ impl<'sess> OnDiskCache<'sess> { pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> { OnDiskCache { serialized_data: Vec::new(), - file_index_to_stable_id: FxHashMap(), - file_index_to_file: Lock::new(FxHashMap()), + file_index_to_stable_id: FxHashMap::default(), + file_index_to_file: Lock::new(FxHashMap::default()), prev_cnums: vec![], cnum_map: Once::new(), source_map, - current_diagnostics: Lock::new(FxHashMap()), - query_result_index: FxHashMap(), - prev_diagnostics_index: FxHashMap(), - synthetic_expansion_infos: Lock::new(FxHashMap()), + current_diagnostics: Lock::new(FxHashMap::default()), + query_result_index: FxHashMap::default(), + prev_diagnostics_index: FxHashMap::default(), + synthetic_expansion_infos: Lock::new(FxHashMap::default()), alloc_decoding_state: AllocDecodingState::new(Vec::new()), } } @@ -174,8 +174,8 @@ impl<'sess> OnDiskCache<'sess> { tcx.dep_graph.with_ignore(|| { // Allocate SourceFileIndices let (file_to_file_index, file_index_to_stable_id) = { - let mut file_to_file_index = FxHashMap(); - let mut file_index_to_stable_id = FxHashMap(); + let mut file_to_file_index = FxHashMap::default(); + let mut file_index_to_stable_id = FxHashMap::default(); for (index, file) in tcx.sess.source_map().files().iter().enumerate() { let index = SourceFileIndex(index as u32); @@ -190,10 +190,10 @@ impl<'sess> OnDiskCache<'sess> { let mut encoder = CacheEncoder { tcx, encoder, - type_shorthands: FxHashMap(), - predicate_shorthands: FxHashMap(), - expn_info_shorthands: FxHashMap(), - interpret_allocs: FxHashMap(), + type_shorthands: FxHashMap::default(), + predicate_shorthands: FxHashMap::default(), + expn_info_shorthands: FxHashMap::default(), + interpret_allocs: FxHashMap::default(), interpret_allocs_inverse: Vec::new(), source_map: CachingSourceMapView::new(tcx.sess.source_map()), file_to_file_index, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index f83f8bcf1a12d..461acd72865e4 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -58,8 +58,8 @@ impl QueryValue { impl<'tcx, M: QueryConfig<'tcx>> QueryCache<'tcx, M> { pub(super) fn new() -> QueryCache<'tcx, M> { QueryCache { - results: FxHashMap(), - active: FxHashMap(), + results: FxHashMap::default(), + active: FxHashMap::default(), } } } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 5f63f11338a15..00a1bfaacd781 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -846,7 +846,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { // contains a different, structurally recursive type, maintain a stack // of seen types and check recursion for each of them (issues #3008, #3779). let mut seen: Vec> = Vec::new(); - let mut representable_cache = FxHashMap(); + let mut representable_cache = FxHashMap::default(); let r = is_type_structurally_recursive( tcx, sp, &mut seen, &mut representable_cache, self); debug!("is_type_representable: {:?} is {:?}", self, r); diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 0dc71af9db694..7946d5a047c96 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -22,9 +22,9 @@ pub use rustc_data_structures::fx::FxHashSet; macro_rules! define_id_collections { ($map_name:ident, $set_name:ident, $key:ty) => { pub type $map_name = FxHashMap<$key, T>; - pub fn $map_name() -> $map_name { FxHashMap() } + pub fn $map_name() -> $map_name { FxHashMap::default() } pub type $set_name = FxHashSet<$key>; - pub fn $set_name() -> $set_name { FxHashSet() } + pub fn $set_name() -> $set_name { FxHashSet::default() } } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index f3b5503b8d0fc..17deede5327f6 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -182,7 +182,7 @@ impl PrintContext { fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Binder) where T: TypeFoldable<'tcx> { - let mut collector = LateBoundRegionNameCollector(FxHashSet()); + let mut collector = LateBoundRegionNameCollector(FxHashSet::default()); value.visit_with(&mut collector); self.used_region_names = Some(collector.0); self.region_index = 0; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 0ef0d284770f5..ca69eb90c37b2 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -103,7 +103,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) // tuple structs/variants) do not have an associated body // and do not need borrowchecking. return Lrc::new(BorrowCheckResult { - used_mut_nodes: FxHashSet(), + used_mut_nodes: FxHashSet::default(), signalled_any_error: SignalledError::NoErrorsSeen, }) } @@ -120,7 +120,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet()), + used_mut_nodes: RefCell::new(FxHashSet::default()), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; @@ -235,7 +235,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet()), + used_mut_nodes: RefCell::new(FxHashSet::default()), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index b1f89ce33fcfa..7d2bcd61e156e 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -45,7 +45,7 @@ struct UnusedMutCx<'a, 'tcx: 'a> { impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { fn check_unused_mut_pat(&self, pats: &[P]) { let tcx = self.bccx.tcx; - let mut mutables: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut mutables: FxHashMap<_, Vec<_>> = FxHashMap::default(); for p in pats { p.each_binding(|_, hir_id, span, ident| { // Skip anything that looks like `_foo` diff --git a/src/librustc_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs index 832b69cb2acc4..1760fb138ead8 100644 --- a/src/librustc_borrowck/dataflow.rs +++ b/src/librustc_borrowck/dataflow.rs @@ -169,7 +169,7 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O fn build_local_id_to_index(body: Option<&hir::Body>, cfg: &cfg::CFG) -> FxHashMap> { - let mut index = FxHashMap(); + let mut index = FxHashMap::default(); // FIXME(#15020) Would it be better to fold formals from decl // into cfg itself? i.e. introduce a fn-based flow-graph in diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index 90ba103ca4ceb..a09a2b0fc4f8c 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -297,7 +297,7 @@ pub fn provide_extern(providers: &mut Providers) { } ).collect::>(); - let mut ret = FxHashMap(); + let mut ret = FxHashMap::default(); for lib in tcx.foreign_modules(cnum).iter() { let module = def_id_to_native_lib .get(&lib.def_id) diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 9fac343b846e4..86c6a5e65b0e9 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -1313,7 +1313,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker, // for the current implementation of the standard library. let mut group_end = None; let mut group_start = None; - let mut end_with = FxHashSet(); + let mut end_with = FxHashSet::default(); let info = &codegen_results.crate_info; for &(cnum, _) in deps.iter().rev() { if let Some(missing) = info.missing_lang_items.get(&cnum) { diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index 3ac22f4eaef65..f648efb47df14 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -882,7 +882,7 @@ pub struct ThinLTOImports { impl ThinLTOImports { fn new() -> ThinLTOImports { ThinLTOImports { - imports: FxHashMap(), + imports: FxHashMap::default(), } } @@ -911,7 +911,7 @@ impl ThinLTOImports { .push(imported_module_name.to_owned()); } let mut map = ThinLTOImports { - imports: FxHashMap(), + imports: FxHashMap::default(), }; llvm::LLVMRustGetThinLTOModuleImports(data, imported_module_callback, diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 95281e2445a1c..81619c219757b 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -1540,7 +1540,7 @@ fn start_executing_work(tcx: TyCtxt, // Compute the set of symbols we need to retain when doing LTO (if we need to) let exported_symbols = { - let mut exported_symbols = FxHashMap(); + let mut exported_symbols = FxHashMap::default(); let copy_symbols = |cnum| { let symbols = tcx.exported_symbols(cnum) diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index c814ab4ab6710..5356014f67196 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -1030,7 +1030,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( }).collect(); if tcx.sess.opts.debugging_opts.print_mono_items.is_some() { - let mut item_to_cgus: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut item_to_cgus: FxHashMap<_, Vec<_>> = FxHashMap::default(); for cgu in &codegen_units { for (&mono_item, &linkage) in cgu.items() { @@ -1092,17 +1092,17 @@ impl CrateInfo { compiler_builtins: None, profiler_runtime: None, sanitizer_runtime: None, - is_no_builtins: FxHashSet(), - native_libraries: FxHashMap(), + is_no_builtins: FxHashSet::default(), + native_libraries: FxHashMap::default(), used_libraries: tcx.native_libraries(LOCAL_CRATE), link_args: tcx.link_args(LOCAL_CRATE), - crate_name: FxHashMap(), + crate_name: FxHashMap::default(), used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), - used_crate_source: FxHashMap(), - wasm_imports: FxHashMap(), - lang_item_to_crate: FxHashMap(), - missing_lang_items: FxHashMap(), + used_crate_source: FxHashMap::default(), + wasm_imports: FxHashMap::default(), + lang_item_to_crate: FxHashMap::default(), + missing_lang_items: FxHashMap::default(), }; let lang_items = tcx.lang_items(); diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index e619742373801..559ca6f0dfe51 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -295,22 +295,22 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> { llcx, stats: RefCell::new(Stats::default()), codegen_unit, - instances: RefCell::new(FxHashMap()), - vtables: RefCell::new(FxHashMap()), - const_cstr_cache: RefCell::new(FxHashMap()), - const_unsized: RefCell::new(FxHashMap()), - const_globals: RefCell::new(FxHashMap()), + instances: RefCell::new(FxHashMap::default()), + vtables: RefCell::new(FxHashMap::default()), + const_cstr_cache: RefCell::new(FxHashMap::default()), + const_unsized: RefCell::new(FxHashMap::default()), + const_globals: RefCell::new(FxHashMap::default()), statics_to_rauw: RefCell::new(Vec::new()), used_statics: RefCell::new(Vec::new()), - lltypes: RefCell::new(FxHashMap()), - scalar_lltypes: RefCell::new(FxHashMap()), - pointee_infos: RefCell::new(FxHashMap()), + lltypes: RefCell::new(FxHashMap::default()), + scalar_lltypes: RefCell::new(FxHashMap::default()), + pointee_infos: RefCell::new(FxHashMap::default()), isize_ty, dbg_cx, eh_personality: Cell::new(None), eh_unwind_resume: Cell::new(None), rust_try_fn: Cell::new(None), - intrinsics: RefCell::new(FxHashMap()), + intrinsics: RefCell::new(FxHashMap::default()), local_gen_sym_counter: Cell::new(0), } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f5e5287cd42c5..3c4e000854e55 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -111,9 +111,9 @@ impl TypeMap<'ll, 'tcx> { pub fn new() -> Self { TypeMap { unique_id_interner: Interner::new(), - type_to_metadata: FxHashMap(), - unique_id_to_metadata: FxHashMap(), - type_to_unique_id: FxHashMap(), + type_to_metadata: FxHashMap::default(), + unique_id_to_metadata: FxHashMap::default(), + type_to_unique_id: FxHashMap::default(), } } diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index acb79d6f568cc..2cd44b2a6c41d 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -100,11 +100,11 @@ impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> { llcontext, llmod, builder, - created_files: RefCell::new(FxHashMap()), - created_enum_disr_types: RefCell::new(FxHashMap()), + created_files: RefCell::new(FxHashMap::default()), + created_enum_disr_types: RefCell::new(FxHashMap::default()), type_map: RefCell::new(TypeMap::new()), namespace_map: RefCell::new(DefIdMap()), - composite_types_completed: RefCell::new(FxHashSet()), + composite_types_completed: RefCell::new(FxHashSet::default()), } } } diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index d693e088360d4..48e1292d435e5 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -132,7 +132,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { ::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { - Lrc::new(FxHashMap()) // Just a dummy + Lrc::new(FxHashMap::default()) // Just a dummy }; providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); diff --git a/src/librustc_data_structures/fx.rs b/src/librustc_data_structures/fx.rs index 3bf3170d1df1a..bce21f5085c7c 100644 --- a/src/librustc_data_structures/fx.rs +++ b/src/librustc_data_structures/fx.rs @@ -8,21 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::collections::{HashMap, HashSet}; -use std::default::Default; -use std::hash::Hash; - pub use rustc_hash::FxHashMap; pub use rustc_hash::FxHashSet; pub use rustc_hash::FxHasher; - -#[allow(non_snake_case)] -pub fn FxHashMap() -> FxHashMap { - HashMap::default() -} - -#[allow(non_snake_case)] -pub fn FxHashSet() -> FxHashSet { - HashSet::default() -} - diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 92cc398db5011..5bc0404a3dace 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -187,11 +187,11 @@ impl ObligationForest { pub fn new() -> ObligationForest { ObligationForest { nodes: vec![], - done_cache: FxHashSet(), - waiting_cache: FxHashMap(), + done_cache: FxHashSet::default(), + waiting_cache: FxHashMap::default(), scratch: Some(vec![]), obligation_tree_id_generator: (0..).map(|i| ObligationTreeId(i)), - error_cache: FxHashMap(), + error_cache: FxHashMap::default(), } } @@ -303,7 +303,7 @@ impl ObligationForest { self.error_cache .entry(node.obligation_tree_id) - .or_insert_with(|| FxHashSet()) + .or_insert_with(|| FxHashSet::default()) .insert(node.obligation.as_predicate().clone()); } diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index 5030bf98dffd5..26528f4434576 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -40,7 +40,7 @@ impl SnapshotMap { pub fn new() -> Self { SnapshotMap { - map: FxHashMap(), + map: FxHashMap::default(), undo_log: vec![], } } diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 1512b30eeadaa..a48b6f381a558 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -55,7 +55,7 @@ impl TransitiveRelation { pub fn new() -> TransitiveRelation { TransitiveRelation { elements: vec![], - map: FxHashMap(), + map: FxHashMap::default(), edges: vec![], closure: Lock::new(None), } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 12f1a43ed0533..bec8d2997f7db 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -382,9 +382,9 @@ impl Handler { emitter: Lock::new(e), continue_after_error: LockCell::new(true), delayed_span_bugs: Lock::new(Vec::new()), - taught_diagnostics: Lock::new(FxHashSet()), - emitted_diagnostic_codes: Lock::new(FxHashSet()), - emitted_diagnostics: Lock::new(FxHashSet()), + taught_diagnostics: Lock::new(FxHashSet::default()), + emitted_diagnostic_codes: Lock::new(FxHashSet::default()), + emitted_diagnostics: Lock::new(FxHashSet::default()), } } @@ -398,7 +398,7 @@ impl Handler { /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. pub fn reset_err_count(&self) { - *self.emitted_diagnostics.borrow_mut() = FxHashSet(); + *self.emitted_diagnostics.borrow_mut() = FxHashSet::default(); self.err_count.store(0, SeqCst); } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 8e07e44513b0a..22a0cc983daab 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -343,7 +343,7 @@ fn walk_nodes<'q>(query: &'q DepGraphQuery, direction: Direction) -> FxHashSet<&'q DepNode> { - let mut set = FxHashSet(); + let mut set = FxHashSet::default(); for &start in starts { debug!("walk_nodes: start={:?} outgoing?={:?}", start, direction == OUTGOING); if set.insert(start) { diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 1b3819474c22e..fa5eda69f76a4 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -226,7 +226,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let krate = tcx.hir.krate(); let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, - checked_attrs: FxHashSet(), + checked_attrs: FxHashSet::default(), }; krate.visit_all_item_likes(&mut dirty_clean_visitor); diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index ec25aef808059..dee50f5ab2679 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -219,7 +219,7 @@ pub fn prepare_session_directory(sess: &Session, } }; - let mut source_directories_already_tried = FxHashSet(); + let mut source_directories_already_tried = FxHashSet::default(); loop { // Generate a session directory of the form: @@ -656,8 +656,8 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { // First do a pass over the crate directory, collecting lock files and // session directories - let mut session_directories = FxHashSet(); - let mut lock_files = FxHashSet(); + let mut session_directories = FxHashSet::default(); + let mut lock_files = FxHashSet::default(); for dir_entry in try!(crate_directory.read_dir()) { let dir_entry = match dir_entry { @@ -875,7 +875,7 @@ fn all_except_most_recent(deletion_candidates: Vec<(SystemTime, PathBuf, Option< .map(|(_, path, lock)| (path, lock)) .collect() } else { - FxHashMap() + FxHashMap::default() } } @@ -924,7 +924,7 @@ fn test_all_except_most_recent() { assert_eq!(all_except_most_recent( vec![ ]).keys().cloned().collect::>(), - FxHashSet() + FxHashSet::default() ); } @@ -939,7 +939,7 @@ fn test_timestamp_serialization() { #[test] fn test_find_source_directory_in_iter() { - let already_visited = FxHashSet(); + let already_visited = FxHashSet::default(); // Find newest assert_eq!(find_source_directory_in_iter( diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index fbc3bf03599fc..e2eaa59d627dc 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -48,7 +48,7 @@ impl LoadResult<(PreviousDepGraph, WorkProductMap)> { match self { LoadResult::Error { message } => { sess.warn(&message); - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) }, LoadResult::DataOutOfDate => { if let Err(err) = delete_all_session_dir_contents(sess) { @@ -56,7 +56,7 @@ impl LoadResult<(PreviousDepGraph, WorkProductMap)> { incremental compilation session directory contents `{}`: {}.", dep_graph_path(sess).display(), err)); } - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) } LoadResult::Ok { data } => data } @@ -117,7 +117,7 @@ pub fn load_dep_graph(sess: &Session) -> if sess.opts.incremental.is_none() { // No incremental compilation. return MaybeAsync::Sync(LoadResult::Ok { - data: (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + data: (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) }); } @@ -127,7 +127,7 @@ pub fn load_dep_graph(sess: &Session) -> let report_incremental_info = sess.opts.debugging_opts.incremental_info; let expected_hash = sess.opts.dep_tracking_hash(); - let mut prev_work_products = FxHashMap(); + let mut prev_work_products = FxHashMap::default(); // If we are only building with -Zquery-dep-graph but without an actual // incr. comp. session directory, we skip this. Otherwise we'd fail diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 06b0ea946d778..6279df4e5801d 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -162,7 +162,7 @@ fn encode_dep_graph(tcx: TyCtxt, let (total_edge_reads, total_duplicate_edge_reads) = tcx.dep_graph.edge_deduplication_data(); - let mut counts: FxHashMap<_, Stat> = FxHashMap(); + let mut counts: FxHashMap<_, Stat> = FxHashMap::default(); for (i, &node) in serialized_graph.nodes.iter_enumerated() { let stat = counts.entry(node.kind).or_insert(Stat { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index a441f7a87f763..5197876f92197 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -734,7 +734,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // any generic types right now: let ty = self.cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); - match self.check_type_for_ffi(&mut FxHashSet(), ty) { + match self.check_type_for_ffi(&mut FxHashSet::default(), ty) { FfiResult::FfiSafe => {} FfiResult::FfiPhantom(ty) => { self.cx.span_lint(IMPROPER_CTYPES, diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index fa2debf2c0dc7..4b96735eb77b4 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -1133,7 +1133,7 @@ impl<'a> CrateLoader<'a> { path_len, direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); self.cstore.add_extern_mod_stmt_cnum(item.id, cnum); cnum @@ -1160,7 +1160,7 @@ impl<'a> CrateLoader<'a> { path_len: usize::max_value(), direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); cnum @@ -1184,7 +1184,7 @@ impl<'a> CrateLoader<'a> { path_len: usize::max_value(), direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); Some(cnum) diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index ec48a4a4c6997..f102417c3452a 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -111,7 +111,7 @@ impl CStore { // corresponding `CrateNum`. This first entry will always remain // `None`. metas: RwLock::new(IndexVec::from_elem_n(None, 1)), - extern_mod_crate_map: Lock::new(FxHashMap()), + extern_mod_crate_map: Lock::new(FxHashMap::default()), metadata_loader, } } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index c36ae02ab54e0..26f977c6b59d1 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1494,7 +1494,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { let tcx = self.tcx; let mut visitor = ImplVisitor { tcx, - impls: FxHashMap(), + impls: FxHashMap::default(), }; tcx.hir.krate().visit_all_item_likes(&mut visitor); diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index adff34af61ed8..0514755d782bf 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -459,7 +459,7 @@ impl<'a> Context<'a> { let mut candidates: FxHashMap< _, (FxHashMap<_, _>, FxHashMap<_, _>, FxHashMap<_, _>), - > = FxHashMap(); + > = FxHashMap::default(); let mut staticlibs = vec![]; // First, find all possible candidate rlibs and dylibs purely based on @@ -528,7 +528,7 @@ impl<'a> Context<'a> { // A Library candidate is created if the metadata for the set of // libraries corresponds to the crate id and hash criteria that this // search is being performed for. - let mut libraries = FxHashMap(); + let mut libraries = FxHashMap::default(); for (_hash, (rlibs, rmetas, dylibs)) in candidates { let mut slot = None; let rlib = self.extract_one(rlibs, CrateFlavor::Rlib, &mut slot); @@ -771,9 +771,9 @@ impl<'a> Context<'a> { // rlibs/dylibs. let sess = self.sess; let dylibname = self.dylibname(); - let mut rlibs = FxHashMap(); - let mut rmetas = FxHashMap(); - let mut dylibs = FxHashMap(); + let mut rlibs = FxHashMap::default(); + let mut rmetas = FxHashMap::default(); + let mut dylibs = FxHashMap::default(); { let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| { if !loc.exists() { diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 446ea6c324441..392644c793d8c 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -183,7 +183,7 @@ impl<'a, 'tcx> Collector<'a, 'tcx> { // Process libs passed on the command line fn process_command_line(&mut self) { // First, check for errors - let mut renames = FxHashSet(); + let mut renames = FxHashSet::default(); for &(ref name, ref new_name, _) in &self.tcx.sess.opts.libs { if let &Some(ref new_name) = new_name { let any_duplicate = self.libs diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index a316fc5ca1029..6096f992391d4 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -151,11 +151,11 @@ impl<'tcx> BorrowSet<'tcx> { tcx, mir, idx_vec: IndexVec::new(), - location_map: FxHashMap(), - activation_map: FxHashMap(), - region_map: FxHashMap(), - local_map: FxHashMap(), - pending_activations: FxHashMap(), + location_map: FxHashMap::default(), + activation_map: FxHashMap::default(), + region_map: FxHashMap::default(), + local_map: FxHashMap::default(), + pending_activations: FxHashMap::default(), locals_state_at_exit: LocalsStateAtExit::build(locals_are_invalidated_at_exit, mir, move_data), }; diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index baf9e032270a6..978b2b2eb8631 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -838,7 +838,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { (predecessor, is_back_edge) })); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); let mut result = vec![]; 'dfs: while let Some((location, is_back_edge)) = stack.pop() { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index a7b356c146163..818b71ded37f8 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -252,13 +252,13 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( location_table, movable_generator, locals_are_invalidated_at_exit, - access_place_error_reported: FxHashSet(), - reservation_error_reported: FxHashSet(), + access_place_error_reported: FxHashSet::default(), + reservation_error_reported: FxHashSet::default(), move_error_reported: BTreeMap::new(), - uninitialized_error_reported: FxHashSet(), + uninitialized_error_reported: FxHashSet::default(), errors_buffer, nonlexical_regioncx: regioncx, - used_mut: FxHashSet(), + used_mut: FxHashSet::default(), used_mut_upvars: SmallVec::new(), borrow_set, dominators, diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs index d4adff7c443cb..1e6ba638e1cc4 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs @@ -48,7 +48,7 @@ struct UseFinder<'cx, 'gcx: 'tcx, 'tcx: 'cx> { impl<'cx, 'gcx, 'tcx> UseFinder<'cx, 'gcx, 'tcx> { fn find(&mut self) -> Option { let mut queue = VecDeque::new(); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); queue.push_back(self.start_point); while let Some(p) = queue.pop_front() { diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index c5758cde9494d..bdaea23d22bc1 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -128,7 +128,7 @@ pub(crate) fn type_check<'gcx, 'tcx>( let mut constraints = MirTypeckRegionConstraints { liveness_constraints: LivenessValues::new(elements), outlives_constraints: ConstraintSet::default(), - closure_bounds_mapping: FxHashMap(), + closure_bounds_mapping: FxHashMap::default(), type_tests: Vec::default(), }; let mut placeholder_indices = PlaceholderIndices::default(); @@ -847,7 +847,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { region_bound_pairs, implicit_region_bound, borrowck_context, - reported_errors: FxHashSet(), + reported_errors: FxHashSet::default(), universal_region_relations, } } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 99c0a52a8ee36..a864b39e15791 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -178,7 +178,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // If there are no match guards then we don't need any fake borrows, // so don't track them. let mut fake_borrows = if has_guard && tcx.generate_borrow_of_any_match_input() { - Some(FxHashMap()) + Some(FxHashMap::default()) } else { None }; diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index a8713286f18ec..06e394775e8c6 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // these maps are empty to start; cases are // added below in add_cases_to_switch options: vec![], - indices: FxHashMap(), + indices: FxHashMap::default(), } } } diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index cc5b08f2a9047..afb3d00d461e0 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -358,7 +358,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { needs_cleanup: false, drops: vec![], cached_generator_drop: None, - cached_exits: FxHashMap(), + cached_exits: FxHashMap::default(), cached_unwind: CachedBlock::default(), }); } diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index caf87fdd5ccce..f7043487c51a6 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -77,7 +77,7 @@ fn precompute_borrows_out_of_scope<'tcx>( // `visited` once they are added to `stack`, before they are actually // processed, because this avoids the need to look them up again on // completion. - let mut visited = FxHashMap(); + let mut visited = FxHashMap::default(); visited.insert(location.block, location.statement_index); let mut stack = vec![]; @@ -162,7 +162,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { } }); - let mut borrows_out_of_scope_at_location = FxHashMap(); + let mut borrows_out_of_scope_at_location = FxHashMap::default(); for (borrow_index, borrow_data) in borrow_set.borrows.iter_enumerated() { let borrow_region = borrow_data.region.to_region_vid(); let location = borrow_set.borrows[borrow_index].reserve_location; diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 32b1187011672..c5b1353d74b3e 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { v, ) }).collect(), - projections: FxHashMap(), + projections: FxHashMap::default(), }, move_paths, path_map, diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index c446980d04995..d7b2f67a581e3 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -89,7 +89,7 @@ pub struct RefTracking<'tcx, Tag> { impl<'tcx, Tag: Copy+Eq+Hash> RefTracking<'tcx, Tag> { pub fn new(op: OpTy<'tcx, Tag>) -> Self { let mut ref_tracking = RefTracking { - seen: FxHashSet(), + seen: FxHashSet::default(), todo: vec![(op, Vec::new())], }; ref_tracking.seen.insert(op); diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index dd83d3157ba61..6b60b5340eee7 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -238,7 +238,7 @@ impl<'tcx> InliningMap<'tcx> { fn new() -> InliningMap<'tcx> { InliningMap { - index: FxHashMap(), + index: FxHashMap::default(), targets: Vec::new(), inlines: GrowableBitSet::with_capacity(1024), } @@ -305,7 +305,7 @@ pub fn collect_crate_mono_items<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("Building mono item graph, beginning at roots"); - let mut visited = MTLock::new(FxHashSet()); + let mut visited = MTLock::new(FxHashSet::default()); let mut inlining_map = MTLock::new(InliningMap::new()); { diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index fd094ffc1cf4f..d16d900b11a7e 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -301,10 +301,10 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> PreInliningPartitioning<'tcx> where I: Iterator> { - let mut roots = FxHashSet(); - let mut codegen_units = FxHashMap(); + let mut roots = FxHashSet::default(); + let mut codegen_units = FxHashMap::default(); let is_incremental_build = tcx.sess.opts.incremental.is_some(); - let mut internalization_candidates = FxHashSet(); + let mut internalization_candidates = FxHashSet::default(); // Determine if monomorphizations instantiated in this crate will be made // available to downstream crates. This depends on whether we are in @@ -314,7 +314,7 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.local_crate_exports_generics(); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); - let cgu_name_cache = &mut FxHashMap(); + let cgu_name_cache = &mut FxHashMap::default(); for mono_item in mono_items { match mono_item.instantiation_mode(tcx) { @@ -602,7 +602,7 @@ fn place_inlined_mono_items<'tcx>(initial_partitioning: PreInliningPartitioning< inlining_map: &InliningMap<'tcx>) -> PostInliningPartitioning<'tcx> { let mut new_partitioning = Vec::new(); - let mut mono_item_placements = FxHashMap(); + let mut mono_item_placements = FxHashMap::default(); let PreInliningPartitioning { codegen_units: initial_cgus, @@ -614,7 +614,7 @@ fn place_inlined_mono_items<'tcx>(initial_partitioning: PreInliningPartitioning< for old_codegen_unit in initial_cgus { // Collect all items that need to be available in this codegen unit - let mut reachable = FxHashSet(); + let mut reachable = FxHashSet::default(); for root in old_codegen_unit.items().keys() { follow_inlining(*root, inlining_map, &mut reachable); } @@ -703,7 +703,7 @@ fn internalize_symbols<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>, // Build a map from every monomorphization to all the monomorphizations that // reference it. - let mut accessor_map: FxHashMap, Vec>> = FxHashMap(); + let mut accessor_map: FxHashMap, Vec>> = FxHashMap::default(); inlining_map.iter_accesses(|accessor, accessees| { for accessee in accessees { accessor_map.entry(*accessee) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 286de52bec5ca..77e580d5855f6 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -57,7 +57,7 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> { }, tcx, param_env, - used_unsafe: FxHashSet(), + used_unsafe: FxHashSet::default(), inherited_blocks: vec![], } } diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index aaba7ab8418f5..56da1919beb12 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -57,7 +57,7 @@ impl MirPass for CleanEndRegions { if !tcx.emit_end_regions() { return; } let mut gather = GatherBorrowedRegions { - seen_regions: FxHashSet() + seen_regions: FxHashSet::default() }; gather.visit_mir(mir); @@ -154,7 +154,7 @@ impl MirPass for CleanFakeReadsAndBorrows { _source: MirSource, mir: &mut Mir<'tcx>) { let mut delete_reads = DeleteAndRecordFakeReads { - fake_borrow_temporaries: FxHashSet(), + fake_borrow_temporaries: FxHashSet::default(), }; delete_reads.visit_mir(mir); let mut delete_borrows = DeleteFakeBorrows { diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 9d77289d7b9b1..e748500cd3ad2 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -75,7 +75,7 @@ impl MirPass for ElaborateDrops { env: &env, flow_inits, flow_uninits, - drop_flags: FxHashMap(), + drop_flags: FxHashMap::default(), patch: MirPatch::new(mir), }.elaborate() }; diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 5e7050caeaf28..78547abf9d9d3 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1291,7 +1291,7 @@ impl MirPass for QualifyAndPromoteConstants { fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { let attrs = tcx.get_attrs(def_id); let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; - let mut ret = FxHashSet(); + let mut ret = FxHashSet::default(); for meta in attr.meta_item_list()? { match meta.literal()?.node { LitKind::Int(a, _) => { ret.insert(a as usize); } diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 710ccb2053b84..7faef65d99458 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -536,7 +536,7 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>( writeln!(w, "{{")?; // construct a scope tree and write it out - let mut scope_tree: FxHashMap> = FxHashMap(); + let mut scope_tree: FxHashMap> = FxHashMap::default(); for (index, scope_data) in mir.source_scopes.iter().enumerate() { if let Some(parent) = scope_data.parent_scope { scope_tree diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index b65a2e3f0e530..019fb9565f413 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -41,8 +41,8 @@ struct StatCollector<'k> { pub fn print_hir_stats(krate: &hir::Crate) { let mut collector = StatCollector { krate: Some(krate), - data: FxHashMap(), - seen: FxHashSet(), + data: FxHashMap::default(), + seen: FxHashSet::default(), }; hir_visit::walk_crate(&mut collector, krate); collector.print("HIR STATS"); @@ -51,8 +51,8 @@ pub fn print_hir_stats(krate: &hir::Crate) { pub fn print_ast_stats<'v>(krate: &'v ast::Crate, title: &str) { let mut collector = StatCollector { krate: None, - data: FxHashMap(), - seen: FxHashSet(), + data: FxHashMap::default(), + seen: FxHashSet::default(), }; ast_visit::walk_crate(&mut collector, krate); collector.print(title); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 989851bb1b9b4..4b7bd7866727b 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1732,7 +1732,7 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, in_body: false, span: krate.span, empty_tables: &empty_tables, - visited_opaque_tys: FxHashSet() + visited_opaque_tys: FxHashSet::default() }; intravisit::walk_crate(&mut visitor, krate); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index bf3fbdc2c5ad5..c7e440ba5674d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -780,7 +780,7 @@ impl<'a, 'tcx, 'cl> Visitor<'tcx> for Resolver<'a, 'cl> { self.label_ribs.push(Rib::new(rib_kind)); // Add each argument to the rib. - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for argument in &declaration.inputs { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); @@ -930,7 +930,7 @@ struct Rib<'a> { impl<'a> Rib<'a> { fn new(kind: RibKind<'a>) -> Rib<'a> { Rib { - bindings: FxHashMap(), + bindings: FxHashMap::default(), kind, } } @@ -1053,11 +1053,11 @@ impl<'a> ModuleData<'a> { parent, kind, normal_ancestor_id, - resolutions: RefCell::new(FxHashMap()), + resolutions: RefCell::new(FxHashMap::default()), legacy_macro_resolutions: RefCell::new(Vec::new()), macro_resolutions: RefCell::new(Vec::new()), builtin_attrs: RefCell::new(Vec::new()), - unresolved_invocations: RefCell::new(FxHashSet()), + unresolved_invocations: RefCell::new(FxHashSet::default()), no_implicit_prelude: false, glob_importers: RefCell::new(Vec::new()), globs: RefCell::new(Vec::new()), @@ -1321,7 +1321,7 @@ struct PrimitiveTypeTable { impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { - let mut table = PrimitiveTypeTable { primitive_types: FxHashMap() }; + let mut table = PrimitiveTypeTable { primitive_types: FxHashMap::default() }; table.intern("bool", Bool); table.intern("char", Char); @@ -1668,7 +1668,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { no_implicit_prelude: attr::contains_name(&krate.attrs, "no_implicit_prelude"), ..ModuleData::new(None, root_module_kind, root_def_id, Mark::root(), krate.span) }); - let mut module_map = FxHashMap(); + let mut module_map = FxHashMap::default(); module_map.insert(DefId::local(CRATE_DEF_INDEX), graph_root); let mut definitions = Definitions::new(); @@ -1688,11 +1688,11 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { } } - let mut invocations = FxHashMap(); + let mut invocations = FxHashMap::default(); invocations.insert(Mark::root(), arenas.alloc_invocation_data(InvocationData::root(graph_root))); - let mut macro_defs = FxHashMap(); + let mut macro_defs = FxHashMap::default(); macro_defs.insert(Mark::root(), root_def_id); Resolver { @@ -1708,8 +1708,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { prelude: None, extern_prelude, - has_self: FxHashSet(), - field_names: FxHashMap(), + has_self: FxHashSet::default(), + field_names: FxHashMap::default(), determined_imports: Vec::new(), indeterminate_imports: Vec::new(), @@ -1732,21 +1732,21 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { import_map: NodeMap(), freevars: NodeMap(), freevars_seen: NodeMap(), - export_map: FxHashMap(), + export_map: FxHashMap::default(), trait_map: NodeMap(), module_map, block_map: NodeMap(), - extern_module_map: FxHashMap(), - binding_parent_modules: FxHashMap(), + extern_module_map: FxHashMap::default(), + binding_parent_modules: FxHashMap::default(), make_glob_map: make_glob_map == MakeGlobMap::Yes, glob_map: NodeMap(), - used_imports: FxHashSet(), + used_imports: FxHashSet::default(), maybe_unused_trait_imports: NodeSet(), maybe_unused_extern_crates: Vec::new(), - unused_labels: FxHashMap(), + unused_labels: FxHashMap::default(), privacy_errors: Vec::new(), ambiguity_errors: Vec::new(), @@ -1762,20 +1762,20 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { }), crate_loader, - macro_names: FxHashSet(), - builtin_macros: FxHashMap(), - macro_use_prelude: FxHashMap(), - all_macros: FxHashMap(), - macro_map: FxHashMap(), + macro_names: FxHashSet::default(), + builtin_macros: FxHashMap::default(), + macro_use_prelude: FxHashMap::default(), + all_macros: FxHashMap::default(), + macro_map: FxHashMap::default(), invocations, macro_defs, - local_macro_def_scopes: FxHashMap(), - name_already_seen: FxHashMap(), + local_macro_def_scopes: FxHashMap::default(), + name_already_seen: FxHashMap::default(), whitelisted_legacy_custom_derives: Vec::new(), potentially_unused_imports: Vec::new(), struct_constructors: DefIdMap(), found_unresolved_macro: false, - unused_macros: FxHashSet(), + unused_macros: FxHashSet::default(), current_type_ascription: Vec::new(), injected_crate: None, } @@ -2381,7 +2381,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { match type_parameters { HasTypeParameters(generics, rib_kind) => { let mut function_type_rib = Rib::new(rib_kind); - let mut seen_bindings = FxHashMap(); + let mut seen_bindings = FxHashMap::default(); for param in &generics.params { match param.kind { GenericParamKind::Lifetime { .. } => {} @@ -2649,7 +2649,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { walk_list!(self, visit_expr, &local.init); // Resolve the pattern. - self.resolve_pattern(&local.pat, PatternSource::Let, &mut FxHashMap()); + self.resolve_pattern(&local.pat, PatternSource::Let, &mut FxHashMap::default()); } // build a map from pattern identifiers to binding-info's. @@ -2657,7 +2657,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { // that expands into an or-pattern where one 'x' was from the // user and one 'x' came from the macro. fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap { - let mut binding_map = FxHashMap(); + let mut binding_map = FxHashMap::default(); pat.walk(&mut |pat| { if let PatKind::Ident(binding_mode, ident, ref sub_pat) = pat.node { @@ -2682,8 +2682,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { return; } - let mut missing_vars = FxHashMap(); - let mut inconsistent_vars = FxHashMap(); + let mut missing_vars = FxHashMap::default(); + let mut inconsistent_vars = FxHashMap::default(); for (i, p) in pats.iter().enumerate() { let map_i = self.binding_mode_map(&p); @@ -2747,7 +2747,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { fn resolve_arm(&mut self, arm: &Arm) { self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pattern in &arm.pats { self.resolve_pattern(&pattern, PatternSource::Match, &mut bindings_list); } @@ -4143,7 +4143,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.visit_expr(subexpression); self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pat in pats { self.resolve_pattern(pat, PatternSource::IfLet, &mut bindings_list); } @@ -4168,7 +4168,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.with_resolved_label(label, expr.id, |this| { this.visit_expr(subexpression); this.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pat in pats { this.resolve_pattern(pat, PatternSource::WhileLet, &mut bindings_list); } @@ -4182,7 +4182,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { ExprKind::ForLoop(ref pattern, ref subexpression, ref block, label) => { self.visit_expr(subexpression); self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - self.resolve_pattern(pattern, PatternSource::For, &mut FxHashMap()); + self.resolve_pattern(pattern, PatternSource::For, &mut FxHashMap::default()); self.resolve_labeled_block(label, expr.id, block); @@ -4235,7 +4235,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.ribs[ValueNS].push(Rib::new(rib_kind)); self.label_ribs.push(Rib::new(rib_kind)); // Resolve arguments: - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for argument in &fn_decl.inputs { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); self.visit_ty(&argument.ty); @@ -4380,7 +4380,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { where FilterFn: Fn(Def) -> bool { let mut candidates = Vec::new(); - let mut seen_modules = FxHashSet(); + let mut seen_modules = FxHashSet::default(); let not_local_module = crate_name != keywords::Crate.ident(); let mut worklist = vec![(start_module, Vec::::new(), not_local_module)]; @@ -4499,7 +4499,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { -> Option<(Module<'a>, ImportSuggestion)> { let mut result = None; - let mut seen_modules = FxHashSet(); + let mut seen_modules = FxHashSet::default(); let mut worklist = vec![(self.graph_root, Vec::new())]; while let Some((in_module, path_segments)) = worklist.pop() { @@ -4673,7 +4673,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { fn report_errors(&mut self, krate: &Crate) { self.report_with_use_injections(krate); - let mut reported_spans = FxHashSet(); + let mut reported_spans = FxHashSet::default(); for &(span_use, span_def) in &self.macro_expanded_macro_export_errors { let msg = "macro-expanded `macro_export` macros from the current crate \ diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index d5d772e135914..f04bbb962a309 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -652,7 +652,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { > = BTreeMap::new(); let mut errors = false; - let mut seen_spans = FxHashSet(); + let mut seen_spans = FxHashSet::default(); let mut error_vec = Vec::new(); let mut prev_root_id: NodeId = NodeId::new(0); for i in 0 .. self.determined_imports.len() { diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index ab8f468672944..d77a8bd2a52d1 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -110,7 +110,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { span: span_utils.clone(), cur_scope: CRATE_NODE_ID, // mac_defs: FxHashSet::default(), - macro_calls: FxHashSet(), + macro_calls: FxHashSet::default(), } } @@ -176,7 +176,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // (and don't include remapping args anymore) let (program, arguments) = { let remap_arg_indices = { - let mut indices = FxHashSet(); + let mut indices = FxHashSet::default(); // Args are guaranteed to be valid UTF-8 (checked early) for (i, e) in env::args().enumerate() { if e.starts_with("--remap-path-prefix=") { diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index ed61f07c4d83d..2ad7ab7c4d927 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -86,7 +86,7 @@ fn dropck_outlives<'tcx>( let mut ty_stack = vec![(for_ty, 0)]; // Set used to detect infinite recursion. - let mut ty_set = FxHashSet(); + let mut ty_set = FxHashSet::default(); let fulfill_cx = &mut FulfillmentContext::new(); @@ -321,8 +321,8 @@ crate fn adt_dtorck_constraint<'a, 'tcx>( } fn dedup_dtorck_constraint<'tcx>(c: &mut DtorckConstraint<'tcx>) { - let mut outlives = FxHashSet(); - let mut dtorck_types = FxHashSet(); + let mut outlives = FxHashSet::default(); + let mut dtorck_types = FxHashSet::default(); c.outlives.retain(|&val| outlives.replace(val).is_none()); c.dtorck_types diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index 3d1e7cf17a659..04290ca6b76e4 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -142,7 +142,7 @@ crate fn program_clauses_for_env<'a, 'tcx>( ) -> Clauses<'tcx> { debug!("program_clauses_for_env(environment={:?})", environment); - let mut last_round = FxHashSet(); + let mut last_round = FxHashSet::default(); { let mut visitor = ClauseVisitor::new(tcx, &mut last_round); for &clause in environment.clauses { @@ -151,7 +151,7 @@ crate fn program_clauses_for_env<'a, 'tcx>( } let mut closure = last_round.clone(); - let mut next_round = FxHashSet(); + let mut next_round = FxHashSet::default(); while !last_round.is_empty() { let mut visitor = ClauseVisitor::new(tcx, &mut next_round); for clause in last_round.drain() { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c9158af178fea..0cc9924474c5a 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -887,7 +887,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); .collect::>(); // Keep track of which fields have already appeared in the pattern. - let mut used_fields = FxHashMap(); + let mut used_fields = FxHashMap::default(); let mut no_field_errors = true; let mut inexistent_fields = vec![]; diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 83005bc374ef5..b4ad9cfbc6d51 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -89,7 +89,7 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, let body = fcx.tcx.hir.body(body_id); let mut visitor = InteriorVisitor { fcx, - types: FxHashMap(), + types: FxHashMap::default(), region_scope_tree: fcx.tcx.region_scope_tree(def_id), expr_count: 0, }; diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index d630c5b3040b7..da96d4f0cba42 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -416,7 +416,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return } - let mut structural_to_nomimal = FxHashMap(); + let mut structural_to_nomimal = FxHashMap::default(); let sig = tcx.fn_sig(def_id); let sig = sig.no_late_bound_regions().unwrap(); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index ae02cd64c3891..f4538dbd25e2f 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -396,7 +396,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { return_type, inherent_candidates: Vec::new(), extension_candidates: Vec::new(), - impl_dups: FxHashSet(), + impl_dups: FxHashSet::default(), steps: steps, static_candidates: Vec::new(), allow_similar_names: false, @@ -718,7 +718,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { if expr_id == ast::DUMMY_NODE_ID { return Ok(()) } - let mut duplicates = FxHashSet(); + let mut duplicates = FxHashSet::default(); let expr_hir_id = self.tcx.hir.node_to_hir_id(expr_id); let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id); if let Some(applicable_traits) = opt_applicable_traits { @@ -735,7 +735,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } fn assemble_extension_candidates_for_all_traits(&mut self) -> Result<(), MethodError<'tcx>> { - let mut duplicates = FxHashSet(); + let mut duplicates = FxHashSet::default(); for trait_info in suggest::all_traits(self.tcx) { if duplicates.insert(trait_info.def_id) { self.assemble_extension_candidates_for_trait(None, trait_info.def_id)?; @@ -800,7 +800,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } fn candidate_method_names(&self) -> Vec { - let mut set = FxHashSet(); + let mut set = FxHashSet::default(); let mut names: Vec<_> = self.inherent_candidates .iter() .chain(&self.extension_candidates) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 2006796a10089..2e0f6600a3518 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -750,7 +750,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec }); // Cross-crate: - let mut external_mods = FxHashSet(); + let mut external_mods = FxHashSet::default(); fn handle_external_def(tcx: TyCtxt, traits: &mut Vec, external_mods: &mut FxHashSet, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 14ce1bb4ccdee..c19439344535b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3492,12 +3492,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => span_bug!(span, "non-ADT passed to check_expr_struct_fields") }; - let mut remaining_fields = FxHashMap(); + let mut remaining_fields = FxHashMap::default(); for (i, field) in variant.fields.iter().enumerate() { remaining_fields.insert(field.ident.modern(), (i, field)); } - let mut seen_fields = FxHashMap(); + let mut seen_fields = FxHashMap::default(); let mut error_happened = false; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 016ea5cba6609..7e1507b7e1f9a 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -491,7 +491,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( true } } - let mut param_count = CountParams { params: FxHashSet() }; + let mut param_count = CountParams { params: FxHashSet::default() }; let has_region = pred.visit_with(&mut param_count); let substituted_pred = pred.subst(fcx.tcx, substs); // Don't check non-defaulted params, dependent defaults (including lifetimes) @@ -606,7 +606,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>( let opaque_node_id = tcx.hir.as_local_node_id(def_id).unwrap(); if may_define_existential_type(tcx, fn_def_id, opaque_node_id) { trace!("check_existential_types may define. Generics: {:#?}", generics); - let mut seen: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut seen: FxHashMap<_, Vec<_>> = FxHashMap::default(); for (subst, param) in substs.iter().zip(&generics.params) { match subst.unpack() { ty::subst::UnpackedKind::Type(ty) => match ty.sty { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index f96c85ae7ae3f..934db4b443591 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -561,7 +561,7 @@ fn convert_variant<'a, 'tcx>( adt_kind: ty::AdtKind, attribute_def_id: DefId ) -> ty::VariantDef { - let mut seen_fields: FxHashMap = FxHashMap(); + let mut seen_fields: FxHashMap = FxHashMap::default(); let node_id = tcx.hir.as_local_node_id(did).unwrap(); let fields = def .fields() diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 7e0a8d63e2889..edf3ddf7bdbfa 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -173,8 +173,8 @@ fn report_unused_parameter(tcx: TyCtxt, fn enforce_impl_items_are_distinct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_refs: &[hir::ImplItemRef]) { - let mut seen_type_items = FxHashMap(); - let mut seen_value_items = FxHashMap(); + let mut seen_type_items = FxHashMap::default(); + let mut seen_value_items = FxHashMap::default(); for impl_item_ref in impl_item_refs { let impl_item = tcx.hir.impl_item(impl_item_ref.id); let seen_items = match impl_item.node { diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index de5a680ccf9d1..16b4347d7ebe1 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -178,7 +178,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { inner: ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, - provided_trait_methods: FxHashSet(), + provided_trait_methods: FxHashSet::default(), trait_: Some(trait_.clean(self.cx)), for_: ty.clean(self.cx), items: Vec::new(), @@ -267,9 +267,9 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { // all intermediate RegionVids. At the end, all constraints should // be between Regions (aka region variables). This gives us the information // we need to create the Generics. - let mut finished: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut finished: FxHashMap<_, Vec<_>> = FxHashMap::default(); - let mut vid_map: FxHashMap = FxHashMap(); + let mut vid_map: FxHashMap = FxHashMap::default(); // Flattening is done in two parts. First, we insert all of the constraints // into a map. Each RegionTarget (either a RegionVid or a Region) maps @@ -407,7 +407,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { ) -> FxHashSet { pred.walk_tys() .flat_map(|t| { - let mut regions = FxHashSet(); + let mut regions = FxHashSet::default(); tcx.collect_regions(&t, &mut regions); regions.into_iter().flat_map(|r| { @@ -576,12 +576,12 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { .. } = full_generics.clean(self.cx); - let mut has_sized = FxHashSet(); - let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap(); - let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap(); - let mut ty_to_traits: FxHashMap> = FxHashMap(); + let mut has_sized = FxHashSet::default(); + let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default(); + let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default(); + let mut ty_to_traits: FxHashMap> = FxHashMap::default(); - let mut ty_to_fn: FxHashMap, Option)> = FxHashMap(); + let mut ty_to_fn: FxHashMap, Option)> = FxHashMap::default(); for (orig_p, p) in clean_where_predicates { match p { diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index a435712ac3d6c..ad0b633d03a7b 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -368,7 +368,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet()); + }).unwrap_or(FxHashSet::default()); debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id()); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2ba1f103971f0..2f9baf2d3ee0e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -76,7 +76,7 @@ use self::auto_trait::AutoTraitFinder; use self::blanket_impl::BlanketImplFinder; thread_local!(pub static MAX_DEF_ID: RefCell> = - RefCell::new(FxHashMap())); + RefCell::new(FxHashMap::default())); const FN_OUTPUT_NAME: &'static str = "Output"; @@ -165,7 +165,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> Clean for visit_ast::RustdocVisitor<'a, 'tc // Clean the crate, translating the entire libsyntax AST to one that is // understood by rustdoc. let mut module = self.module.clean(cx); - let mut masked_crates = FxHashSet(); + let mut masked_crates = FxHashSet::default(); match module.inner { ModuleItem(ref module) => { @@ -1585,7 +1585,7 @@ impl<'a, 'tcx> Clean for (&'a ty::Generics, // Note that associated types also have a sized bound by default, but we // don't actually know the set of associated types right here so that's // handled in cleaning associated types - let mut sized_params = FxHashSet(); + let mut sized_params = FxHashSet::default(); where_predicates.retain(|pred| { match *pred { WP::BoundPredicate { ty: Generic(ref g), ref bounds } => { @@ -2447,8 +2447,8 @@ impl Clean for hir::Ty { if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias { let provided_params = &path.segments.last().expect("segments were empty"); - let mut ty_substs = FxHashMap(); - let mut lt_substs = FxHashMap(); + let mut ty_substs = FxHashMap::default(); + let mut lt_substs = FxHashMap::default(); provided_params.with_generic_args(|generic_args| { let mut indices: GenericParamCount = Default::default(); for param in generics.params.iter() { @@ -3388,7 +3388,7 @@ impl Clean> for doctree::Impl { .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet()); + }).unwrap_or(FxHashSet::default()); ret.push(Item { name: None, @@ -3502,7 +3502,7 @@ impl Clean> for doctree::Import { let path = self.path.clean(cx); let inner = if self.glob { if !denied { - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); if let Some(items) = inline::try_inline_glob(cx, path.def, &mut visited) { return items; } @@ -3512,7 +3512,7 @@ impl Clean> for doctree::Import { } else { let name = self.name; if !denied { - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); if let Some(items) = inline::try_inline(cx, path.def, name, &mut visited) { return items; } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 2e14c2552de3a..14160e14bbc17 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -539,9 +539,9 @@ pub fn run_core(search_paths: SearchPaths, lt_substs: Default::default(), impl_trait_bounds: Default::default(), send_trait: send_trait, - fake_def_ids: RefCell::new(FxHashMap()), - all_fake_def_ids: RefCell::new(FxHashSet()), - generated_synthetics: RefCell::new(FxHashSet()), + fake_def_ids: RefCell::new(FxHashMap::default()), + all_fake_def_ids: RefCell::new(FxHashSet::default()), + generated_synthetics: RefCell::new(FxHashSet::default()), all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(), }; debug!("crate: {:?}", tcx.hir.krate()); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 23f1e15de3c92..d484df00f37e8 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -513,7 +513,7 @@ pub fn run(mut krate: clean::Crate, src_root, passes, include_sources: true, - local_sources: FxHashMap(), + local_sources: FxHashMap::default(), issue_tracker_base_url: None, layout: layout::Layout { logo: String::new(), @@ -522,7 +522,7 @@ pub fn run(mut krate: clean::Crate, krate: krate.name.clone(), }, css_file_extension: css_file_extension.clone(), - created_dirs: RefCell::new(FxHashSet()), + created_dirs: RefCell::new(FxHashSet::default()), sort_modules_alphabetically, themes, resource_suffix, @@ -591,29 +591,29 @@ pub fn run(mut krate: clean::Crate, .collect(); let mut cache = Cache { - impls: FxHashMap(), + impls: FxHashMap::default(), external_paths, exact_paths, - paths: FxHashMap(), - implementors: FxHashMap(), + paths: FxHashMap::default(), + implementors: FxHashMap::default(), stack: Vec::new(), parent_stack: Vec::new(), search_index: Vec::new(), parent_is_trait_impl: false, - extern_locations: FxHashMap(), - primitive_locations: FxHashMap(), + extern_locations: FxHashMap::default(), + primitive_locations: FxHashMap::default(), stripped_mod: false, access_levels, crate_version: krate.version.take(), orphan_impl_items: Vec::new(), orphan_trait_impls: Vec::new(), - traits: krate.external_traits.lock().replace(FxHashMap()), + traits: krate.external_traits.lock().replace(FxHashMap::default()), deref_trait_did, deref_mut_trait_did, owned_box_did, - masked_crates: mem::replace(&mut krate.masked_crates, FxHashSet()), + masked_crates: mem::replace(&mut krate.masked_crates, FxHashSet::default()), typarams: external_typarams, - aliases: FxHashMap(), + aliases: FxHashMap::default(), }; // Cache where all our extern crates are located @@ -674,7 +674,7 @@ pub fn run(mut krate: clean::Crate, /// Build the search index from the collected metadata fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { - let mut nodeid_to_pathid = FxHashMap(); + let mut nodeid_to_pathid = FxHashMap::default(); let mut crate_items = Vec::with_capacity(cache.search_index.len()); let mut crate_paths = Vec::::new(); @@ -1448,7 +1448,7 @@ impl DocFolder for Cache { // Figure out the id of this impl. This may map to a // primitive rather than always to a struct/enum. // Note: matching twice to restrict the lifetime of the `i` borrow. - let mut dids = FxHashSet(); + let mut dids = FxHashSet::default(); if let clean::Item { inner: clean::ImplItem(ref i), .. } = item { match i.for_ { clean::ResolvedPath { did, .. } | @@ -2940,7 +2940,7 @@ fn item_trait( if let Some(implementors) = cache.implementors.get(&it.def_id) { // The DefId is for the first Type found with that name. The bool is // if any Types with the same name but different DefId have been found. - let mut implementor_dups: FxHashMap<&str, (DefId, bool)> = FxHashMap(); + let mut implementor_dups: FxHashMap<&str, (DefId, bool)> = FxHashMap::default(); for implementor in implementors { match implementor.inner_impl().for_ { clean::ResolvedPath { ref path, did, is_generic: false, .. } | @@ -3793,7 +3793,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result { out.push_str(" "); assoc_type(&mut out, it, &[], Some(&tydef.type_), - AssocItemLink::GotoSource(t_did, &FxHashSet()))?; + AssocItemLink::GotoSource(t_did, &FxHashSet::default()))?; out.push_str(";"); } } @@ -4703,7 +4703,7 @@ fn get_index_type(clean_type: &clean::Type) -> Type { /// picked up the impl fn collect_paths_for_type(first_ty: clean::Type) -> Vec { let mut out = Vec::new(); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); let mut work = VecDeque::new(); let cache = cache(); diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 92d8dbed0718a..5d221d3006f3e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore> ) -> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { // If the root is re-exported, terminate all recursion. - let mut stack = FxHashSet(); + let mut stack = FxHashSet::default(); stack.insert(ast::CRATE_NODE_ID); RustdocVisitor { module: Module::new(None), @@ -64,7 +64,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { view_item_stack: stack, inlining: false, inside_public_path: true, - exact_paths: Some(FxHashMap()), + exact_paths: Some(FxHashMap::default()), } } diff --git a/src/librustdoc/visit_lib.rs b/src/librustdoc/visit_lib.rs index fd81f937f30c7..5d1f42c83f449 100644 --- a/src/librustdoc/visit_lib.rs +++ b/src/librustdoc/visit_lib.rs @@ -40,7 +40,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> LibEmbargoVisitor<'a, 'tcx, 'rcx, 'cstore> { cx, access_levels: RefMut::map(cx.renderinfo.borrow_mut(), |ri| &mut ri.access_levels), prev_level: Some(AccessLevel::Public), - visited_mods: FxHashSet() + visited_mods: FxHashSet::default() } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 84122688c83d2..a110248439ee5 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1930,7 +1930,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], let incomplete_features = ["generic_associated_types"]; let mut features = Features::new(); - let mut edition_enabled_features = FxHashMap(); + let mut edition_enabled_features = FxHashMap::default(); for &edition in ALL_EDITIONS { if edition <= crate_edition { diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 7ee5835062184..c1274e740590b 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -145,7 +145,7 @@ impl SourceMap { SourceMap { files: Lock::new(SourceMapFiles { file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap(), + stable_id_to_source_file: FxHashMap::default(), }), file_loader: Box::new(RealFileLoader), path_mapping, @@ -168,7 +168,7 @@ impl SourceMap { SourceMap { files: Lock::new(SourceMapFiles { file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap(), + stable_id_to_source_file: FxHashMap::default(), }), file_loader: file_loader, path_mapping, diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index f053cb10d0649..bc52a3e1c7c29 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -156,7 +156,7 @@ impl Mark { pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark { HygieneData::with(|data| { // Compute the path from a to the root - let mut a_path = FxHashSet::(); + let mut a_path = FxHashSet::::default(); while a != Mark::root() { a_path.insert(a); a = data.marks[a.0 as usize].parent; From 3c9258e604c7f5d3b7e86c34da1f067ff0a60257 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 16:57:53 +0200 Subject: [PATCH 2/9] Prefer `Default::default` over `FxHash*::default` in struct constructors --- src/bootstrap/cache.rs | 20 ++-------- src/libarena/lib.rs | 32 ++++++---------- src/librustc/dep_graph/cgu_reuse_tracker.rs | 4 +- src/librustc/dep_graph/dep_tracking_map.rs | 2 +- src/librustc/dep_graph/graph.rs | 10 ++--- src/librustc/dep_graph/prev.rs | 2 +- src/librustc/dep_graph/serialized.rs | 12 +----- src/librustc/hir/map/definitions.rs | 8 ++-- src/librustc/hir/map/hir_id_validator.rs | 2 +- src/librustc/ich/hcx.rs | 2 +- src/librustc/ich/impls_ty.rs | 2 +- src/librustc/infer/freshen.rs | 2 +- .../infer/lexical_region_resolve/mod.rs | 2 +- src/librustc/infer/mod.rs | 10 ++--- src/librustc/infer/outlives/env.rs | 4 +- .../infer/outlives/free_region_map.rs | 6 +-- src/librustc/infer/region_constraints/mod.rs | 4 +- src/librustc/lint/context.rs | 6 +-- src/librustc/lint/levels.rs | 2 +- src/librustc/middle/dead.rs | 3 +- src/librustc/middle/lib_features.rs | 4 +- src/librustc/middle/region.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 18 ++++----- src/librustc/middle/stability.rs | 6 +-- src/librustc/mir/interpret/mod.rs | 4 +- src/librustc/mir/mono.rs | 4 +- src/librustc/session/code_stats.rs | 4 +- src/librustc/session/mod.rs | 6 +-- src/librustc/traits/error_reporting.rs | 2 +- src/librustc/traits/mod.rs | 2 +- src/librustc/traits/project.rs | 7 +--- src/librustc/traits/select.rs | 20 ++-------- src/librustc/traits/specialize/mod.rs | 22 +---------- src/librustc/traits/util.rs | 2 +- src/librustc/ty/context.rs | 38 ++++++------------- src/librustc/ty/fold.rs | 2 +- src/librustc/ty/mod.rs | 3 +- src/librustc/ty/query/on_disk_cache.rs | 26 ++++++------- src/librustc/ty/query/plumbing.rs | 6 +-- src/librustc/util/nodemap.rs | 4 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 6 +-- src/librustc_borrowck/borrowck/unused.rs | 2 +- src/librustc_codegen_llvm/back/lto.rs | 14 ++----- src/librustc_codegen_llvm/base.rs | 18 ++++----- src/librustc_codegen_llvm/context.rs | 18 ++++----- .../debuginfo/metadata.rs | 10 +---- src/librustc_codegen_llvm/debuginfo/mod.rs | 8 ++-- src/librustc_codegen_utils/codegen_backend.rs | 4 +- .../obligation_forest/mod.rs | 8 ++-- .../snapshot_map/mod.rs | 8 +++- src/librustc_data_structures/sync.rs | 4 +- .../transitive_relation.rs | 8 ++-- src/librustc_errors/lib.rs | 8 ++-- .../persist/dirty_clean.rs | 2 +- src/librustc_incremental/persist/load.rs | 6 +-- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/locator.rs | 2 +- src/librustc_mir/borrow_check/borrow_set.rs | 10 ++--- src/librustc_mir/borrow_check/mod.rs | 8 ++-- .../nll/type_check/free_region_relations.rs | 4 +- .../borrow_check/nll/type_check/mod.rs | 4 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/build/scope.rs | 2 +- .../dataflow/move_paths/builder.rs | 3 +- src/librustc_mir/hair/pattern/_match.rs | 2 +- src/librustc_mir/monomorphize/partitioning.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- .../transform/cleanup_post_borrowck.rs | 10 ++--- src/librustc_mir/transform/elaborate_drops.rs | 2 +- src/librustc_mir/util/pretty.rs | 2 +- src/librustc_resolve/lib.rs | 20 ++++------ src/librustc_typeck/check/wfcheck.rs | 3 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/variance/mod.rs | 2 +- src/librustdoc/clean/auto_trait.rs | 14 +++---- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/clean/mod.rs | 5 +-- src/librustdoc/core.rs | 6 +-- src/librustdoc/html/render.rs | 20 +++++----- src/libsyntax/source_map.rs | 11 ++---- src/libsyntax_pos/symbol.rs | 14 ++----- 82 files changed, 237 insertions(+), 362 deletions(-) diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index bca5ff85ba23e..4a50f744e7a54 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -169,19 +169,13 @@ impl Ord for Interned { } } -struct TyIntern { +#[derive(Default)] +struct TyIntern { items: Vec, set: HashMap>, } impl TyIntern { - fn new() -> TyIntern { - TyIntern { - items: Vec::new(), - set: HashMap::new(), - } - } - fn intern_borrow(&mut self, item: &B) -> Interned where B: Eq + Hash + ToOwned + ?Sized, @@ -212,19 +206,13 @@ impl TyIntern { } } +#[derive(Default)] pub struct Interner { strs: Mutex>, paths: Mutex>, } impl Interner { - fn new() -> Interner { - Interner { - strs: Mutex::new(TyIntern::new()), - paths: Mutex::new(TyIntern::new()), - } - } - pub fn intern_str(&self, s: &str) -> Interned { self.strs.lock().unwrap().intern_borrow(s) } @@ -238,7 +226,7 @@ impl Interner { } lazy_static! { - pub static ref INTERNER: Interner = Interner::new(); + pub static ref INTERNER: Interner = Interner::default(); } /// This is essentially a HashMap which allows storing any type in its input and diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index b02ae75eff86b..a7b34b6dc40af 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -114,10 +114,9 @@ impl TypedArenaChunk { const PAGE: usize = 4096; -impl TypedArena { +impl Default for TypedArena { /// Creates a new `TypedArena`. - #[inline] - pub fn new() -> TypedArena { + fn default() -> TypedArena { TypedArena { // We set both `ptr` and `end` to 0 so that the first call to // alloc() will trigger a grow(). @@ -127,7 +126,9 @@ impl TypedArena { _own: PhantomData, } } +} +impl TypedArena { /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &mut T { @@ -296,15 +297,17 @@ pub struct DroplessArena { unsafe impl Send for DroplessArena {} -impl DroplessArena { - pub fn new() -> DroplessArena { +impl Default for DroplessArena { + fn default() -> DroplessArena { DroplessArena { ptr: Cell::new(0 as *mut u8), end: Cell::new(0 as *mut u8), - chunks: RefCell::new(vec![]), + chunks: Default::default(), } } +} +impl DroplessArena { pub fn in_arena(&self, ptr: *const T) -> bool { let ptr = ptr as *const u8 as *mut u8; for chunk in &*self.chunks.borrow() { @@ -419,18 +422,13 @@ impl DroplessArena { } } +#[derive(Default)] +// FIXME(@Zoxc): this type is entirely unused in rustc pub struct SyncTypedArena { lock: MTLock>, } impl SyncTypedArena { - #[inline(always)] - pub fn new() -> SyncTypedArena { - SyncTypedArena { - lock: MTLock::new(TypedArena::new()) - } - } - #[inline(always)] pub fn alloc(&self, object: T) -> &mut T { // Extend the lifetime of the result since it's limited to the lock guard @@ -452,18 +450,12 @@ impl SyncTypedArena { } } +#[derive(Default)] pub struct SyncDroplessArena { lock: MTLock, } impl SyncDroplessArena { - #[inline(always)] - pub fn new() -> SyncDroplessArena { - SyncDroplessArena { - lock: MTLock::new(DroplessArena::new()) - } - } - #[inline(always)] pub fn in_arena(&self, ptr: *const T) -> bool { self.lock.lock().in_arena(ptr) diff --git a/src/librustc/dep_graph/cgu_reuse_tracker.rs b/src/librustc/dep_graph/cgu_reuse_tracker.rs index 8e6983e9ddfe0..99fc020bbe44f 100644 --- a/src/librustc/dep_graph/cgu_reuse_tracker.rs +++ b/src/librustc/dep_graph/cgu_reuse_tracker.rs @@ -51,8 +51,8 @@ pub struct CguReuseTracker { impl CguReuseTracker { pub fn new() -> CguReuseTracker { let data = TrackerData { - actual_reuse: FxHashMap::default(), - expected_reuse: FxHashMap::default(), + actual_reuse: Default::default(), + expected_reuse: Default::default(), }; CguReuseTracker { diff --git a/src/librustc/dep_graph/dep_tracking_map.rs b/src/librustc/dep_graph/dep_tracking_map.rs index 33b10bcfc8a92..a674b5df6395c 100644 --- a/src/librustc/dep_graph/dep_tracking_map.rs +++ b/src/librustc/dep_graph/dep_tracking_map.rs @@ -36,7 +36,7 @@ impl DepTrackingMap { DepTrackingMap { phantom: PhantomData, graph, - map: FxHashMap::default(), + map: Default::default(), } } } diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 971f4e86c5e0c..ddc5676c74eb5 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -101,11 +101,11 @@ impl DepGraph { DepGraph { data: Some(Lrc::new(DepGraphData { previous_work_products: prev_work_products, - dep_node_debug: Lock::new(FxHashMap::default()), + dep_node_debug: Lock::new(Default::default()), current: Lock::new(CurrentDepGraph::new()), previous: prev_graph, colors: Lock::new(DepNodeColorMap::new(prev_graph_node_count)), - loaded_from_cache: Lock::new(FxHashMap::default()), + loaded_from_cache: Lock::new(Default::default()), })), fingerprints: Lrc::new(Lock::new(fingerprints)), } @@ -209,7 +209,7 @@ impl DepGraph { |key| OpenTask::Regular(Lock::new(RegularOpenTask { node: key, reads: SmallVec::new(), - read_set: FxHashSet::default(), + read_set: Default::default(), })), |data, key, task| data.borrow_mut().complete_task(key, task)) } @@ -353,7 +353,7 @@ impl DepGraph { let (result, open_task) = ty::tls::with_context(|icx| { let task = OpenTask::Anon(Lock::new(AnonOpenTask { reads: SmallVec::new(), - read_set: FxHashSet::default(), + read_set: Default::default(), })); let r = { @@ -937,7 +937,7 @@ impl CurrentDepGraph { CurrentDepGraph { nodes: IndexVec::new(), edges: IndexVec::new(), - node_to_node_index: FxHashMap::default(), + node_to_node_index: Default::default(), anon_id_seed: stable_hasher.finish(), forbidden_edge, total_read_count: 0, diff --git a/src/librustc/dep_graph/prev.rs b/src/librustc/dep_graph/prev.rs index 669a99019aa60..ebc50f4afb8c8 100644 --- a/src/librustc/dep_graph/prev.rs +++ b/src/librustc/dep_graph/prev.rs @@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxHashMap; use super::dep_node::DepNode; use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex}; -#[derive(Debug, RustcEncodable, RustcDecodable)] +#[derive(Debug, RustcEncodable, RustcDecodable, Default)] pub struct PreviousDepGraph { data: SerializedDepGraph, index: FxHashMap, diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 4c896a33e59c1..0c6c224fa914c 100644 --- a/src/librustc/dep_graph/serialized.rs +++ b/src/librustc/dep_graph/serialized.rs @@ -19,7 +19,7 @@ newtype_index! { } /// Data for use when recompiling the **current crate**. -#[derive(Debug, RustcEncodable, RustcDecodable)] +#[derive(Debug, RustcEncodable, RustcDecodable, Default)] pub struct SerializedDepGraph { /// The set of all DepNodes in the graph pub nodes: IndexVec, @@ -36,16 +36,6 @@ pub struct SerializedDepGraph { } impl SerializedDepGraph { - - pub fn new() -> SerializedDepGraph { - SerializedDepGraph { - nodes: IndexVec::new(), - fingerprints: IndexVec::new(), - edge_list_indices: IndexVec::new(), - edge_list_data: Vec::new(), - } - } - #[inline] pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 54d662cce3336..dd6891540868d 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -421,10 +421,10 @@ impl Definitions { node_to_def_index: NodeMap(), def_index_to_node: [vec![], vec![]], node_to_hir_id: IndexVec::new(), - parent_modules_of_macro_defs: FxHashMap::default(), - expansions_that_defined: FxHashMap::default(), - next_disambiguator: FxHashMap::default(), - def_index_to_span: FxHashMap::default(), + parent_modules_of_macro_defs: Default::default(), + expansions_that_defined: Default::default(), + next_disambiguator: Default::default(), + def_index_to_span: Default::default(), } } diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index d8dc75a059029..087efbd4a22dd 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -51,7 +51,7 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> { HirIdValidator { hir_map, owner_def_index: None, - hir_ids_seen: FxHashMap::default(), + hir_ids_seen: Default::default(), errors: Vec::new(), } } diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index f0ab449b70289..1c7c1b854da45 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -370,7 +370,7 @@ impl<'a> HashStable> for Span { // recursing every time. thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap::default()); + RefCell::new(Default::default()); } let sub_hash: u64 = CACHE.with(|cache| { diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 63a3534fb706a..d8b3cbded13d4 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -32,7 +32,7 @@ for &'gcx ty::List hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap::default()); + RefCell::new(Default::default()); } let hash = CACHE.with(|cache| { diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 26c252cef0921..c7785d8317173 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> { TypeFreshener { infcx, freshen_count: 0, - freshen_map: FxHashMap::default(), + freshen_map: Default::default(), } } diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 066951c930b80..8f28e9a320df2 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -614,7 +614,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { dup_found: bool, } let mut state = WalkState { - set: FxHashSet::default(), + set: Default::default(), stack: vec![orig_node_idx], result: Vec::new(), dup_found: false, diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index c1c09a7e7fa35..f5513acecf9e7 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -478,7 +478,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> { pub fn infer_ctxt(self) -> InferCtxtBuilder<'a, 'gcx, 'tcx> { InferCtxtBuilder { global_tcx: self, - arena: SyncDroplessArena::new(), + arena: SyncDroplessArena::default(), fresh_tables: None, } } @@ -526,15 +526,15 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> { f(InferCtxt { tcx, in_progress_tables, - projection_cache: RefCell::new(traits::ProjectionCache::new()), + projection_cache: Default::default(), type_variables: RefCell::new(type_variable::TypeVariableTable::new()), int_unification_table: RefCell::new(ut::UnificationTable::new()), float_unification_table: RefCell::new(ut::UnificationTable::new()), region_constraints: RefCell::new(Some(RegionConstraintCollector::new())), lexical_region_resolutions: RefCell::new(None), - selection_cache: traits::SelectionCache::new(), - evaluation_cache: traits::EvaluationCache::new(), - reported_trait_errors: RefCell::new(FxHashMap::default()), + selection_cache: Default::default(), + evaluation_cache: Default::default(), + reported_trait_errors: Default::default(), tainted_by_errors_flag: Cell::new(false), err_count_on_creation: tcx.sess.err_count(), in_snapshot: Cell::new(false), diff --git a/src/librustc/infer/outlives/env.rs b/src/librustc/infer/outlives/env.rs index 631ff58d3e37e..726bb388252f9 100644 --- a/src/librustc/infer/outlives/env.rs +++ b/src/librustc/infer/outlives/env.rs @@ -81,8 +81,8 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self { let mut env = OutlivesEnvironment { param_env, - free_region_map: FreeRegionMap::new(), - region_bound_pairs_map: FxHashMap::default(), + free_region_map: Default::default(), + region_bound_pairs_map: Default::default(), region_bound_pairs_accum: vec![], }; diff --git a/src/librustc/infer/outlives/free_region_map.rs b/src/librustc/infer/outlives/free_region_map.rs index e19ecfd427bec..588a00eb50361 100644 --- a/src/librustc/infer/outlives/free_region_map.rs +++ b/src/librustc/infer/outlives/free_region_map.rs @@ -11,7 +11,7 @@ use ty::{self, Lift, TyCtxt, Region}; use rustc_data_structures::transitive_relation::TransitiveRelation; -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)] pub struct FreeRegionMap<'tcx> { // Stores the relation `a < b`, where `a` and `b` are regions. // @@ -21,10 +21,6 @@ pub struct FreeRegionMap<'tcx> { } impl<'tcx> FreeRegionMap<'tcx> { - pub fn new() -> Self { - FreeRegionMap { relation: TransitiveRelation::new() } - } - pub fn is_empty(&self) -> bool { self.relation.is_empty() } diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index d631ddbf31dc3..a38be941b9a5c 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -345,8 +345,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> { RegionConstraintCollector { var_infos: VarInfos::default(), data: RegionConstraintData::default(), - lubs: FxHashMap::default(), - glbs: FxHashMap::default(), + lubs: Default::default(), + glbs: Default::default(), bound_count: 0, undo_log: Vec::new(), unification_table: ut::UnificationTable::new(), diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 730f85a3dd0bb..7e2532bb1c4e8 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -159,9 +159,9 @@ impl LintStore { pre_expansion_passes: Some(vec![]), early_passes: Some(vec![]), late_passes: Some(vec![]), - by_name: FxHashMap::default(), - future_incompatible: FxHashMap::default(), - lint_groups: FxHashMap::default(), + by_name: Default::default(), + future_incompatible: Default::default(), + lint_groups: Default::default(), } } diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index f775ddf210f8e..475ca8da6b93c 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -175,7 +175,7 @@ impl<'a> LintLevelsBuilder<'a> { sess, sets, cur: 0, - id_to_set: FxHashMap::default(), + id_to_set: Default::default(), warn_about_weird_lints: sess.buffered_lints.borrow().is_some(), } } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 06547796972b1..cd85d5e361440 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -50,6 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> { worklist: Vec, tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &'a ty::TypeckTables<'tcx>, + // TODO: remove this `Box` live_symbols: Box>, repr_has_repr_c: bool, in_pat: bool, @@ -429,7 +430,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, worklist, tcx, tables: &ty::TypeckTables::empty(None), - live_symbols: box FxHashSet::default(), + live_symbols: box Default::default(), repr_has_repr_c: false, in_pat: false, inherited_pub_visibility: false, diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index aaa218926f867..7d65d412e01d7 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -31,8 +31,8 @@ pub struct LibFeatures { impl LibFeatures { fn new() -> LibFeatures { LibFeatures { - stable: FxHashMap::default(), - unstable: FxHashSet::default(), + stable: Default::default(), + unstable: Default::default(), } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 3e49dec4401d8..d00fbdeca21aa 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -1347,7 +1347,7 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) parent: None, var_parent: None, }, - terminating_scopes: FxHashSet::default(), + terminating_scopes: Default::default(), }; let body = tcx.hir.body(body_id); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index d959029d1202a..e89ba8ac54ff6 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -216,6 +216,7 @@ struct NamedRegionMap { } /// See `NamedRegionMap`. +#[derive(Default)] pub struct ResolveLifetimes { defs: FxHashMap>>, late_bound: FxHashMap>>, @@ -392,11 +393,7 @@ fn resolve_lifetimes<'tcx>( let named_region_map = krate(tcx); - let mut rl = ResolveLifetimes { - defs: FxHashMap::default(), - late_bound: FxHashMap::default(), - object_lifetime_defaults: FxHashMap::default(), - }; + let mut rl = ResolveLifetimes::default(); for (k, v) in named_region_map.defs { let hir_id = tcx.hir.node_to_hir_id(k); @@ -2017,7 +2014,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { map: self.map, outer_index: ty::INNERMOST, have_bound_regions: false, - lifetimes: FxHashSet::default(), + lifetimes: Default::default(), }; gather.visit_ty(input); @@ -2536,15 +2533,13 @@ fn insert_late_bound_lifetimes( debug!("insert_late_bound_lifetimes(decl={:?}, generics={:?})", decl, generics); - let mut constrained_by_input = ConstrainedCollector { - regions: FxHashSet::default(), - }; + let mut constrained_by_input = ConstrainedCollector::default(); for arg_ty in &decl.inputs { constrained_by_input.visit_ty(arg_ty); } let mut appears_in_output = AllCollector { - regions: FxHashSet::default(), + regions: Default::default(), }; intravisit::walk_fn_ret_ty(&mut appears_in_output, &decl.output); @@ -2556,7 +2551,7 @@ fn insert_late_bound_lifetimes( // Subtle point: because we disallow nested bindings, we can just // ignore binders here and scrape up all names we see. let mut appears_in_where_clause = AllCollector { - regions: FxHashSet::default(), + regions: Default::default(), }; appears_in_where_clause.visit_generics(generics); @@ -2610,6 +2605,7 @@ fn insert_late_bound_lifetimes( return; + #[derive(Default)] struct ConstrainedCollector { regions: FxHashSet, } diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index a5d3e8023bd12..ba79cf66d0848 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -405,9 +405,9 @@ impl<'a, 'tcx> Index<'tcx> { staged_api.insert(LOCAL_CRATE, is_staged_api); let mut index = Index { staged_api, - stab_map: FxHashMap::default(), - depr_map: FxHashMap::default(), - active_features: FxHashSet::default(), + stab_map: Default::default(), + depr_map: Default::default(), + active_features: Default::default(), }; let ref active_lib_features = tcx.features().declared_lib_features; diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index a5e37274b8e3d..8c8073080aaf8 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -453,8 +453,8 @@ pub struct AllocMap<'tcx, M> { impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> { pub fn new() -> Self { AllocMap { - id_to_type: FxHashMap::default(), - type_interner: FxHashMap::default(), + id_to_type: Default::default(), + type_interner: Default::default(), next_id: AllocId(0), } } diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 9b31d12981553..ff2bf3d78070d 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -121,7 +121,7 @@ impl<'tcx> CodegenUnit<'tcx> { pub fn new(name: InternedString) -> CodegenUnit<'tcx> { CodegenUnit { name: name, - items: FxHashMap::default(), + items: Default::default(), size_estimate: None, } } @@ -251,7 +251,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> { pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self { CodegenUnitNameBuilder { tcx, - cache: FxHashMap::default(), + cache: Default::default(), } } diff --git a/src/librustc/session/code_stats.rs b/src/librustc/session/code_stats.rs index eb9bfe984229b..b1dcfdfcda038 100644 --- a/src/librustc/session/code_stats.rs +++ b/src/librustc/session/code_stats.rs @@ -54,14 +54,12 @@ pub struct TypeSizeInfo { pub variants: Vec, } -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Default)] pub struct CodeStats { type_sizes: FxHashSet, } impl CodeStats { - pub fn new() -> Self { CodeStats { type_sizes: FxHashSet::default() } } - pub fn record_type_size(&mut self, kind: DataTypeKind, type_desc: S, diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index fccdbcb5c2f87..a17825a877d88 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1147,7 +1147,7 @@ pub fn build_session_( working_dir, lint_store: RwLock::new(lint::LintStore::new()), buffered_lints: Lock::new(Some(lint::LintBuffer::new())), - one_time_diagnostics: Lock::new(FxHashSet::default()), + one_time_diagnostics: Default::default(), plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())), plugin_attributes: OneThread::new(RefCell::new(Vec::new())), crate_types: Once::new(), @@ -1173,7 +1173,7 @@ pub fn build_session_( normalize_ty_after_erasing_regions: AtomicUsize::new(0), normalize_projection_ty: AtomicUsize::new(0), }, - code_stats: Lock::new(CodeStats::new()), + code_stats: Default::default(), optimization_fuel_crate, optimization_fuel_limit, print_fuel_crate, @@ -1207,7 +1207,7 @@ pub fn build_session_( }, has_global_allocator: Once::new(), has_panic_handler: Once::new(), - driver_lint_caps: FxHashMap::default(), + driver_lint_caps: Default::default(), }; validate_commandline_args_with_session_available(&sess); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 4bc2413357181..28c59d65becf2 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1404,7 +1404,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let cleaned_pred = pred.fold_with(&mut ParamToVarFolder { infcx: self, - var_map: FxHashMap::default() + var_map: Default::default() }); let cleaned_pred = super::project::normalize( diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index d129cd486cf05..8bceebb23950c 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -48,7 +48,7 @@ pub use self::on_unimplemented::{OnUnimplementedDirective, OnUnimplementedNote}; pub use self::select::{EvaluationCache, SelectionContext, SelectionCache}; pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError}; pub use self::specialize::{OverlapError, specialization_graph, translate_substs}; -pub use self::specialize::{SpecializesCache, find_associated_item}; +pub use self::specialize::find_associated_item; pub use self::engine::{TraitEngine, TraitEngineExt}; pub use self::util::elaborate_predicates; pub use self::util::supertraits; diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 7c1f87fbf3fef..b29ee8f7cdce4 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -1601,6 +1601,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( /// FIXME: we probably also want some sort of cross-infcx cache here to /// reduce the amount of duplication. Let's see what we get with the Chalk /// reforms. +#[derive(Default)] pub struct ProjectionCache<'tcx> { map: SnapshotMap, ProjectionCacheEntry<'tcx>>, } @@ -1643,12 +1644,6 @@ pub struct ProjectionCacheSnapshot { } impl<'tcx> ProjectionCache<'tcx> { - pub fn new() -> Self { - ProjectionCache { - map: SnapshotMap::new() - } - } - pub fn clear(&mut self) { self.map.clear(); } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 9e541799120ae..95683e0613e15 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -166,7 +166,7 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> { previous: TraitObligationStackList<'prev, 'tcx>, } -#[derive(Clone)] +#[derive(Clone, Default)] pub struct SelectionCache<'tcx> { hashmap: Lock< FxHashMap, WithDepNode>>>, @@ -444,7 +444,7 @@ impl<'tcx> From for SelectionError<'tcx> { } } -#[derive(Clone)] +#[derive(Clone, Default)] pub struct EvaluationCache<'tcx> { hashmap: Lock, WithDepNode>>, } @@ -3789,26 +3789,14 @@ impl<'tcx> TraitObligation<'tcx> { } impl<'tcx> SelectionCache<'tcx> { - pub fn new() -> SelectionCache<'tcx> { - SelectionCache { - hashmap: Lock::new(FxHashMap::default()), - } - } - pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap::default() + self.hashmap.borrow_mut().clear(); } } impl<'tcx> EvaluationCache<'tcx> { - pub fn new() -> EvaluationCache<'tcx> { - EvaluationCache { - hashmap: Lock::new(FxHashMap::default()), - } - } - pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap::default() + self.hashmap.borrow_mut().clear(); } } diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 010b79f7d585b..0ce1d8f822755 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -22,7 +22,7 @@ use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use hir::def_id::DefId; use infer::{InferCtxt, InferOk}; use ty::subst::{Subst, Substs}; @@ -284,26 +284,6 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, }) } -pub struct SpecializesCache { - map: FxHashMap<(DefId, DefId), bool>, -} - -impl SpecializesCache { - pub fn new() -> Self { - SpecializesCache { - map: FxHashMap::default() - } - } - - pub fn check(&self, a: DefId, b: DefId) -> Option { - self.map.get(&(a, b)).cloned() - } - - pub fn insert(&mut self, a: DefId, b: DefId, result: bool) { - self.map.insert((a, b), result); - } -} - // Query provider for `specialization_graph_of`. pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_id: DefId) diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 81fa1ea02b06b..0b7526dd78428 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -59,7 +59,7 @@ struct PredicateSet<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> { fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PredicateSet<'a, 'gcx, 'tcx> { - PredicateSet { tcx: tcx, set: FxHashSet::default() } + PredicateSet { tcx: tcx, set: Default::default() } } fn insert(&mut self, pred: &ty::Predicate<'tcx>) -> bool { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2325570c40ff6..64f87d077bab3 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -89,13 +89,14 @@ pub struct AllArenas<'tcx> { impl<'tcx> AllArenas<'tcx> { pub fn new() -> Self { AllArenas { - global: WorkerLocal::new(|_| GlobalArenas::new()), - interner: SyncDroplessArena::new(), + global: WorkerLocal::new(|_| GlobalArenas::default()), + interner: SyncDroplessArena::default(), } } } /// Internal storage +#[derive(Default)] pub struct GlobalArenas<'tcx> { // internings layout: TypedArena, @@ -111,21 +112,6 @@ pub struct GlobalArenas<'tcx> { const_allocs: TypedArena, } -impl<'tcx> GlobalArenas<'tcx> { - pub fn new() -> GlobalArenas<'tcx> { - GlobalArenas { - layout: TypedArena::new(), - generics: TypedArena::new(), - trait_def: TypedArena::new(), - adt_def: TypedArena::new(), - steal_mir: TypedArena::new(), - mir: TypedArena::new(), - tables: TypedArena::new(), - const_allocs: TypedArena::new(), - } - } -} - type InternedSet<'tcx, T> = Lock>>; pub struct CtxtInterners<'tcx> { @@ -462,15 +448,15 @@ impl<'tcx> TypeckTables<'tcx> { adjustments: ItemLocalMap(), pat_binding_modes: ItemLocalMap(), pat_adjustments: ItemLocalMap(), - upvar_capture_map: FxHashMap::default(), + upvar_capture_map: Default::default(), closure_kind_origins: ItemLocalMap(), liberated_fn_sigs: ItemLocalMap(), fru_field_types: ItemLocalMap(), cast_kinds: ItemLocalMap(), used_trait_imports: Lrc::new(DefIdSet()), tainted_by_errors: false, - free_region_map: FreeRegionMap::new(), - concrete_existential_types: FxHashMap::default(), + free_region_map: Default::default(), + concrete_existential_types: Default::default(), } } @@ -1231,14 +1217,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { extern_providers, on_disk_query_result_cache, ), - rcache: Lock::new(FxHashMap::default()), - selection_cache: traits::SelectionCache::new(), - evaluation_cache: traits::EvaluationCache::new(), + rcache: Default::default(), + selection_cache: Default::default(), + evaluation_cache: Default::default(), crate_name: Symbol::intern(crate_name), data_layout, - layout_interner: Lock::new(FxHashSet::default()), - stability_interner: Lock::new(FxHashSet::default()), - allocation_interner: Lock::new(FxHashSet::default()), + layout_interner: Default::default(), + stability_interner: Default::default(), + allocation_interner: Default::default(), alloc_map: Lock::new(interpret::AllocMap::new()), tx_to_llvm_workers: Lock::new(tx), output_filenames: Arc::new(output_filenames.clone()), diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index cdb0500ec61bf..80dfd263af9af 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -753,7 +753,7 @@ impl LateBoundRegionsCollector { fn new(just_constrained: bool) -> Self { LateBoundRegionsCollector { current_index: ty::INNERMOST, - regions: FxHashSet::default(), + regions: Default::default(), just_constrained, } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index aba488095bdec..760114a583885 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1841,8 +1841,7 @@ impl<'a> HashStable> for AdtDef { hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { thread_local! { - static CACHE: RefCell> = - RefCell::new(FxHashMap::default()); + static CACHE: RefCell> = Default::default(); } let hash: Fingerprint = CACHE.with(|cache| { diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 7deb8d77c3105..62bdf40317d12 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -136,14 +136,14 @@ impl<'sess> OnDiskCache<'sess> { OnDiskCache { serialized_data: data, file_index_to_stable_id: footer.file_index_to_stable_id, - file_index_to_file: Lock::new(FxHashMap::default()), + file_index_to_file: Default::default(), prev_cnums: footer.prev_cnums, cnum_map: Once::new(), source_map: sess.source_map(), - current_diagnostics: Lock::new(FxHashMap::default()), + current_diagnostics: Default::default(), query_result_index: footer.query_result_index.into_iter().collect(), prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(), - synthetic_expansion_infos: Lock::new(FxHashMap::default()), + synthetic_expansion_infos: Default::default(), alloc_decoding_state: AllocDecodingState::new(footer.interpret_alloc_index), } } @@ -151,15 +151,15 @@ impl<'sess> OnDiskCache<'sess> { pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> { OnDiskCache { serialized_data: Vec::new(), - file_index_to_stable_id: FxHashMap::default(), - file_index_to_file: Lock::new(FxHashMap::default()), + file_index_to_stable_id: Default::default(), + file_index_to_file: Default::default(), prev_cnums: vec![], cnum_map: Once::new(), source_map, - current_diagnostics: Lock::new(FxHashMap::default()), - query_result_index: FxHashMap::default(), - prev_diagnostics_index: FxHashMap::default(), - synthetic_expansion_infos: Lock::new(FxHashMap::default()), + current_diagnostics: Default::default(), + query_result_index: Default::default(), + prev_diagnostics_index: Default::default(), + synthetic_expansion_infos: Default::default(), alloc_decoding_state: AllocDecodingState::new(Vec::new()), } } @@ -190,10 +190,10 @@ impl<'sess> OnDiskCache<'sess> { let mut encoder = CacheEncoder { tcx, encoder, - type_shorthands: FxHashMap::default(), - predicate_shorthands: FxHashMap::default(), - expn_info_shorthands: FxHashMap::default(), - interpret_allocs: FxHashMap::default(), + type_shorthands: Default::default(), + predicate_shorthands: Default::default(), + expn_info_shorthands: Default::default(), + interpret_allocs: Default::default(), interpret_allocs_inverse: Vec::new(), source_map: CachingSourceMapView::new(tcx.sess.source_map()), file_to_file_index, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 461acd72865e4..71e435fea77d4 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -55,8 +55,8 @@ impl QueryValue { } } -impl<'tcx, M: QueryConfig<'tcx>> QueryCache<'tcx, M> { - pub(super) fn new() -> QueryCache<'tcx, M> { +impl<'tcx, M: QueryConfig<'tcx>> Default for QueryCache<'tcx, M> { + fn default() -> QueryCache<'tcx, M> { QueryCache { results: FxHashMap::default(), active: FxHashMap::default(), @@ -699,7 +699,7 @@ macro_rules! define_queries_inner { providers, fallback_extern_providers: Box::new(fallback_extern_providers), on_disk_cache, - $($name: Lock::new(QueryCache::new())),* + $($name: Default::default()),* } } diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 7946d5a047c96..dbd3e00d9fd1d 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -22,9 +22,9 @@ pub use rustc_data_structures::fx::FxHashSet; macro_rules! define_id_collections { ($map_name:ident, $set_name:ident, $key:ty) => { pub type $map_name = FxHashMap<$key, T>; - pub fn $map_name() -> $map_name { FxHashMap::default() } + pub fn $map_name() -> $map_name { Default::default() } pub type $set_name = FxHashSet<$key>; - pub fn $set_name() -> $set_name { FxHashSet::default() } + pub fn $set_name() -> $set_name { Default::default() } } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 17deede5327f6..bfa2203cc04b2 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -182,7 +182,7 @@ impl PrintContext { fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Binder) where T: TypeFoldable<'tcx> { - let mut collector = LateBoundRegionNameCollector(FxHashSet::default()); + let mut collector = LateBoundRegionNameCollector(Default::default()); value.visit_with(&mut collector); self.used_region_names = Some(collector.0); self.region_index = 0; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index ca69eb90c37b2..da5c5f47c08ac 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -103,7 +103,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) // tuple structs/variants) do not have an associated body // and do not need borrowchecking. return Lrc::new(BorrowCheckResult { - used_mut_nodes: FxHashSet::default(), + used_mut_nodes: Default::default(), signalled_any_error: SignalledError::NoErrorsSeen, }) } @@ -120,7 +120,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet::default()), + used_mut_nodes: Default::default(), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; @@ -235,7 +235,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet::default()), + used_mut_nodes: Default::default(), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 7d2bcd61e156e..85794c5b10af4 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -45,7 +45,7 @@ struct UnusedMutCx<'a, 'tcx: 'a> { impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { fn check_unused_mut_pat(&self, pats: &[P]) { let tcx = self.bccx.tcx; - let mut mutables: FxHashMap<_, Vec<_>> = FxHashMap::default(); + let mut mutables: FxHashMap<_, Vec<_>> = Default::default(); for p in pats { p.each_binding(|_, hir_id, span, ident| { // Skip anything that looks like `_foo` diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index f648efb47df14..61856236a1491 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -502,7 +502,7 @@ fn thin_lto(cgcx: &CodegenContext, // If we don't compile incrementally, we don't need to load the // import data from LLVM. assert!(green_modules.is_empty()); - ThinLTOImports::new() + ThinLTOImports::default() }; info!("thin LTO import map loaded"); timeline.record("import-map-loaded"); @@ -873,19 +873,13 @@ impl ThinModule { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ThinLTOImports { // key = llvm name of importing module, value = list of modules it imports from imports: FxHashMap>, } impl ThinLTOImports { - fn new() -> ThinLTOImports { - ThinLTOImports { - imports: FxHashMap::default(), - } - } - fn modules_imported_by(&self, llvm_module_name: &str) -> &[String] { self.imports.get(llvm_module_name).map(|v| &v[..]).unwrap_or(&[]) } @@ -910,9 +904,7 @@ impl ThinLTOImports { .unwrap() .push(imported_module_name.to_owned()); } - let mut map = ThinLTOImports { - imports: FxHashMap::default(), - }; + let mut map = ThinLTOImports::default(); llvm::LLVMRustGetThinLTOModuleImports(data, imported_module_callback, &mut map as *mut _ as *mut libc::c_void); diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 5356014f67196..614a562846e86 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -70,7 +70,7 @@ use time_graph; use mono_item::{MonoItem, BaseMonoItemExt, MonoItemExt}; use type_::Type; use type_of::LayoutLlvmExt; -use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; +use rustc::util::nodemap::{FxHashMap, DefIdSet}; use CrateInfo; use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::sync::Lrc; @@ -1030,7 +1030,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( }).collect(); if tcx.sess.opts.debugging_opts.print_mono_items.is_some() { - let mut item_to_cgus: FxHashMap<_, Vec<_>> = FxHashMap::default(); + let mut item_to_cgus: FxHashMap<_, Vec<_>> = Default::default(); for cgu in &codegen_units { for (&mono_item, &linkage) in cgu.items() { @@ -1092,17 +1092,17 @@ impl CrateInfo { compiler_builtins: None, profiler_runtime: None, sanitizer_runtime: None, - is_no_builtins: FxHashSet::default(), - native_libraries: FxHashMap::default(), + is_no_builtins: Default::default(), + native_libraries: Default::default(), used_libraries: tcx.native_libraries(LOCAL_CRATE), link_args: tcx.link_args(LOCAL_CRATE), - crate_name: FxHashMap::default(), + crate_name: Default::default(), used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), - used_crate_source: FxHashMap::default(), - wasm_imports: FxHashMap::default(), - lang_item_to_crate: FxHashMap::default(), - missing_lang_items: FxHashMap::default(), + used_crate_source: Default::default(), + wasm_imports: Default::default(), + lang_item_to_crate: Default::default(), + missing_lang_items: Default::default(), }; let lang_items = tcx.lang_items(); diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 559ca6f0dfe51..826df82193a31 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -295,22 +295,22 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> { llcx, stats: RefCell::new(Stats::default()), codegen_unit, - instances: RefCell::new(FxHashMap::default()), - vtables: RefCell::new(FxHashMap::default()), - const_cstr_cache: RefCell::new(FxHashMap::default()), - const_unsized: RefCell::new(FxHashMap::default()), - const_globals: RefCell::new(FxHashMap::default()), + instances: Default::default(), + vtables: Default::default(), + const_cstr_cache: Default::default(), + const_unsized: Default::default(), + const_globals: Default::default(), statics_to_rauw: RefCell::new(Vec::new()), used_statics: RefCell::new(Vec::new()), - lltypes: RefCell::new(FxHashMap::default()), - scalar_lltypes: RefCell::new(FxHashMap::default()), - pointee_infos: RefCell::new(FxHashMap::default()), + lltypes: Default::default(), + scalar_lltypes: Default::default(), + pointee_infos: Default::default(), isize_ty, dbg_cx, eh_personality: Cell::new(None), eh_unwind_resume: Cell::new(None), rust_try_fn: Cell::new(None), - intrinsics: RefCell::new(FxHashMap::default()), + intrinsics: Default::default(), local_gen_sym_counter: Cell::new(0), } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 3c4e000854e55..846d505641103 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -96,6 +96,7 @@ pub struct UniqueTypeId(ast::Name); // created so far. The metadata nodes are indexed by UniqueTypeId, and, for // faster lookup, also by Ty. The TypeMap is responsible for creating // UniqueTypeIds. +#[derive(Default)] pub struct TypeMap<'ll, 'tcx> { // The UniqueTypeIds created so far unique_id_interner: Interner, @@ -108,15 +109,6 @@ pub struct TypeMap<'ll, 'tcx> { } impl TypeMap<'ll, 'tcx> { - pub fn new() -> Self { - TypeMap { - unique_id_interner: Interner::new(), - type_to_metadata: FxHashMap::default(), - unique_id_to_metadata: FxHashMap::default(), - type_to_unique_id: FxHashMap::default(), - } - } - // Adds a Ty to metadata mapping to the TypeMap. The method will fail if // the mapping already exists. fn register_type_with_metadata( diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 2cd44b2a6c41d..042e72e921ece 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -100,11 +100,11 @@ impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> { llcontext, llmod, builder, - created_files: RefCell::new(FxHashMap::default()), - created_enum_disr_types: RefCell::new(FxHashMap::default()), - type_map: RefCell::new(TypeMap::new()), + created_files: Default::default(), + created_enum_disr_types: Default::default(), + type_map: Default::default(), namespace_map: RefCell::new(DefIdMap()), - composite_types_completed: RefCell::new(FxHashSet::default()), + composite_types_completed: Default::default(), } } } diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 48e1292d435e5..046f0cccfee05 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -28,7 +28,6 @@ use std::path::Path; use std::sync::{mpsc, Arc}; use rustc_data_structures::owning_ref::OwningRef; -use rustc_data_structures::sync::Lrc; use flate2::Compression; use flate2::write::DeflateEncoder; @@ -42,7 +41,6 @@ use rustc::middle::cstore::EncodedMetadata; use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; use rustc_target::spec::Target; -use rustc_data_structures::fx::FxHashMap; use rustc_mir::monomorphize::collector; use link::out_filename; @@ -132,7 +130,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { ::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { - Lrc::new(FxHashMap::default()) // Just a dummy + Default::default() // Just a dummy }; providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 5bc0404a3dace..ccf2a7f81590e 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -187,11 +187,11 @@ impl ObligationForest { pub fn new() -> ObligationForest { ObligationForest { nodes: vec![], - done_cache: FxHashSet::default(), - waiting_cache: FxHashMap::default(), + done_cache: Default::default(), + waiting_cache: Default::default(), scratch: Some(vec![]), obligation_tree_id_generator: (0..).map(|i| ObligationTreeId(i)), - error_cache: FxHashMap::default(), + error_cache: Default::default(), } } @@ -303,7 +303,7 @@ impl ObligationForest { self.error_cache .entry(node.obligation_tree_id) - .or_insert_with(|| FxHashSet::default()) + .or_default() .insert(node.obligation.as_predicate().clone()); } diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index 26528f4434576..f8663cd4fd436 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -35,16 +35,20 @@ enum UndoLog { Noop, } -impl SnapshotMap +impl Default for SnapshotMap where K: Hash + Clone + Eq { - pub fn new() -> Self { + fn default() -> Self { SnapshotMap { map: FxHashMap::default(), undo_log: vec![], } } +} +impl SnapshotMap + where K: Hash + Clone + Eq +{ pub fn clear(&mut self) { self.map.clear(); self.undo_log.clear(); diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index a2893a60cb680..6a4012c81984d 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -133,7 +133,7 @@ cfg_if! { pub type MTRef<'a, T> = &'a mut T; - #[derive(Debug)] + #[derive(Debug, Default)] pub struct MTLock(T); impl MTLock { @@ -228,7 +228,7 @@ cfg_if! { pub type MTRef<'a, T> = &'a T; - #[derive(Debug)] + #[derive(Debug, Default)] pub struct MTLock(Lock); impl MTLock { diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index a48b6f381a558..3cc467aa038c4 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -51,8 +51,8 @@ struct Edge { target: Index, } -impl TransitiveRelation { - pub fn new() -> TransitiveRelation { +impl Default for TransitiveRelation { + fn default() -> TransitiveRelation { TransitiveRelation { elements: vec![], map: FxHashMap::default(), @@ -60,7 +60,9 @@ impl TransitiveRelation { closure: Lock::new(None), } } +} +impl TransitiveRelation { pub fn is_empty(&self) -> bool { self.edges.is_empty() } @@ -95,7 +97,7 @@ impl TransitiveRelation { where F: FnMut(&T) -> Option, U: Clone + Debug + Eq + Hash + Clone, { - let mut result = TransitiveRelation::new(); + let mut result = TransitiveRelation::default(); for edge in &self.edges { result.add(f(&self.elements[edge.source.0])?, f(&self.elements[edge.target.0])?); } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index bec8d2997f7db..f02a5e2bc5d3a 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -382,9 +382,9 @@ impl Handler { emitter: Lock::new(e), continue_after_error: LockCell::new(true), delayed_span_bugs: Lock::new(Vec::new()), - taught_diagnostics: Lock::new(FxHashSet::default()), - emitted_diagnostic_codes: Lock::new(FxHashSet::default()), - emitted_diagnostics: Lock::new(FxHashSet::default()), + taught_diagnostics: Default::default(), + emitted_diagnostic_codes: Default::default(), + emitted_diagnostics: Default::default(), } } @@ -398,7 +398,7 @@ impl Handler { /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. pub fn reset_err_count(&self) { - *self.emitted_diagnostics.borrow_mut() = FxHashSet::default(); + self.emitted_diagnostics.borrow_mut().clear(); self.err_count.store(0, SeqCst); } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index fa5eda69f76a4..58a799bb45f2d 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -226,7 +226,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let krate = tcx.hir.krate(); let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, - checked_attrs: FxHashSet::default(), + checked_attrs: Default::default(), }; krate.visit_all_item_likes(&mut dirty_clean_visitor); diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index e2eaa59d627dc..2f7e1af1ff6c2 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -48,7 +48,7 @@ impl LoadResult<(PreviousDepGraph, WorkProductMap)> { match self { LoadResult::Error { message } => { sess.warn(&message); - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) + Default::default() }, LoadResult::DataOutOfDate => { if let Err(err) = delete_all_session_dir_contents(sess) { @@ -56,7 +56,7 @@ impl LoadResult<(PreviousDepGraph, WorkProductMap)> { incremental compilation session directory contents `{}`: {}.", dep_graph_path(sess).display(), err)); } - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) + Default::default() } LoadResult::Ok { data } => data } @@ -117,7 +117,7 @@ pub fn load_dep_graph(sess: &Session) -> if sess.opts.incremental.is_none() { // No incremental compilation. return MaybeAsync::Sync(LoadResult::Ok { - data: (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap::default()) + data: Default::default(), }); } diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index f102417c3452a..2be9883d03d9b 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -111,7 +111,7 @@ impl CStore { // corresponding `CrateNum`. This first entry will always remain // `None`. metas: RwLock::new(IndexVec::from_elem_n(None, 1)), - extern_mod_crate_map: Lock::new(FxHashMap::default()), + extern_mod_crate_map: Default::default(), metadata_loader, } } diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 0514755d782bf..e7e6dd71a7668 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -459,7 +459,7 @@ impl<'a> Context<'a> { let mut candidates: FxHashMap< _, (FxHashMap<_, _>, FxHashMap<_, _>, FxHashMap<_, _>), - > = FxHashMap::default(); + > = Default::default(); let mut staticlibs = vec![]; // First, find all possible candidate rlibs and dylibs purely based on diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 6096f992391d4..ab44ebc052f30 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -151,11 +151,11 @@ impl<'tcx> BorrowSet<'tcx> { tcx, mir, idx_vec: IndexVec::new(), - location_map: FxHashMap::default(), - activation_map: FxHashMap::default(), - region_map: FxHashMap::default(), - local_map: FxHashMap::default(), - pending_activations: FxHashMap::default(), + location_map: Default::default(), + activation_map: Default::default(), + region_map: Default::default(), + local_map: Default::default(), + pending_activations: Default::default(), locals_state_at_exit: LocalsStateAtExit::build(locals_are_invalidated_at_exit, mir, move_data), }; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 818b71ded37f8..6ef8b15545872 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -252,13 +252,13 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( location_table, movable_generator, locals_are_invalidated_at_exit, - access_place_error_reported: FxHashSet::default(), - reservation_error_reported: FxHashSet::default(), + access_place_error_reported: Default::default(), + reservation_error_reported: Default::default(), move_error_reported: BTreeMap::new(), - uninitialized_error_reported: FxHashSet::default(), + uninitialized_error_reported: Default::default(), errors_buffer, nonlexical_regioncx: regioncx, - used_mut: FxHashSet::default(), + used_mut: Default::default(), used_mut_upvars: SmallVec::new(), borrow_set, dominators, diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index 35342b2129e6e..f8c839e4d3f88 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -80,8 +80,8 @@ crate fn create( region_bound_pairs: Vec::new(), relations: UniversalRegionRelations { universal_regions: universal_regions.clone(), - outlives: TransitiveRelation::new(), - inverse_outlives: TransitiveRelation::new(), + outlives: Default::default(), + inverse_outlives: Default::default(), }, }.create() } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index bdaea23d22bc1..9d9588dd9b904 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -128,7 +128,7 @@ pub(crate) fn type_check<'gcx, 'tcx>( let mut constraints = MirTypeckRegionConstraints { liveness_constraints: LivenessValues::new(elements), outlives_constraints: ConstraintSet::default(), - closure_bounds_mapping: FxHashMap::default(), + closure_bounds_mapping: Default::default(), type_tests: Vec::default(), }; let mut placeholder_indices = PlaceholderIndices::default(); @@ -847,7 +847,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { region_bound_pairs, implicit_region_bound, borrowck_context, - reported_errors: FxHashSet::default(), + reported_errors: Default::default(), universal_region_relations, } } diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 06e394775e8c6..c7da9c4fbd792 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // these maps are empty to start; cases are // added below in add_cases_to_switch options: vec![], - indices: FxHashMap::default(), + indices: Default::default(), } } } diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index afb3d00d461e0..b3e6278825683 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -358,7 +358,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { needs_cleanup: false, drops: vec![], cached_generator_drop: None, - cached_exits: FxHashMap::default(), + cached_exits: Default::default(), cached_unwind: CachedBlock::default(), }); } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index c5b1353d74b3e..08696dc098e00 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -11,7 +11,6 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::mir::tcx::RvalueInitializationState; -use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{IndexVec}; use std::collections::hash_map::Entry; @@ -53,7 +52,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { v, ) }).collect(), - projections: FxHashMap::default(), + projections: Default::default(), }, move_paths, path_map, diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index aa1c6902dce33..04a297d0a8317 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -320,7 +320,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { f: F) -> R where F: for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R { - let pattern_arena = TypedArena::new(); + let pattern_arena = TypedArena::default(); f(MatchCheckCtxt { tcx, diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index d16d900b11a7e..3a1108bb16983 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -703,7 +703,7 @@ fn internalize_symbols<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>, // Build a map from every monomorphization to all the monomorphizations that // reference it. - let mut accessor_map: FxHashMap, Vec>> = FxHashMap::default(); + let mut accessor_map: FxHashMap, Vec>> = Default::default(); inlining_map.iter_accesses(|accessor, accessees| { for accessee in accessees { accessor_map.entry(*accessee) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 77e580d5855f6..ae881bad58dcd 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -57,7 +57,7 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> { }, tcx, param_env, - used_unsafe: FxHashSet::default(), + used_unsafe: Default::default(), inherited_blocks: vec![], } } diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index 56da1919beb12..4d3b422ab2817 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -41,6 +41,7 @@ use transform::{MirPass, MirSource}; pub struct CleanEndRegions; +#[derive(Default)] struct GatherBorrowedRegions { seen_regions: FxHashSet, } @@ -56,9 +57,7 @@ impl MirPass for CleanEndRegions { mir: &mut Mir<'tcx>) { if !tcx.emit_end_regions() { return; } - let mut gather = GatherBorrowedRegions { - seen_regions: FxHashSet::default() - }; + let mut gather = GatherBorrowedRegions::default(); gather.visit_mir(mir); let mut delete = DeleteTrivialEndRegions { seen_regions: &mut gather.seen_regions }; @@ -139,6 +138,7 @@ impl<'tcx> MutVisitor<'tcx> for DeleteAscribeUserType { pub struct CleanFakeReadsAndBorrows; +#[derive(Default)] pub struct DeleteAndRecordFakeReads { fake_borrow_temporaries: FxHashSet, } @@ -153,9 +153,7 @@ impl MirPass for CleanFakeReadsAndBorrows { _tcx: TyCtxt<'a, 'tcx, 'tcx>, _source: MirSource, mir: &mut Mir<'tcx>) { - let mut delete_reads = DeleteAndRecordFakeReads { - fake_borrow_temporaries: FxHashSet::default(), - }; + let mut delete_reads = DeleteAndRecordFakeReads::default(); delete_reads.visit_mir(mir); let mut delete_borrows = DeleteFakeBorrows { fake_borrow_temporaries: delete_reads.fake_borrow_temporaries, diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index e748500cd3ad2..e1165e865cec2 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -75,7 +75,7 @@ impl MirPass for ElaborateDrops { env: &env, flow_inits, flow_uninits, - drop_flags: FxHashMap::default(), + drop_flags: Default::default(), patch: MirPatch::new(mir), }.elaborate() }; diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 7faef65d99458..25bd02ff6dc5d 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -536,7 +536,7 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>( writeln!(w, "{{")?; // construct a scope tree and write it out - let mut scope_tree: FxHashMap> = FxHashMap::default(); + let mut scope_tree: FxHashMap> = Default::default(); for (index, scope_data) in mir.source_scopes.iter().enumerate() { if let Some(parent) = scope_data.parent_scope { scope_tree diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c7e440ba5674d..0f96ee6a688f1 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -930,7 +930,7 @@ struct Rib<'a> { impl<'a> Rib<'a> { fn new(kind: RibKind<'a>) -> Rib<'a> { Rib { - bindings: FxHashMap::default(), + bindings: Default::default(), kind, } } @@ -1053,11 +1053,11 @@ impl<'a> ModuleData<'a> { parent, kind, normal_ancestor_id, - resolutions: RefCell::new(FxHashMap::default()), + resolutions: Default::default(), legacy_macro_resolutions: RefCell::new(Vec::new()), macro_resolutions: RefCell::new(Vec::new()), builtin_attrs: RefCell::new(Vec::new()), - unresolved_invocations: RefCell::new(FxHashSet::default()), + unresolved_invocations: Default::default(), no_implicit_prelude: false, glob_importers: RefCell::new(Vec::new()), globs: RefCell::new(Vec::new()), @@ -1315,13 +1315,14 @@ impl<'a> NameBinding<'a> { /// /// All other types are defined somewhere and possibly imported, but the primitive ones need /// special handling, since they have no place of origin. +#[derive(Default)] struct PrimitiveTypeTable { primitive_types: FxHashMap, } impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { - let mut table = PrimitiveTypeTable { primitive_types: FxHashMap::default() }; + let mut table = PrimitiveTypeTable::default(); table.intern("bool", Bool); table.intern("char", Char); @@ -1482,6 +1483,7 @@ pub struct Resolver<'a, 'b: 'a> { } /// Nothing really interesting here, it just provides memory for the rest of the crate. +#[derive(Default)] pub struct ResolverArenas<'a> { modules: arena::TypedArena>, local_modules: RefCell>>, @@ -1782,15 +1784,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { } pub fn arenas() -> ResolverArenas<'a> { - ResolverArenas { - modules: arena::TypedArena::new(), - local_modules: RefCell::new(Vec::new()), - name_bindings: arena::TypedArena::new(), - import_directives: arena::TypedArena::new(), - name_resolutions: arena::TypedArena::new(), - invocation_data: arena::TypedArena::new(), - legacy_bindings: arena::TypedArena::new(), - } + Default::default() } /// Runs the function on each namespace. diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 7e1507b7e1f9a..a251269b21d2b 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -475,6 +475,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( }); // Now we build the substituted predicates. let default_obligations = predicates.predicates.iter().flat_map(|&(pred, _)| { + #[derive(Default)] struct CountParams { params: FxHashSet } impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { @@ -491,7 +492,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( true } } - let mut param_count = CountParams { params: FxHashSet::default() }; + let mut param_count = CountParams::default(); let has_region = pred.visit_with(&mut param_count); let substituted_pred = pred.subst(fcx.tcx, substs); // Don't check non-defaulted params, dependent defaults (including lifetimes) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 934db4b443591..eb52a013b0566 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -561,7 +561,7 @@ fn convert_variant<'a, 'tcx>( adt_kind: ty::AdtKind, attribute_def_id: DefId ) -> ty::VariantDef { - let mut seen_fields: FxHashMap = FxHashMap::default(); + let mut seen_fields: FxHashMap = Default::default(); let node_id = tcx.hir.as_local_node_id(did).unwrap(); let fields = def .fields() diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 25f6b259e96bc..7cc56bc192bb2 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -48,7 +48,7 @@ pub fn provide(providers: &mut Providers) { fn crate_variances<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Lrc { assert_eq!(crate_num, LOCAL_CRATE); - let mut arena = arena::TypedArena::new(); + let mut arena = arena::TypedArena::default(); let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &mut arena); let constraints_cx = constraints::add_constraints_from_crate(terms_cx); Lrc::new(solve::solve_constraints(constraints_cx)) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 16b4347d7ebe1..26487605bac67 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -178,7 +178,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { inner: ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, - provided_trait_methods: FxHashSet::default(), + provided_trait_methods: Default::default(), trait_: Some(trait_.clean(self.cx)), for_: ty.clean(self.cx), items: Vec::new(), @@ -267,9 +267,9 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { // all intermediate RegionVids. At the end, all constraints should // be between Regions (aka region variables). This gives us the information // we need to create the Generics. - let mut finished: FxHashMap<_, Vec<_>> = FxHashMap::default(); + let mut finished: FxHashMap<_, Vec<_>> = Default::default(); - let mut vid_map: FxHashMap = FxHashMap::default(); + let mut vid_map: FxHashMap = Default::default(); // Flattening is done in two parts. First, we insert all of the constraints // into a map. Each RegionTarget (either a RegionVid or a Region) maps @@ -577,11 +577,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { } = full_generics.clean(self.cx); let mut has_sized = FxHashSet::default(); - let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default(); - let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default(); - let mut ty_to_traits: FxHashMap> = FxHashMap::default(); + let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); + let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); + let mut ty_to_traits: FxHashMap> = Default::default(); - let mut ty_to_fn: FxHashMap, Option)> = FxHashMap::default(); + let mut ty_to_fn: FxHashMap, Option)> = Default::default(); for (orig_p, p) in clean_where_predicates { match p { diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ad0b633d03a7b..49cecd5b04bbc 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -368,7 +368,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet::default()); + }).unwrap_or_default(); debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id()); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2f9baf2d3ee0e..db605e57735aa 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -75,8 +75,7 @@ use self::cfg::Cfg; use self::auto_trait::AutoTraitFinder; use self::blanket_impl::BlanketImplFinder; -thread_local!(pub static MAX_DEF_ID: RefCell> = - RefCell::new(FxHashMap::default())); +thread_local!(pub static MAX_DEF_ID: RefCell> = Default::default()); const FN_OUTPUT_NAME: &'static str = "Output"; @@ -3388,7 +3387,7 @@ impl Clean> for doctree::Impl { .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet::default()); + }).unwrap_or_default(); ret.push(Item { name: None, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 14160e14bbc17..49f13df64d6ea 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -539,9 +539,9 @@ pub fn run_core(search_paths: SearchPaths, lt_substs: Default::default(), impl_trait_bounds: Default::default(), send_trait: send_trait, - fake_def_ids: RefCell::new(FxHashMap::default()), - all_fake_def_ids: RefCell::new(FxHashSet::default()), - generated_synthetics: RefCell::new(FxHashSet::default()), + fake_def_ids: Default::default(), + all_fake_def_ids: Default::default(), + generated_synthetics: Default::default(), all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(), }; debug!("crate: {:?}", tcx.hir.krate()); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d484df00f37e8..dda0f37c3f95b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -513,7 +513,7 @@ pub fn run(mut krate: clean::Crate, src_root, passes, include_sources: true, - local_sources: FxHashMap::default(), + local_sources: Default::default(), issue_tracker_base_url: None, layout: layout::Layout { logo: String::new(), @@ -522,7 +522,7 @@ pub fn run(mut krate: clean::Crate, krate: krate.name.clone(), }, css_file_extension: css_file_extension.clone(), - created_dirs: RefCell::new(FxHashSet::default()), + created_dirs: Default::default(), sort_modules_alphabetically, themes, resource_suffix, @@ -591,29 +591,29 @@ pub fn run(mut krate: clean::Crate, .collect(); let mut cache = Cache { - impls: FxHashMap::default(), + impls: Default::default(), external_paths, exact_paths, - paths: FxHashMap::default(), - implementors: FxHashMap::default(), + paths: Default::default(), + implementors: Default::default(), stack: Vec::new(), parent_stack: Vec::new(), search_index: Vec::new(), parent_is_trait_impl: false, - extern_locations: FxHashMap::default(), - primitive_locations: FxHashMap::default(), + extern_locations: Default::default(), + primitive_locations: Default::default(), stripped_mod: false, access_levels, crate_version: krate.version.take(), orphan_impl_items: Vec::new(), orphan_trait_impls: Vec::new(), - traits: krate.external_traits.lock().replace(FxHashMap::default()), + traits: krate.external_traits.lock().replace(Default::default()), deref_trait_did, deref_mut_trait_did, owned_box_did, - masked_crates: mem::replace(&mut krate.masked_crates, FxHashSet::default()), + masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), typarams: external_typarams, - aliases: FxHashMap::default(), + aliases: Default::default(), }; // Cache where all our extern crates are located diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index c1274e740590b..5054f18b020f6 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -124,6 +124,7 @@ impl StableFilemapId { // SourceMap // +#[derive(Default)] pub(super) struct SourceMapFiles { pub(super) file_maps: Vec>, stable_id_to_source_file: FxHashMap> @@ -143,10 +144,7 @@ pub struct SourceMap { impl SourceMap { pub fn new(path_mapping: FilePathMapping) -> SourceMap { SourceMap { - files: Lock::new(SourceMapFiles { - file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap::default(), - }), + files: Default::default(), file_loader: Box::new(RealFileLoader), path_mapping, doctest_offset: None, @@ -166,10 +164,7 @@ impl SourceMap { path_mapping: FilePathMapping) -> SourceMap { SourceMap { - files: Lock::new(SourceMapFiles { - file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap::default(), - }), + files: Default::default(), file_loader: file_loader, path_mapping, doctest_offset: None, diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index d412412fc655e..361353c82e25c 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -224,6 +224,7 @@ impl> PartialEq for Symbol { } // The &'static strs in this type actually point into the arena +#[derive(Default)] pub struct Interner { arena: DroplessArena, names: FxHashMap<&'static str, Symbol>, @@ -232,17 +233,8 @@ pub struct Interner { } impl Interner { - pub fn new() -> Self { - Interner { - arena: DroplessArena::new(), - names: Default::default(), - strings: Default::default(), - gensyms: Default::default(), - } - } - fn prefill(init: &[&str]) -> Self { - let mut this = Interner::new(); + let mut this = Interner::default(); for &string in init { if string == "" { // We can't allocate empty strings in the arena, so handle this here @@ -697,7 +689,7 @@ mod tests { #[test] fn interner_tests() { - let mut i: Interner = Interner::new(); + let mut i: Interner = Interner::default(); // first one is zero: assert_eq!(i.intern("dog"), Symbol(0)); // re-use gets the same entry: From 5075174c465ee868937517aba69ff5df5878a69d Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 17:19:25 +0200 Subject: [PATCH 3/9] Derives often have very strict bounds --- src/bootstrap/cache.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index 4a50f744e7a54..fd9a1be207280 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -169,12 +169,20 @@ impl Ord for Interned { } } -#[derive(Default)] struct TyIntern { items: Vec, set: HashMap>, } +impl Default for TyIntern { + fn default() -> Self { + TyIntern { + items: Vec::new(), + set: Default::default(), + } + } +} + impl TyIntern { fn intern_borrow(&mut self, item: &B) -> Interned where From 36641ce8cde4b2a402cd50137521e8bb18476728 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 17:21:55 +0200 Subject: [PATCH 4/9] Remove unused box --- src/librustc/middle/dead.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index cd85d5e361440..dc5f736172503 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -50,8 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> { worklist: Vec, tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &'a ty::TypeckTables<'tcx>, - // TODO: remove this `Box` - live_symbols: Box>, + live_symbols: FxHashSet, repr_has_repr_c: bool, in_pat: bool, inherited_pub_visibility: bool, @@ -424,13 +423,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &privacy::AccessLevels, krate: &hir::Crate) - -> Box> { + -> FxHashSet { let worklist = create_and_seed_worklist(tcx, access_levels, krate); let mut symbol_visitor = MarkSymbolVisitor { worklist, tcx, tables: &ty::TypeckTables::empty(None), - live_symbols: box Default::default(), + live_symbols: Default::default(), repr_has_repr_c: false, in_pat: false, inherited_pub_visibility: false, @@ -451,7 +450,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option { struct DeadVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, - live_symbols: Box>, + live_symbols: FxHashSet, } impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { From 55f76628ee053f8e331c1898f20aaefe4dd9bc7f Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 19:51:12 +0200 Subject: [PATCH 5/9] Update a compiler-test to the `Default` changes --- src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs b/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs index 48f5418879679..9fa0b40d49c20 100644 --- a/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs +++ b/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs @@ -46,6 +46,6 @@ impl<'a> HasId for &'a usize { fn count(&self) -> usize { 1 } } fn f<'a, 'b>(_arena: &'a TypedArena>) {} fn main() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); f(&arena); } From ab3f37ec43b0ca842baf5d79416eb0f86195cda6 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 19:59:44 +0200 Subject: [PATCH 6/9] Free some memory instead of just dropping elements --- src/librustc/traits/select.rs | 6 ++++-- src/librustc_errors/lib.rs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 95683e0613e15..39c623de677d3 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -3789,14 +3789,16 @@ impl<'tcx> TraitObligation<'tcx> { } impl<'tcx> SelectionCache<'tcx> { + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - self.hashmap.borrow_mut().clear(); + *self.hashmap.borrow_mut() = Default::default(); } } impl<'tcx> EvaluationCache<'tcx> { + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - self.hashmap.borrow_mut().clear(); + *self.hashmap.borrow_mut() = Default::default(); } } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index f02a5e2bc5d3a..9bd95e8262fc6 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -398,7 +398,8 @@ impl Handler { /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. pub fn reset_err_count(&self) { - self.emitted_diagnostics.borrow_mut().clear(); + // actually frees the underlying memory (which `clear` would not do) + *self.emitted_diagnostics.borrow_mut() = Default::default(); self.err_count.store(0, SeqCst); } From 54eb222c40321af6ec2d8dcc961366b1f68302a9 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 16 Oct 2018 22:06:19 +0200 Subject: [PATCH 7/9] Update more internals tests to `default` --- src/test/run-pass-fulldeps/regions-mock-tcx.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass-fulldeps/regions-mock-tcx.rs b/src/test/run-pass-fulldeps/regions-mock-tcx.rs index 013c331d0fd32..70c19df9788b2 100644 --- a/src/test/run-pass-fulldeps/regions-mock-tcx.rs +++ b/src/test/run-pass-fulldeps/regions-mock-tcx.rs @@ -133,8 +133,8 @@ fn compute_types<'tcx,'ast>(tcx: &mut TypeContext<'tcx,'ast>, } pub fn main() { - let ty_arena = TypedArena::new(); - let ast_arena = TypedArena::new(); + let ty_arena = TypedArena::default(); + let ast_arena = TypedArena::default(); let mut tcx = TypeContext::new(&ty_arena, &ast_arena); let ast = tcx.ast(ExprInt); let ty = compute_types(&mut tcx, ast); From bf3d40aa7e6a1d95536a406b3fd4743a26cdc758 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 17 Oct 2018 09:11:55 +0200 Subject: [PATCH 8/9] Update TypedArena tests --- src/libarena/lib.rs | 22 +++++++++---------- .../dropck_tarena_cycle_checked.rs | 2 +- .../dropck_tarena_unsound_drop.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index a7b34b6dc40af..dae05a368fa06 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -500,7 +500,7 @@ mod tests { #[test] pub fn test_unused() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); assert!(arena.chunks.borrow().is_empty()); } @@ -538,7 +538,7 @@ mod tests { } } - let arena = Wrap(TypedArena::new()); + let arena = Wrap(TypedArena::default()); let result = arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }), @@ -549,7 +549,7 @@ mod tests { #[test] pub fn test_copy() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(Point { x: 1, y: 2, z: 3 }); } @@ -557,7 +557,7 @@ mod tests { #[bench] pub fn bench_copy(b: &mut Bencher) { - let arena = TypedArena::new(); + let arena = TypedArena::default(); b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 })) } @@ -576,7 +576,7 @@ mod tests { #[test] pub fn test_noncopy() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(Noncopy { string: "hello world".to_string(), @@ -587,7 +587,7 @@ mod tests { #[test] pub fn test_typed_arena_zero_sized() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(()); } @@ -595,7 +595,7 @@ mod tests { #[test] pub fn test_typed_arena_clear() { - let mut arena = TypedArena::new(); + let mut arena = TypedArena::default(); for _ in 0..10 { arena.clear(); for _ in 0..10000 { @@ -620,7 +620,7 @@ mod tests { fn test_typed_arena_drop_count() { let counter = Cell::new(0); { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. arena.alloc(DropCounter { count: &counter }); @@ -632,7 +632,7 @@ mod tests { #[test] fn test_typed_arena_drop_on_clear() { let counter = Cell::new(0); - let mut arena: TypedArena = TypedArena::new(); + let mut arena: TypedArena = TypedArena::default(); for i in 0..10 { for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. @@ -659,7 +659,7 @@ mod tests { fn test_typed_arena_drop_small_count() { DROP_COUNTER.with(|c| c.set(0)); { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. arena.alloc(SmallDroppable); @@ -671,7 +671,7 @@ mod tests { #[bench] pub fn bench_noncopy(b: &mut Bencher) { - let arena = TypedArena::new(); + let arena = TypedArena::default(); b.iter(|| { arena.alloc(Noncopy { string: "hello world".to_string(), diff --git a/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs b/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs index f368788af55de..5ab6b99eb62f9 100644 --- a/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs +++ b/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs @@ -122,6 +122,6 @@ fn f<'a>(arena: &'a TypedArena>) { } fn main() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); f(&arena); } //~^ ERROR `arena` does not live long enough diff --git a/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs b/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs index 531e1ada44b3f..e2231b0814f3a 100644 --- a/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs +++ b/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs @@ -47,7 +47,7 @@ impl<'a> HasId for &'a usize { fn count(&self) -> usize { 1 } } fn f<'a>(_arena: &'a TypedArena>) {} fn main() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); f(&arena); } //~^ ERROR `arena` does not live long enough From 53e92f4573f30e52a0ea241fb76c6f1ffaabff90 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 17 Oct 2018 13:51:47 +0200 Subject: [PATCH 9/9] Update unit tests --- .../snapshot_map/test.rs | 6 ++-- .../transitive_relation.rs | 32 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/librustc_data_structures/snapshot_map/test.rs b/src/librustc_data_structures/snapshot_map/test.rs index b163e0fe420ec..700f9c95e3b57 100644 --- a/src/librustc_data_structures/snapshot_map/test.rs +++ b/src/librustc_data_structures/snapshot_map/test.rs @@ -12,7 +12,7 @@ use super::SnapshotMap; #[test] fn basic() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot = map.snapshot(); map.insert(22, "thirty-three"); @@ -29,7 +29,7 @@ fn basic() { #[test] #[should_panic] fn out_of_order() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot1 = map.snapshot(); let _snapshot2 = map.snapshot(); @@ -38,7 +38,7 @@ fn out_of_order() { #[test] fn nested_commit_then_rollback() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot1 = map.snapshot(); let snapshot2 = map.snapshot(); diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 3cc467aa038c4..e1318eb54d581 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -489,7 +489,7 @@ impl HashStable for Index { #[test] fn test_one_step() { - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "b"); relation.add("a", "c"); assert!(relation.contains(&"a", &"c")); @@ -500,7 +500,7 @@ fn test_one_step() { #[test] fn test_many_steps() { - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "b"); relation.add("a", "c"); relation.add("a", "f"); @@ -530,7 +530,7 @@ fn mubs_triangle() { // ^ // | // b - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "tcx"); relation.add("b", "tcx"); assert_eq!(relation.minimal_upper_bounds(&"a", &"b"), vec![&"tcx"]); @@ -551,7 +551,7 @@ fn mubs_best_choice1() { // need the second pare down call to get the right result (after // intersection, we have [1, 2], but 2 -> 1). - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -578,7 +578,7 @@ fn mubs_best_choice2() { // Like the precedecing test, but in this case intersection is [2, // 1], and hence we rely on the first pare down call. - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -597,7 +597,7 @@ fn mubs_best_choice2() { fn mubs_no_best_choice() { // in this case, the intersection yields [1, 2], and the "pare // down" calls find nothing to remove. - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -614,7 +614,7 @@ fn mubs_best_choice_scc() { // in this case, 1 and 2 form a cycle; we pick arbitrarily (but // consistently). - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -636,7 +636,7 @@ fn pdub_crisscross() { // /\ | // b -> b1 ---+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("a", "b1"); relation.add("b", "a1"); @@ -659,7 +659,7 @@ fn pdub_crisscross_more() { // /\ /\ | // b -> b1 -> b2 ---------+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("a", "b1"); relation.add("b", "a1"); @@ -692,7 +692,7 @@ fn pdub_lub() { // | // b -> b1 ---+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("b", "b1"); relation.add("a1", "x"); @@ -715,7 +715,7 @@ fn mubs_intermediate_node_on_one_side_only() { // b // "digraph { a -> c -> d; b -> d; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("b", "d"); @@ -734,7 +734,7 @@ fn mubs_scc_1() { // b // "digraph { a -> c -> d; d -> c; a -> d; b -> d; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "c"); @@ -754,7 +754,7 @@ fn mubs_scc_2() { // +--- b // "digraph { a -> c -> d; d -> c; b -> d; b -> c; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "c"); @@ -774,7 +774,7 @@ fn mubs_scc_3() { // b ---+ // "digraph { a -> c -> d -> e -> c; b -> d; b -> e; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "e"); @@ -796,7 +796,7 @@ fn mubs_scc_4() { // b ---+ // "digraph { a -> c -> d -> e -> c; a -> d; b -> e; }" - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "e"); @@ -834,7 +834,7 @@ fn parent() { (1, /*->*/ 3), ]; - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); for (a, b) in pairs { relation.add(a, b); }