summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-20 08:45:55 +0000
committerbors <bors@rust-lang.org>2018-10-20 08:45:55 +0000
commit94273f4d8e463cac45486328294bb1c2bbc10170 (patch)
treede04f7e054e20b25d6b095ea417a42e22720a6f9 /src
parent89be71a46234a2231b5b3839cd497188e072291f (diff)
parent53e92f4573f30e52a0ea241fb76c6f1ffaabff90 (diff)
downloadrust-94273f4d8e463cac45486328294bb1c2bbc10170.tar.gz
Auto merge of #55114 - oli-obk:fx#map, r=nikomatsakis
Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hack
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/cache.rs20
-rw-r--r--src/libarena/lib.rs54
-rw-r--r--src/librustc/dep_graph/cgu_reuse_tracker.rs4
-rw-r--r--src/librustc/dep_graph/dep_tracking_map.rs2
-rw-r--r--src/librustc/dep_graph/graph.rs10
-rw-r--r--src/librustc/dep_graph/prev.rs2
-rw-r--r--src/librustc/dep_graph/query.rs2
-rw-r--r--src/librustc/dep_graph/serialized.rs12
-rw-r--r--src/librustc/hir/map/definitions.rs8
-rw-r--r--src/librustc/hir/map/hir_id_validator.rs2
-rw-r--r--src/librustc/ich/hcx.rs2
-rw-r--r--src/librustc/ich/impls_ty.rs2
-rw-r--r--src/librustc/infer/freshen.rs2
-rw-r--r--src/librustc/infer/higher_ranked/mod.rs2
-rw-r--r--src/librustc/infer/lexical_region_resolve/graphviz.rs4
-rw-r--r--src/librustc/infer/lexical_region_resolve/mod.rs2
-rw-r--r--src/librustc/infer/mod.rs10
-rw-r--r--src/librustc/infer/outlives/env.rs4
-rw-r--r--src/librustc/infer/outlives/free_region_map.rs6
-rw-r--r--src/librustc/infer/region_constraints/mod.rs4
-rw-r--r--src/librustc/infer/region_constraints/taint.rs2
-rw-r--r--src/librustc/lint/context.rs6
-rw-r--r--src/librustc/lint/levels.rs6
-rw-r--r--src/librustc/middle/dead.rs10
-rw-r--r--src/librustc/middle/dependency_format.rs4
-rw-r--r--src/librustc/middle/lang_items.rs2
-rw-r--r--src/librustc/middle/lib_features.rs4
-rw-r--r--src/librustc/middle/reachable.rs2
-rw-r--r--src/librustc/middle/region.rs4
-rw-r--r--src/librustc/middle/resolve_lifetime.rs20
-rw-r--r--src/librustc/middle/stability.rs12
-rw-r--r--src/librustc/mir/interpret/mod.rs4
-rw-r--r--src/librustc/mir/mono.rs4
-rw-r--r--src/librustc/session/code_stats.rs4
-rw-r--r--src/librustc/session/mod.rs6
-rw-r--r--src/librustc/traits/auto_trait.rs8
-rw-r--r--src/librustc/traits/error_reporting.rs4
-rw-r--r--src/librustc/traits/mod.rs2
-rw-r--r--src/librustc/traits/project.rs7
-rw-r--r--src/librustc/traits/select.rs24
-rw-r--r--src/librustc/traits/specialize/mod.rs22
-rw-r--r--src/librustc/traits/util.rs2
-rw-r--r--src/librustc/ty/context.rs40
-rw-r--r--src/librustc/ty/fold.rs2
-rw-r--r--src/librustc/ty/inhabitedness/mod.rs4
-rw-r--r--src/librustc/ty/mod.rs3
-rw-r--r--src/librustc/ty/query/on_disk_cache.rs30
-rw-r--r--src/librustc/ty/query/plumbing.rs10
-rw-r--r--src/librustc/ty/util.rs2
-rw-r--r--src/librustc/util/nodemap.rs4
-rw-r--r--src/librustc/util/ppaux.rs2
-rw-r--r--src/librustc_borrowck/borrowck/mod.rs6
-rw-r--r--src/librustc_borrowck/borrowck/unused.rs2
-rw-r--r--src/librustc_borrowck/dataflow.rs2
-rw-r--r--src/librustc_codegen_llvm/attributes.rs2
-rw-r--r--src/librustc_codegen_llvm/back/link.rs2
-rw-r--r--src/librustc_codegen_llvm/back/lto.rs14
-rw-r--r--src/librustc_codegen_llvm/back/write.rs2
-rw-r--r--src/librustc_codegen_llvm/base.rs18
-rw-r--r--src/librustc_codegen_llvm/context.rs18
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs10
-rw-r--r--src/librustc_codegen_llvm/debuginfo/mod.rs8
-rw-r--r--src/librustc_codegen_utils/codegen_backend.rs4
-rw-r--r--src/librustc_data_structures/fx.rs15
-rw-r--r--src/librustc_data_structures/obligation_forest/mod.rs8
-rw-r--r--src/librustc_data_structures/snapshot_map/mod.rs10
-rw-r--r--src/librustc_data_structures/snapshot_map/test.rs6
-rw-r--r--src/librustc_data_structures/sync.rs4
-rw-r--r--src/librustc_data_structures/transitive_relation.rs42
-rw-r--r--src/librustc_errors/lib.rs9
-rw-r--r--src/librustc_incremental/assert_dep_graph.rs2
-rw-r--r--src/librustc_incremental/persist/dirty_clean.rs2
-rw-r--r--src/librustc_incremental/persist/fs.rs12
-rw-r--r--src/librustc_incremental/persist/load.rs8
-rw-r--r--src/librustc_incremental/persist/save.rs2
-rw-r--r--src/librustc_lint/types.rs2
-rw-r--r--src/librustc_metadata/creader.rs6
-rw-r--r--src/librustc_metadata/cstore.rs2
-rw-r--r--src/librustc_metadata/encoder.rs2
-rw-r--r--src/librustc_metadata/locator.rs10
-rw-r--r--src/librustc_metadata/native_libs.rs2
-rw-r--r--src/librustc_mir/borrow_check/borrow_set.rs10
-rw-r--r--src/librustc_mir/borrow_check/error_reporting.rs2
-rw-r--r--src/librustc_mir/borrow_check/mod.rs8
-rw-r--r--src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs2
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs4
-rw-r--r--src/librustc_mir/build/matches/mod.rs2
-rw-r--r--src/librustc_mir/build/matches/test.rs2
-rw-r--r--src/librustc_mir/build/scope.rs2
-rw-r--r--src/librustc_mir/dataflow/impls/borrows.rs4
-rw-r--r--src/librustc_mir/dataflow/move_paths/builder.rs3
-rw-r--r--src/librustc_mir/hair/pattern/_match.rs2
-rw-r--r--src/librustc_mir/interpret/validity.rs2
-rw-r--r--src/librustc_mir/monomorphize/collector.rs4
-rw-r--r--src/librustc_mir/monomorphize/partitioning.rs14
-rw-r--r--src/librustc_mir/transform/check_unsafety.rs2
-rw-r--r--src/librustc_mir/transform/cleanup_post_borrowck.rs10
-rw-r--r--src/librustc_mir/transform/elaborate_drops.rs2
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs2
-rw-r--r--src/librustc_mir/util/pretty.rs2
-rw-r--r--src/librustc_passes/hir_stats.rs8
-rw-r--r--src/librustc_privacy/lib.rs2
-rw-r--r--src/librustc_resolve/lib.rs84
-rw-r--r--src/librustc_resolve/resolve_imports.rs2
-rw-r--r--src/librustc_save_analysis/dump_visitor.rs4
-rw-r--r--src/librustc_traits/dropck_outlives.rs6
-rw-r--r--src/librustc_traits/lowering/environment.rs4
-rw-r--r--src/librustc_typeck/check/_match.rs2
-rw-r--r--src/librustc_typeck/check/generator_interior.rs2
-rw-r--r--src/librustc_typeck/check/intrinsic.rs2
-rw-r--r--src/librustc_typeck/check/method/probe.rs8
-rw-r--r--src/librustc_typeck/check/method/suggest.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs4
-rw-r--r--src/librustc_typeck/check/wfcheck.rs5
-rw-r--r--src/librustc_typeck/collect.rs2
-rw-r--r--src/librustc_typeck/impl_wf_check.rs4
-rw-r--r--src/librustc_typeck/variance/mod.rs2
-rw-r--r--src/librustdoc/clean/auto_trait.rs18
-rw-r--r--src/librustdoc/clean/inline.rs2
-rw-r--r--src/librustdoc/clean/mod.rs17
-rw-r--r--src/librustdoc/core.rs6
-rw-r--r--src/librustdoc/html/render.rs30
-rw-r--r--src/librustdoc/visit_ast.rs4
-rw-r--r--src/librustdoc/visit_lib.rs2
-rw-r--r--src/libsyntax/feature_gate.rs2
-rw-r--r--src/libsyntax/source_map.rs11
-rw-r--r--src/libsyntax_pos/hygiene.rs2
-rw-r--r--src/libsyntax_pos/symbol.rs14
-rw-r--r--src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs2
-rw-r--r--src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs2
-rw-r--r--src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs2
-rw-r--r--src/test/run-pass-fulldeps/regions-mock-tcx.rs4
133 files changed, 428 insertions, 558 deletions
diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs
index bca5ff85ba2..fd9a1be2072 100644
--- a/src/bootstrap/cache.rs
+++ b/src/bootstrap/cache.rs
@@ -169,19 +169,21 @@ impl Ord for Interned<String> {
}
}
-struct TyIntern<T> {
+struct TyIntern<T: Hash + Clone + Eq> {
items: Vec<T>,
set: HashMap<T, Interned<T>>,
}
-impl<T: Hash + Clone + Eq> TyIntern<T> {
- fn new() -> TyIntern<T> {
+impl<T: Hash + Clone + Eq> Default for TyIntern<T> {
+ fn default() -> Self {
TyIntern {
items: Vec::new(),
- set: HashMap::new(),
+ set: Default::default(),
}
}
+}
+impl<T: Hash + Clone + Eq> TyIntern<T> {
fn intern_borrow<B>(&mut self, item: &B) -> Interned<T>
where
B: Eq + Hash + ToOwned<Owned=T> + ?Sized,
@@ -212,19 +214,13 @@ impl<T: Hash + Clone + Eq> TyIntern<T> {
}
}
+#[derive(Default)]
pub struct Interner {
strs: Mutex<TyIntern<String>>,
paths: Mutex<TyIntern<PathBuf>>,
}
impl Interner {
- fn new() -> Interner {
- Interner {
- strs: Mutex::new(TyIntern::new()),
- paths: Mutex::new(TyIntern::new()),
- }
- }
-
pub fn intern_str(&self, s: &str) -> Interned<String> {
self.strs.lock().unwrap().intern_borrow(s)
}
@@ -238,7 +234,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 b02ae75eff8..dae05a368fa 100644
--- a/src/libarena/lib.rs
+++ b/src/libarena/lib.rs
@@ -114,10 +114,9 @@ impl<T> TypedArenaChunk<T> {
const PAGE: usize = 4096;
-impl<T> TypedArena<T> {
+impl<T> Default for TypedArena<T> {
/// Creates a new `TypedArena`.
- #[inline]
- pub fn new() -> TypedArena<T> {
+ fn default() -> TypedArena<T> {
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<T> TypedArena<T> {
_own: PhantomData,
}
}
+}
+impl<T> TypedArena<T> {
/// 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<T: ?Sized>(&self, ptr: *const T) -> bool {
let ptr = ptr as *const u8 as *mut u8;
for chunk in &*self.chunks.borrow() {
@@ -419,19 +422,14 @@ impl DroplessArena {
}
}
+#[derive(Default)]
+// FIXME(@Zoxc): this type is entirely unused in rustc
pub struct SyncTypedArena<T> {
lock: MTLock<TypedArena<T>>,
}
impl<T> SyncTypedArena<T> {
#[inline(always)]
- pub fn new() -> SyncTypedArena<T> {
- 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
unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) }
@@ -452,19 +450,13 @@ impl<T> SyncTypedArena<T> {
}
}
+#[derive(Default)]
pub struct SyncDroplessArena {
lock: MTLock<DroplessArena>,
}
impl SyncDroplessArena {
#[inline(always)]
- pub fn new() -> SyncDroplessArena {
- SyncDroplessArena {
- lock: MTLock::new(DroplessArena::new())
- }
- }
-
- #[inline(always)]
pub fn in_arena<T: ?Sized>(&self, ptr: *const T) -> bool {
self.lock.lock().in_arena(ptr)
}
@@ -508,7 +500,7 @@ mod tests {
#[test]
pub fn test_unused() {
- let arena: TypedArena<Point> = TypedArena::new();
+ let arena: TypedArena<Point> = TypedArena::default();
assert!(arena.chunks.borrow().is_empty());
}
@@ -546,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 }),
@@ -557,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 });
}
@@ -565,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 }))
}
@@ -584,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(),
@@ -595,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(());
}
@@ -603,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 {
@@ -628,7 +620,7 @@ mod tests {
fn test_typed_arena_drop_count() {
let counter = Cell::new(0);
{
- let arena: TypedArena<DropCounter> = TypedArena::new();
+ let arena: TypedArena<DropCounter> = TypedArena::default();
for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak.
arena.alloc(DropCounter { count: &counter });
@@ -640,7 +632,7 @@ mod tests {
#[test]
fn test_typed_arena_drop_on_clear() {
let counter = Cell::new(0);
- let mut arena: TypedArena<DropCounter> = TypedArena::new();
+ let mut arena: TypedArena<DropCounter> = TypedArena::default();
for i in 0..10 {
for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak.
@@ -667,7 +659,7 @@ mod tests {
fn test_typed_arena_drop_small_count() {
DROP_COUNTER.with(|c| c.set(0));
{
- let arena: TypedArena<SmallDroppable> = TypedArena::new();
+ let arena: TypedArena<SmallDroppable> = TypedArena::default();
for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak.
arena.alloc(SmallDroppable);
@@ -679,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/librustc/dep_graph/cgu_reuse_tracker.rs b/src/librustc/dep_graph/cgu_reuse_tracker.rs
index 2a0891787f8..99fc020bbe4 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: 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 7e46c202a84..a674b5df639 100644
--- a/src/librustc/dep_graph/dep_tracking_map.rs
+++ b/src/librustc/dep_graph/dep_tracking_map.rs
@@ -36,7 +36,7 @@ impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
DepTrackingMap {
phantom: PhantomData,
graph,
- map: FxHashMap(),
+ map: Default::default(),
}
}
}
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs
index f5a46060759..ddc5676c74e 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(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()),
+ 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(),
+ 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(),
+ read_set: Default::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: 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 669a99019aa..ebc50f4afb8 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<DepNode, SerializedDepNodeIndex>,
diff --git a/src/librustc/dep_graph/query.rs b/src/librustc/dep_graph/query.rs
index ce0b5557a34..4aec2af887c 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/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs
index 4c896a33e59..0c6c224fa91 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<SerializedDepNodeIndex, DepNode>,
@@ -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 fa4bf1511b8..dd689154086 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: 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 d61b5313444..087efbd4a22 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: Default::default(),
errors: Vec::new(),
}
}
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 0694c0f05b0..1c7c1b854da 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -370,7 +370,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
// recursing every time.
thread_local! {
static CACHE: RefCell<FxHashMap<hygiene::Mark, u64>> =
- RefCell::new(FxHashMap());
+ 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 10e73fb636c..2a3d40c0e3f 100644
--- a/src/librustc/ich/impls_ty.rs
+++ b/src/librustc/ich/impls_ty.rs
@@ -32,7 +32,7 @@ for &'gcx ty::List<T>
hasher: &mut StableHasher<W>) {
thread_local! {
static CACHE: RefCell<FxHashMap<(usize, usize), Fingerprint>> =
- RefCell::new(FxHashMap());
+ RefCell::new(Default::default());
}
let hash = CACHE.with(|cache| {
diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs
index 969d260d97e..c7785d83171 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: Default::default(),
}
}
diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs
index ae1892caa74..d85a3e84f85 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 b55727d2c84..3b92d032bdc 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 caba8b514f7..8f28e9a320d 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: 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 fbd38ebd78c..f5513acecf9 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()),
+ 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 631ff58d3e3..726bb388252 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 e19ecfd427b..588a00eb503 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 df30ad36006..96278e5140c 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: Default::default(),
+ glbs: Default::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 4f513cd5d48..ef7365276f6 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 852af2cdaa2..7e2532bb1c4 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: 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 950754a07ab..475ca8da6b9 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: Default::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 ea90922b110..dc5f7361725 100644
--- a/src/librustc/middle/dead.rs
+++ b/src/librustc/middle/dead.rs
@@ -50,7 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
worklist: Vec<ast::NodeId>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
- live_symbols: Box<FxHashSet<ast::NodeId>>,
+ live_symbols: FxHashSet<ast::NodeId>,
repr_has_repr_c: bool,
in_pat: bool,
inherited_pub_visibility: bool,
@@ -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
@@ -423,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<ast::NodeId>> {
+ -> FxHashSet<ast::NodeId> {
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 FxHashSet(),
+ live_symbols: Default::default(),
repr_has_repr_c: false,
in_pat: false,
inherited_pub_visibility: false,
@@ -450,7 +450,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> {
struct DeadVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
- live_symbols: Box<FxHashSet<ast::NodeId>>,
+ live_symbols: FxHashSet<ast::NodeId>,
}
impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs
index 95fb35165e7..8b5c6d147d7 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 c5d028c1735..45de958e72e 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 6055a05158f..7d65d412e01 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: Default::default(),
+ unstable: Default::default(),
}
}
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 55e5663f030..8c3a3fb6dc1 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 a90f03f536a..d00fbdeca21 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: 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 b22ea3dceb3..98e80d333c1 100644
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -218,6 +218,7 @@ struct NamedRegionMap {
}
/// See `NamedRegionMap`.
+#[derive(Default)]
pub struct ResolveLifetimes {
defs: FxHashMap<LocalDefId, Lrc<FxHashMap<ItemLocalId, Region>>>,
late_bound: FxHashMap<LocalDefId, Lrc<FxHashSet<ItemLocalId>>>,
@@ -394,11 +395,7 @@ fn resolve_lifetimes<'tcx>(
let named_region_map = krate(tcx);
- let mut rl = ResolveLifetimes {
- defs: FxHashMap(),
- late_bound: FxHashMap(),
- object_lifetime_defaults: FxHashMap(),
- };
+ let mut rl = ResolveLifetimes::default();
for (k, v) in named_region_map.defs {
let hir_id = tcx.hir.node_to_hir_id(k);
@@ -711,7 +708,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 {
@@ -2084,7 +2081,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
map: self.map,
outer_index: ty::INNERMOST,
have_bound_regions: false,
- lifetimes: FxHashSet(),
+ lifetimes: Default::default(),
};
gather.visit_ty(input);
@@ -2614,15 +2611,13 @@ fn insert_late_bound_lifetimes(
decl, generics
);
- let mut constrained_by_input = ConstrainedCollector {
- regions: FxHashSet(),
- };
+ 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(),
+ regions: Default::default(),
};
intravisit::walk_fn_ret_ty(&mut appears_in_output, &decl.output);
@@ -2636,7 +2631,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: Default::default(),
};
appears_in_where_clause.visit_generics(generics);
@@ -2693,6 +2688,7 @@ fn insert_late_bound_lifetimes(
return;
+ #[derive(Default)]
struct ConstrainedCollector {
regions: FxHashSet<hir::LifetimeName>,
}
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index 9dd13dd2272..ba79cf66d08 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: Default::default(),
+ depr_map: Default::default(),
+ active_features: Default::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 5eee0fba5fb..8c8073080aa 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: 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 7520695a7cd..ff2bf3d7807 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: 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(),
+ cache: Default::default(),
}
}
diff --git a/src/librustc/session/code_stats.rs b/src/librustc/session/code_stats.rs
index 32865acb298..b1dcfdfcda0 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<VariantInfo>,
}
-#[derive(PartialEq, Eq, Debug)]
+#[derive(PartialEq, Eq, Debug, Default)]
pub struct CodeStats {
type_sizes: FxHashSet<TypeSizeInfo>,
}
impl CodeStats {
- pub fn new() -> Self { CodeStats { type_sizes: FxHashSet() } }
-
pub fn record_type_size<S: ToString>(&mut self,
kind: DataTypeKind,
type_desc: S,
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 2b90a27b6a8..a17825a877d 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: 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(),
+ driver_lint_caps: Default::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 1e5ce15914d..06d548909b5 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<ty::RegionVid, ty::Region<'cx>> {
- let mut vid_map: FxHashMap<RegionTarget<'cx>, RegionDeps<'cx>> = FxHashMap();
- let mut finished_map = FxHashMap();
+ let mut vid_map: FxHashMap<RegionTarget<'cx>, 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 db775beae4f..28c59d65bec 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: Default::default()
});
let cleaned_pred = super::project::normalize(
diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs
index d129cd486cf..8bceebb2395 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 7c1f87fbf3f..b29ee8f7cdc 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<ProjectionCacheKey<'tcx>, 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 156a27a7d0a..39c623de677 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<ty::TraitRef<'tcx>, WithDepNode<SelectionResult<'tcx, SelectionCandidate<'tcx>>>>,
@@ -444,7 +444,7 @@ impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
}
}
-#[derive(Clone)]
+#[derive(Clone, Default)]
pub struct EvaluationCache<'tcx> {
hashmap: Lock<FxHashMap<ty::PolyTraitRef<'tcx>, WithDepNode<EvaluationResult>>>,
}
@@ -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()
@@ -3789,26 +3789,16 @@ impl<'tcx> TraitObligation<'tcx> {
}
impl<'tcx> SelectionCache<'tcx> {
- pub fn new() -> SelectionCache<'tcx> {
- SelectionCache {
- hashmap: Lock::new(FxHashMap()),
- }
- }
-
+ /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
pub fn clear(&self) {
- *self.hashmap.borrow_mut() = FxHashMap()
+ *self.hashmap.borrow_mut() = Default::default();
}
}
impl<'tcx> EvaluationCache<'tcx> {
- pub fn new() -> EvaluationCache<'tcx> {
- EvaluationCache {
- hashmap: Lock::new(FxHashMap()),
- }
- }
-
+ /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
pub fn clear(&self) {
- *self.hashmap.borrow_mut() = FxHashMap()
+ *self.hashmap.borrow_mut() = Default::default();
}
}
diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs
index 2c713c0f7f1..0ce1d8f8227 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()
- }
- }
-
- pub fn check(&self, a: DefId, b: DefId) -> Option<bool> {
- 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 7c273fb14db..0b7526dd784 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: 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 1bccd05af83..64f87d077ba 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<LayoutDetails>,
@@ -111,21 +112,6 @@ pub struct GlobalArenas<'tcx> {
const_allocs: TypedArena<interpret::Allocation>,
}
-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<FxHashSet<Interned<'tcx, T>>>;
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(),
+ 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(),
+ free_region_map: Default::default(),
+ concrete_existential_types: Default::default(),
}
}
@@ -1190,7 +1176,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
None
};
- let mut trait_map: FxHashMap<_, Lrc<FxHashMap<_, _>>> = FxHashMap();
+ let mut trait_map: FxHashMap<_, Lrc<FxHashMap<_, _>>> = 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 +1217,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
extern_providers,
on_disk_query_result_cache,
),
- rcache: Lock::new(FxHashMap()),
- 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()),
- stability_interner: Lock::new(FxHashSet()),
- allocation_interner: Lock::new(FxHashSet()),
+ 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 f54dcfa37e9..80dfd263af9 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: Default::default(),
just_constrained,
}
}
diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs
index ef5b2236200..56fe479ffc5 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 45a70be5842..760114a5838 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -1841,8 +1841,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for AdtDef {
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
thread_local! {
- static CACHE: RefCell<FxHashMap<usize, Fingerprint>> =
- RefCell::new(FxHashMap());
+ static CACHE: RefCell<FxHashMap<usize, Fingerprint>> = 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 ce580c78033..62bdf40317d 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: Default::default(),
prev_cnums: footer.prev_cnums,
cnum_map: Once::new(),
source_map: sess.source_map(),
- current_diagnostics: Lock::new(FxHashMap()),
+ 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()),
+ 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(),
- file_index_to_file: Lock::new(FxHashMap()),
+ 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()),
- query_result_index: FxHashMap(),
- prev_diagnostics_index: FxHashMap(),
- synthetic_expansion_infos: Lock::new(FxHashMap()),
+ 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()),
}
}
@@ -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: 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 f83f8bcf1a1..71e435fea77 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -55,11 +55,11 @@ impl<T> QueryValue<T> {
}
}
-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(),
- active: FxHashMap(),
+ 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/ty/util.rs b/src/librustc/ty/util.rs
index 5f63f11338a..00a1bfaacd7 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<Ty<'_>> = 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 0dc71af9db6..dbd3e00d9fd 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<T> = FxHashMap<$key, T>;
- pub fn $map_name<T>() -> $map_name<T> { FxHashMap() }
+ pub fn $map_name<T>() -> $map_name<T> { Default::default() }
pub type $set_name = FxHashSet<$key>;
- pub fn $set_name() -> $set_name { FxHashSet() }
+ pub fn $set_name() -> $set_name { Default::default() }
}
}
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index f3b5503b8d0..bfa2203cc04 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<T>)
where T: TypeFoldable<'tcx>
{
- let mut collector = LateBoundRegionNameCollector(FxHashSet());
+ 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 0ef0d284770..da5c5f47c08 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: 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()),
+ 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()),
+ 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 b1f89ce33fc..85794c5b10a 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<hir::Pat>]) {
let tcx = self.bccx.tcx;
- let mut mutables: FxHashMap<_, Vec<_>> = FxHashMap();
+ 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_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs
index 832b69cb2ac..1760fb138ea 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<hir::ItemLocalId, Vec<CFGIndex>> {
- 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 90ba103ca4c..a09a2b0fc4f 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::<FxHashMap<_, _>>();
- 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 9fac343b846..86c6a5e65b0 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 3ac22f4eaef..61856236a14 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<String, Vec<String>>,
}
impl ThinLTOImports {
- fn new() -> ThinLTOImports {
- ThinLTOImports {
- imports: FxHashMap(),
- }
- }
-
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(),
- };
+ 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/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 95281e2445a..81619c21975 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 c814ab4ab67..614a562846e 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();
+ 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(),
- native_libraries: FxHashMap(),
+ 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(),
+ 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(),
- wasm_imports: FxHashMap(),
- lang_item_to_crate: FxHashMap(),
- missing_lang_items: FxHashMap(),
+ 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 e6197423738..826df82193a 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: 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()),
- scalar_lltypes: RefCell::new(FxHashMap()),
- pointee_infos: RefCell::new(FxHashMap()),
+ 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()),
+ 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 f5e5287cd42..846d5056411 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(),
- unique_id_to_metadata: FxHashMap(),
- type_to_unique_id: FxHashMap(),
- }
- }
-
// 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 acb79d6f568..042e72e921e 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()),
- 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()),
+ composite_types_completed: Default::default(),
}
}
}
diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs
index d693e088360..046f0cccfee 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()) // 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/fx.rs b/src/librustc_data_structures/fx.rs
index 3bf3170d1df..bce21f5085c 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<K: Hash + Eq, V>() -> FxHashMap<K, V> {
- HashMap::default()
-}
-
-#[allow(non_snake_case)]
-pub fn FxHashSet<V: Hash + Eq>() -> FxHashSet<V> {
- HashSet::default()
-}
-
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 92cc398db50..ccf2a7f8159 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -187,11 +187,11 @@ impl<O: ForestObligation> ObligationForest<O> {
pub fn new() -> ObligationForest<O> {
ObligationForest {
nodes: vec![],
- done_cache: FxHashSet(),
- waiting_cache: FxHashMap(),
+ done_cache: Default::default(),
+ waiting_cache: Default::default(),
scratch: Some(vec![]),
obligation_tree_id_generator: (0..).map(|i| ObligationTreeId(i)),
- error_cache: FxHashMap(),
+ error_cache: Default::default(),
}
}
@@ -303,7 +303,7 @@ impl<O: ForestObligation> ObligationForest<O> {
self.error_cache
.entry(node.obligation_tree_id)
- .or_insert_with(|| FxHashSet())
+ .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 5030bf98dff..f8663cd4fd4 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<K, V> {
Noop,
}
-impl<K, V> SnapshotMap<K, V>
+impl<K, V> Default for SnapshotMap<K, V>
where K: Hash + Clone + Eq
{
- pub fn new() -> Self {
+ fn default() -> Self {
SnapshotMap {
- map: FxHashMap(),
+ map: FxHashMap::default(),
undo_log: vec![],
}
}
+}
+impl<K, V> SnapshotMap<K, V>
+ where K: Hash + Clone + Eq
+{
pub fn clear(&mut self) {
self.map.clear();
self.undo_log.clear();
diff --git a/src/librustc_data_structures/snapshot_map/test.rs b/src/librustc_data_structures/snapshot_map/test.rs
index b163e0fe420..700f9c95e3b 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/sync.rs b/src/librustc_data_structures/sync.rs
index a2893a60cb6..6a4012c8198 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>(T);
impl<T> MTLock<T> {
@@ -228,7 +228,7 @@ cfg_if! {
pub type MTRef<'a, T> = &'a T;
- #[derive(Debug)]
+ #[derive(Debug, Default)]
pub struct MTLock<T>(Lock<T>);
impl<T> MTLock<T> {
diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs
index 1512b30eead..e1318eb54d5 100644
--- a/src/librustc_data_structures/transitive_relation.rs
+++ b/src/librustc_data_structures/transitive_relation.rs
@@ -51,16 +51,18 @@ struct Edge {
target: Index,
}
-impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
- pub fn new() -> TransitiveRelation<T> {
+impl<T: Clone + Debug + Eq + Hash> Default for TransitiveRelation<T> {
+ fn default() -> TransitiveRelation<T> {
TransitiveRelation {
elements: vec![],
- map: FxHashMap(),
+ map: FxHashMap::default(),
edges: vec![],
closure: Lock::new(None),
}
}
+}
+impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
pub fn is_empty(&self) -> bool {
self.edges.is_empty()
}
@@ -95,7 +97,7 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
where F: FnMut(&T) -> Option<U>,
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])?);
}
@@ -487,7 +489,7 @@ impl<CTX> HashStable<CTX> 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"));
@@ -498,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");
@@ -528,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"]);
@@ -549,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");
@@ -576,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");
@@ -595,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");
@@ -612,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");
@@ -634,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");
@@ -657,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");
@@ -690,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");
@@ -713,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");
@@ -732,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");
@@ -752,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");
@@ -772,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");
@@ -794,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");
@@ -832,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);
}
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 12f1a43ed05..9bd95e8262f 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: Default::default(),
+ emitted_diagnostic_codes: Default::default(),
+ emitted_diagnostics: Default::default(),
}
}
@@ -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() = FxHashSet();
+ // actually frees the underlying memory (which `clear` would not do)
+ *self.emitted_diagnostics.borrow_mut() = Default::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 8e07e44513b..22a0cc983da 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 1b3819474c2..58a799bb45f 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: Default::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 ec25aef8080..dee50f5ab26 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<PathBuf>>(),
- 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 fbc3bf03599..2f7e1af1ff6 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()
},
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()
}
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: Default::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 06b0ea946d7..6279df4e580 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 a441f7a87f7..5197876f921 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 fa2debf2c0d..4b96735eb77 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 ec48a4a4c69..2be9883d03d 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: Default::default(),
metadata_loader,
}
}
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index c36ae02ab54..26f977c6b59 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 adff34af61e..e7e6dd71a76 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();
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 446ea6c3244..392644c793d 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 a316fc5ca10..ab44ebc052f 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: 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/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs
index baf9e032270..978b2b2eb86 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 a7b356c1461..6ef8b155458 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: Default::default(),
+ reservation_error_reported: Default::default(),
move_error_reported: BTreeMap::new(),
- uninitialized_error_reported: FxHashSet(),
+ uninitialized_error_reported: Default::default(),
errors_buffer,
nonlexical_regioncx: regioncx,
- used_mut: FxHashSet(),
+ used_mut: Default::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 d4adff7c443..1e6ba638e1c 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<Cause> {
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/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
index 35342b2129e..f8c839e4d3f 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 7737fcc765d..ed8ca9a637f 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: Default::default(),
type_tests: Vec::default(),
};
let mut placeholder_indices = PlaceholderIndices::default();
@@ -845,7 +845,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
region_bound_pairs,
implicit_region_bound,
borrowck_context,
- reported_errors: FxHashSet(),
+ reported_errors: Default::default(),
universal_region_relations,
}
}
diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs
index 99c0a52a8ee..a864b39e157 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 a8713286f18..c7da9c4fbd7 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: Default::default(),
}
}
}
diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs
index cc5b08f2a90..b3e62788256 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: Default::default(),
cached_unwind: CachedBlock::default(),
});
}
diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs
index caf87fdd5cc..f7043487c51 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 32b11870116..08696dc098e 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(),
+ 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 aa1c6902dce..04a297d0a83 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/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index c446980d049..d7b2f67a581 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 dd83d3157ba..6b60b5340ee 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 fd094ffc1cf..3a1108bb169 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<Item = MonoItem<'tcx>>
{
- 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<MonoItem<'tcx>, Vec<MonoItem<'tcx>>> = FxHashMap();
+ let mut accessor_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>> = 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 286de52bec5..ae881bad58d 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: 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 aaba7ab8418..4d3b422ab28 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<region::Scope>,
}
@@ -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()
- };
+ 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<Local>,
}
@@ -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(),
- };
+ 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 9d77289d7b9..e1165e865ce 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: Default::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 5e7050caeaf..78547abf9d9 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<FxHashSet<usize>> {
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 710ccb2053b..25bd02ff6dc 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<SourceScope, Vec<SourceScope>> = FxHashMap();
+ let mut scope_tree: FxHashMap<SourceScope, Vec<SourceScope>> = 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_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs
index b65a2e3f0e5..019fb9565f4 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 989851bb1b9..4b7bd786672 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 bf3fbdc2c5a..0f96ee6a688 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: Default::default(),
kind,
}
}
@@ -1053,11 +1053,11 @@ impl<'a> ModuleData<'a> {
parent,
kind,
normal_ancestor_id,
- resolutions: RefCell::new(FxHashMap()),
+ 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()),
+ 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<Name, PrimTy>,
}
impl PrimitiveTypeTable {
fn new() -> PrimitiveTypeTable {
- let mut table = PrimitiveTypeTable { primitive_types: FxHashMap() };
+ 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<ModuleData<'a>>,
local_modules: RefCell<Vec<Module<'a>>>,
@@ -1668,7 +1670,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 +1690,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 +1710,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 +1734,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,35 +1764,27 @@ 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,
}
}
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.
@@ -2381,7 +2375,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 +2643,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 +2651,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 +2676,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 +2741,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 +4137,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 +4162,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 +4176,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 +4229,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 +4374,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::<ast::PathSegment>::new(), not_local_module)];
@@ -4499,7 +4493,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 +4667,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 d5d772e1359..f04bbb962a3 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 ab8f4686729..d77a8bd2a52 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 ed61f07c4d8..2ad7ab7c4d9 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 3d1e7cf17a6..04290ca6b76 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 c9158af178f..0cc9924474c 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::<FxHashMap<_, _>>();
// 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 83005bc374e..b4ad9cfbc6d 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 d630c5b3040..da96d4f0cba 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 ae02cd64c38..f4538dbd25e 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<ast::Ident> {
- 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 2006796a100..2e0f6600a35 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<DefId>
});
// Cross-crate:
- let mut external_mods = FxHashSet();
+ let mut external_mods = FxHashSet::default();
fn handle_external_def(tcx: TyCtxt,
traits: &mut Vec<DefId>,
external_mods: &mut FxHashSet<DefId>,
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index ffa21e1fc22..5d9fbf72ce2 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3510,12 +3510,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 1b493f1c12b..ec773e384af 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<u32> }
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() };
+ 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)
@@ -606,7 +607,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 f96c85ae7ae..eb52a013b05 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<ast::Ident, Span> = FxHashMap();
+ let mut seen_fields: FxHashMap<ast::Ident, Span> = Default::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 7e0a8d63e28..edf3ddf7bdb 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/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs
index 25f6b259e96..7cc56bc192b 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<CrateVariancesMap> {
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 de5a680ccf9..26487605bac 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: 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();
+ let mut finished: FxHashMap<_, Vec<_>> = Default::default();
- let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = FxHashMap();
+ let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = 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
@@ -407,7 +407,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
) -> FxHashSet<GenericParamDef> {
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<Type, FxHashSet<Type>> = FxHashMap();
+ let mut has_sized = FxHashSet::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<Type, FxHashSet<Type>> = Default::default();
- let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = FxHashMap();
+ let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = 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 a435712ac3d..49cecd5b04b 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<clean::Item>) {
.into_iter()
.map(|meth| meth.ident.to_string())
.collect()
- }).unwrap_or(FxHashSet());
+ }).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 2ba1f103971..db605e57735 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<FxHashMap<CrateNum, DefId>> =
- RefCell::new(FxHashMap()));
+thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = Default::default());
const FN_OUTPUT_NAME: &'static str = "Output";
@@ -165,7 +164,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> Clean<Crate> 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 +1584,7 @@ impl<'a, 'tcx> Clean<Generics> 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 +2446,8 @@ impl Clean<Type> 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 +3387,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
.into_iter()
.map(|meth| meth.ident.to_string())
.collect()
- }).unwrap_or(FxHashSet());
+ }).unwrap_or_default();
ret.push(Item {
name: None,
@@ -3502,7 +3501,7 @@ impl Clean<Vec<Item>> 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 +3511,7 @@ impl Clean<Vec<Item>> 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 2e14c2552de..49f13df64d6 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: 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 23f1e15de3c..dda0f37c3f9 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: 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()),
+ 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(),
+ impls: Default::default(),
external_paths,
exact_paths,
- paths: FxHashMap(),
- implementors: FxHashMap(),
+ 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(),
- primitive_locations: FxHashMap(),
+ 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()),
+ 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()),
+ masked_crates: mem::replace(&mut krate.masked_crates, Default::default()),
typarams: external_typarams,
- aliases: FxHashMap(),
+ aliases: Default::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::<Json>::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<String, fmt::Error> {
out.push_str("<span class=\"where fmt-newline\"> ");
assoc_type(&mut out, it, &[],
Some(&tydef.type_),
- AssocItemLink::GotoSource(t_did, &FxHashSet()))?;
+ AssocItemLink::GotoSource(t_did, &FxHashSet::default()))?;
out.push_str(";</span>");
}
}
@@ -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<String> {
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 92d8dbed071..5d221d3006f 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 fd81f937f30..5d1f42c83f4 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 84122688c83..a110248439e 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 7ee58350621..5054f18b020 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<Lrc<SourceFile>>,
stable_id_to_source_file: FxHashMap<StableFilemapId, Lrc<SourceFile>>
@@ -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(),
- }),
+ 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(),
- }),
+ files: Default::default(),
file_loader: file_loader,
path_mapping,
doctest_offset: None,
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs
index f053cb10d06..bc52a3e1c7c 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::<Mark>();
+ let mut a_path = FxHashSet::<Mark>::default();
while a != Mark::root() {
a_path.insert(a);
a = data.marks[a.0 as usize].parent;
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index d412412fc65..361353c82e2 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -224,6 +224,7 @@ impl<T: ::std::ops::Deref<Target=str>> PartialEq<T> 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:
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 f368788af55..5ab6b99eb62 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<C<'a>>) {
}
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 531e1ada44b..e2231b0814f 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<C<'a>>) {}
fn main() {
- let arena: TypedArena<C> = TypedArena::new();
+ let arena: TypedArena<C> = TypedArena::default();
f(&arena);
} //~^ ERROR `arena` does not live long enough
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 48f54188796..9fa0b40d49c 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<C<'b>>) {}
fn main() {
- let arena: TypedArena<C> = TypedArena::new();
+ let arena: TypedArena<C> = TypedArena::default();
f(&arena);
}
diff --git a/src/test/run-pass-fulldeps/regions-mock-tcx.rs b/src/test/run-pass-fulldeps/regions-mock-tcx.rs
index 013c331d0fd..70c19df9788 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);