From 3121c040438fcc9a14d028a5aca4a6892f7bcdcc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 16 Jan 2015 14:27:43 -0800 Subject: [PATCH] Fix typedef/module name conflicts in the compiler --- src/librustc/lint/builtin.rs | 4 +- src/librustc/lint/context.rs | 8 +- src/librustc/metadata/cstore.rs | 4 +- src/librustc/metadata/encoder.rs | 4 +- src/librustc/middle/cfg/construct.rs | 2 +- src/librustc/middle/check_static.rs | 8 +- src/librustc/middle/const_eval.rs | 2 +- src/librustc/middle/dataflow.rs | 2 +- src/librustc/middle/dependency_format.rs | 2 +- .../middle/infer/region_inference/graphviz.rs | 4 +- .../middle/infer/region_inference/mod.rs | 12 +-- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/liveness.rs | 10 +- src/librustc/middle/pat_util.rs | 2 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 10 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/stability.rs | 4 +- src/librustc/middle/traits/fulfill.rs | 2 +- src/librustc/middle/ty.rs | 94 +++++++++---------- src/librustc/session/mod.rs | 2 +- src/librustc/util/nodemap.rs | 44 ++------- src/librustc_borrowck/borrowck/move_data.rs | 4 +- src/librustc_privacy/lib.rs | 8 +- src/librustc_resolve/lib.rs | 24 ++--- src/librustc_trans/trans/_match.rs | 2 +- src/librustc_trans/trans/base.rs | 4 +- src/librustc_trans/trans/builder.rs | 2 +- src/librustc_trans/trans/common.rs | 2 +- src/librustc_trans/trans/context.rs | 60 ++++++------ src/librustc_trans/trans/debuginfo.rs | 16 ++-- src/librustc_trans/trans/type_.rs | 2 +- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/mod.rs | 20 ++-- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/collect.rs | 4 +- src/librustc_typeck/variance.rs | 2 +- src/librustdoc/html/render.rs | 2 +- 39 files changed, 180 insertions(+), 204 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 59808b302f4..8a27cfc510f 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -575,7 +575,7 @@ pub struct RawPointerDerive { impl RawPointerDerive { pub fn new() -> RawPointerDerive { RawPointerDerive { - checked_raw_pointers: NodeSet::new(), + checked_raw_pointers: NodeSet(), } } } @@ -1323,7 +1323,7 @@ impl UnusedMut { // collect all mutable pattern and group their NodeIDs by their Identifier to // avoid false warnings in match arms with multiple patterns - let mut mutables = FnvHashMap::new(); + let mut mutables = FnvHashMap(); for p in pats.iter() { pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| { let ident = path1.node; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 95e1e8d44bf..de4efe09f27 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -98,9 +98,9 @@ impl LintStore { LintStore { lints: vec!(), passes: Some(vec!()), - by_name: FnvHashMap::new(), - levels: FnvHashMap::new(), - lint_groups: FnvHashMap::new(), + by_name: FnvHashMap(), + levels: FnvHashMap(), + lint_groups: FnvHashMap(), } } @@ -468,7 +468,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { exported_items: exported_items, lints: lint_store, level_stack: vec![], - node_levels: RefCell::new(FnvHashMap::new()), + node_levels: RefCell::new(FnvHashMap()), } } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 49e03376a8c..a928d1c9022 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -84,8 +84,8 @@ pub struct CStore { impl CStore { pub fn new(intr: Rc) -> CStore { CStore { - metas: RefCell::new(FnvHashMap::new()), - extern_mod_crate_map: RefCell::new(FnvHashMap::new()), + metas: RefCell::new(FnvHashMap()), + extern_mod_crate_map: RefCell::new(FnvHashMap()), used_crate_sources: RefCell::new(Vec::new()), used_libraries: RefCell::new(Vec::new()), used_link_args: RefCell::new(Vec::new()), diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index c8921f1b2fb..5cbe9750428 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -2111,7 +2111,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter, link_meta: link_meta, cstore: cstore, encode_inlined_item: RefCell::new(encode_inlined_item), - type_abbrevs: RefCell::new(FnvHashMap::new()), + type_abbrevs: RefCell::new(FnvHashMap()), reachable: reachable, }; @@ -2216,7 +2216,7 @@ pub fn encoded_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> String { diag: tcx.sess.diagnostic(), ds: def_to_string, tcx: tcx, - abbrevs: &RefCell::new(FnvHashMap::new()) + abbrevs: &RefCell::new(FnvHashMap()) }, t); String::from_utf8(wr.unwrap()).unwrap() } diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 07b520e5865..a1ac25a5650 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -46,7 +46,7 @@ pub fn construct(tcx: &ty::ctxt, let block_exit; let mut cfg_builder = CFGBuilder { - exit_map: NodeMap::new(), + exit_map: NodeMap(), graph: graph, fn_exit: fn_exit, tcx: tcx, diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index 026aa3c5ccf..9d3180864f2 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -64,10 +64,10 @@ struct GlobalChecker { pub fn check_crate(tcx: &ty::ctxt) { let mut checker = GlobalChecker { - static_consumptions: NodeSet::new(), - const_borrows: NodeSet::new(), - static_interior_borrows: NodeSet::new(), - static_local_borrows: NodeSet::new(), + static_consumptions: NodeSet(), + const_borrows: NodeSet(), + static_interior_borrows: NodeSet(), + static_local_borrows: NodeSet(), }; { let param_env = ty::empty_parameter_environment(tcx); diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index c998d178c22..05dd47f5a36 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -286,7 +286,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstEvalVisitor<'a, 'tcx> { pub fn process_crate(tcx: &ty::ctxt) { visit::walk_crate(&mut ConstEvalVisitor { tcx: tcx, - ccache: DefIdMap::new(), + ccache: DefIdMap(), }, tcx.map.krate()); tcx.sess.abort_if_errors(); } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 4ae0aa43406..2b9bd1cd09f 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -145,7 +145,7 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O fn build_nodeid_to_index(decl: Option<&ast::FnDecl>, cfg: &cfg::CFG) -> NodeMap { - let mut index = NodeMap::new(); + let mut index = NodeMap(); // FIXME (#6298): 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/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index cca0b7d9ad0..95e6edd6dfe 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -137,7 +137,7 @@ fn calculate_type(sess: &session::Session, config::CrateTypeExecutable | config::CrateTypeDylib => {}, } - let mut formats = FnvHashMap::new(); + let mut formats = FnvHashMap(); // 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/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index 0d6ab9c273b..f8f962cd86d 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> { name: String, map: &'a ConstraintMap<'tcx>) -> ConstraintGraph<'a, 'tcx> { let mut i = 0; - let mut node_ids = FnvHashMap::new(); + let mut node_ids = FnvHashMap(); { let mut add_node = |&mut : node| { if let Vacant(e) = node_ids.entry(node) { @@ -188,7 +188,7 @@ fn constraint_to_nodes(c: &Constraint) -> (Node, Node) { impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> { fn nodes(&self) -> dot::Nodes { - let mut set = FnvHashSet::new(); + let mut set = FnvHashSet(); for constraint in self.map.keys() { let (n1, n2) = constraint_to_nodes(constraint); set.insert(n1); diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index d54d0ae87ae..0f487fffe5c 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -236,11 +236,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { tcx: tcx, var_origins: RefCell::new(Vec::new()), values: RefCell::new(None), - constraints: RefCell::new(FnvHashMap::new()), + constraints: RefCell::new(FnvHashMap()), verifys: RefCell::new(Vec::new()), - givens: RefCell::new(FnvHashSet::new()), - lubs: RefCell::new(FnvHashMap::new()), - glbs: RefCell::new(FnvHashMap::new()), + givens: RefCell::new(FnvHashSet()), + lubs: RefCell::new(FnvHashMap()), + glbs: RefCell::new(FnvHashMap()), skolemization_count: Cell::new(0), bound_count: Cell::new(0), undo_log: RefCell::new(Vec::new()) @@ -1200,7 +1200,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { values: &Vec, errors: &mut Vec>) { - let mut reg_reg_dups = FnvHashSet::new(); + let mut reg_reg_dups = FnvHashSet(); for verify in self.verifys.borrow().iter() { match *verify { VerifyRegSubReg(ref origin, sub, sup) => { @@ -1476,7 +1476,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { dup_found: bool } let mut state = WalkState { - set: FnvHashSet::new(), + set: FnvHashSet(), stack: vec!(orig_node_idx), result: Vec::new(), dup_found: false diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 2f81d8c0f70..db6a4768857 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -167,7 +167,7 @@ impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> { impl<'a> LanguageItemCollector<'a> { pub fn new(session: &'a Session) -> LanguageItemCollector<'a> { - let mut item_refs = FnvHashMap::new(); + let mut item_refs = FnvHashMap(); $( item_refs.insert($name, $variant as uint); )* diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 6b9e5b2ceea..27a0324a3c4 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -277,9 +277,9 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { tcx: tcx, num_live_nodes: 0, num_vars: 0, - live_node_map: NodeMap::new(), - variable_map: NodeMap::new(), - capture_info_map: NodeMap::new(), + live_node_map: NodeMap(), + variable_map: NodeMap(), + capture_info_map: NodeMap(), var_kinds: Vec::new(), lnks: Vec::new(), } @@ -582,8 +582,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { successors: repeat(invalid_node()).take(num_live_nodes).collect(), users: repeat(invalid_users()).take(num_live_nodes * num_vars).collect(), loop_scope: Vec::new(), - break_ln: NodeMap::new(), - cont_ln: NodeMap::new(), + break_ln: NodeMap(), + cont_ln: NodeMap(), } } diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 0a6c29d1cb6..01dc55c3eee 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -21,7 +21,7 @@ pub type PatIdMap = FnvHashMap; // This is used because same-named variables in alternative patterns need to // use the NodeId of their namesake in the first pattern. pub fn pat_id_map(dm: &DefMap, pat: &ast::Pat) -> PatIdMap { - let mut map = FnvHashMap::new(); + let mut map = FnvHashMap(); pat_bindings(dm, pat, |_bm, p_id, _s, path1| { map.insert(path1.node, p_id); }); diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index b7e6da8c5f6..d6e652f16c6 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -169,7 +169,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { }); ReachableContext { tcx: tcx, - reachable_symbols: NodeSet::new(), + reachable_symbols: NodeSet(), worklist: Vec::new(), any_library: any_library, } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 8dcbc74f0eb..90ba442ee39 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -891,11 +891,11 @@ impl<'a, 'v> Visitor<'v> for RegionResolutionVisitor<'a> { pub fn resolve_crate(sess: &Session, krate: &ast::Crate) -> RegionMaps { let maps = RegionMaps { - scope_map: RefCell::new(FnvHashMap::new()), - var_map: RefCell::new(NodeMap::new()), - free_region_map: RefCell::new(FnvHashMap::new()), - rvalue_scopes: RefCell::new(NodeMap::new()), - terminating_scopes: RefCell::new(FnvHashSet::new()), + scope_map: RefCell::new(FnvHashMap()), + var_map: RefCell::new(NodeMap()), + free_region_map: RefCell::new(FnvHashMap()), + rvalue_scopes: RefCell::new(NodeMap()), + terminating_scopes: RefCell::new(FnvHashSet()), }; { let mut visitor = RegionResolutionVisitor { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index b670099ff96..eff0018becc 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -74,7 +74,7 @@ type Scope<'a> = &'a ScopeChain<'a>; static ROOT_SCOPE: ScopeChain<'static> = RootScope; pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegionMap { - let mut named_region_map = NodeMap::new(); + let mut named_region_map = NodeMap(); visit::walk_crate(&mut LifetimeContext { sess: sess, named_region_map: &mut named_region_map, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index e712f510d9d..1a00e175e0f 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -141,8 +141,8 @@ impl Index { pub fn build(krate: &Crate) -> Index { let mut annotator = Annotator { index: Index { - local: NodeMap::new(), - extern_cache: DefIdMap::new() + local: NodeMap(), + extern_cache: DefIdMap() }, parent: None }; diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index c3b9be85eb5..42624555ae4 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -96,7 +96,7 @@ impl<'tcx> FulfillmentContext<'tcx> { duplicate_set: HashSet::new(), predicates: Vec::new(), attempted_mark: 0, - region_obligations: NodeMap::new(), + region_obligations: NodeMap(), } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 34e4993c54d..be6c6b9d34f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2362,71 +2362,71 @@ pub fn mk_ctxt<'tcx>(s: Session, lang_items: middle::lang_items::LanguageItems, stability: stability::Index) -> ctxt<'tcx> { - let mut interner = FnvHashMap::new(); + let mut interner = FnvHashMap(); let common_types = CommonTypes::new(&arenas.type_, &mut interner); ctxt { arenas: arenas, interner: RefCell::new(interner), - substs_interner: RefCell::new(FnvHashMap::new()), - bare_fn_interner: RefCell::new(FnvHashMap::new()), - region_interner: RefCell::new(FnvHashMap::new()), + substs_interner: RefCell::new(FnvHashMap()), + bare_fn_interner: RefCell::new(FnvHashMap()), + region_interner: RefCell::new(FnvHashMap()), types: common_types, named_region_map: named_region_map, - item_variance_map: RefCell::new(DefIdMap::new()), + item_variance_map: RefCell::new(DefIdMap()), variance_computed: Cell::new(false), sess: s, def_map: dm, region_maps: region_maps, - node_types: RefCell::new(FnvHashMap::new()), - item_substs: RefCell::new(NodeMap::new()), - trait_refs: RefCell::new(NodeMap::new()), - trait_defs: RefCell::new(DefIdMap::new()), - object_cast_map: RefCell::new(NodeMap::new()), + node_types: RefCell::new(FnvHashMap()), + item_substs: RefCell::new(NodeMap()), + trait_refs: RefCell::new(NodeMap()), + trait_defs: RefCell::new(DefIdMap()), + object_cast_map: RefCell::new(NodeMap()), map: map, - intrinsic_defs: RefCell::new(DefIdMap::new()), + intrinsic_defs: RefCell::new(DefIdMap()), freevars: freevars, - tcache: RefCell::new(DefIdMap::new()), - rcache: RefCell::new(FnvHashMap::new()), - short_names_cache: RefCell::new(FnvHashMap::new()), - tc_cache: RefCell::new(FnvHashMap::new()), - ast_ty_to_ty_cache: RefCell::new(NodeMap::new()), - enum_var_cache: RefCell::new(DefIdMap::new()), - impl_or_trait_items: RefCell::new(DefIdMap::new()), - trait_item_def_ids: RefCell::new(DefIdMap::new()), - trait_items_cache: RefCell::new(DefIdMap::new()), - impl_trait_cache: RefCell::new(DefIdMap::new()), - ty_param_defs: RefCell::new(NodeMap::new()), - adjustments: RefCell::new(NodeMap::new()), - normalized_cache: RefCell::new(FnvHashMap::new()), + tcache: RefCell::new(DefIdMap()), + rcache: RefCell::new(FnvHashMap()), + short_names_cache: RefCell::new(FnvHashMap()), + tc_cache: RefCell::new(FnvHashMap()), + ast_ty_to_ty_cache: RefCell::new(NodeMap()), + enum_var_cache: RefCell::new(DefIdMap()), + impl_or_trait_items: RefCell::new(DefIdMap()), + trait_item_def_ids: RefCell::new(DefIdMap()), + trait_items_cache: RefCell::new(DefIdMap()), + impl_trait_cache: RefCell::new(DefIdMap()), + ty_param_defs: RefCell::new(NodeMap()), + adjustments: RefCell::new(NodeMap()), + normalized_cache: RefCell::new(FnvHashMap()), lang_items: lang_items, - provided_method_sources: RefCell::new(DefIdMap::new()), - struct_fields: RefCell::new(DefIdMap::new()), - destructor_for_type: RefCell::new(DefIdMap::new()), - destructors: RefCell::new(DefIdSet::new()), - trait_impls: RefCell::new(DefIdMap::new()), - inherent_impls: RefCell::new(DefIdMap::new()), - impl_items: RefCell::new(DefIdMap::new()), - used_unsafe: RefCell::new(NodeSet::new()), - used_mut_nodes: RefCell::new(NodeSet::new()), - populated_external_types: RefCell::new(DefIdSet::new()), - populated_external_traits: RefCell::new(DefIdSet::new()), - upvar_borrow_map: RefCell::new(FnvHashMap::new()), - extern_const_statics: RefCell::new(DefIdMap::new()), - extern_const_variants: RefCell::new(DefIdMap::new()), - method_map: RefCell::new(FnvHashMap::new()), - dependency_formats: RefCell::new(FnvHashMap::new()), - unboxed_closures: RefCell::new(DefIdMap::new()), - node_lint_levels: RefCell::new(FnvHashMap::new()), + provided_method_sources: RefCell::new(DefIdMap()), + struct_fields: RefCell::new(DefIdMap()), + destructor_for_type: RefCell::new(DefIdMap()), + destructors: RefCell::new(DefIdSet()), + trait_impls: RefCell::new(DefIdMap()), + inherent_impls: RefCell::new(DefIdMap()), + impl_items: RefCell::new(DefIdMap()), + used_unsafe: RefCell::new(NodeSet()), + used_mut_nodes: RefCell::new(NodeSet()), + populated_external_types: RefCell::new(DefIdSet()), + populated_external_traits: RefCell::new(DefIdSet()), + upvar_borrow_map: RefCell::new(FnvHashMap()), + extern_const_statics: RefCell::new(DefIdMap()), + extern_const_variants: RefCell::new(DefIdMap()), + method_map: RefCell::new(FnvHashMap()), + dependency_formats: RefCell::new(FnvHashMap()), + unboxed_closures: RefCell::new(DefIdMap()), + node_lint_levels: RefCell::new(FnvHashMap()), transmute_restrictions: RefCell::new(Vec::new()), stability: RefCell::new(stability), capture_modes: capture_modes, - associated_types: RefCell::new(DefIdMap::new()), + associated_types: RefCell::new(DefIdMap()), selection_cache: traits::SelectionCache::new(), - repr_hint_cache: RefCell::new(DefIdMap::new()), + repr_hint_cache: RefCell::new(DefIdMap()), type_impls_copy_cache: RefCell::new(HashMap::new()), type_impls_sized_cache: RefCell::new(HashMap::new()), - object_safety_cache: RefCell::new(DefIdMap::new()), + object_safety_cache: RefCell::new(DefIdMap()), } } @@ -3331,7 +3331,7 @@ pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool { pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents { return memoized(&cx.tc_cache, ty, |ty| { - tc_ty(cx, ty, &mut FnvHashMap::new()) + tc_ty(cx, ty, &mut FnvHashMap()) }); fn tc_ty<'tcx>(cx: &ctxt<'tcx>, @@ -6760,7 +6760,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>( { debug!("replace_late_bound_regions({})", binder.repr(tcx)); - let mut map = FnvHashMap::new(); + let mut map = FnvHashMap(); // Note: fold the field `0`, not the binder, so that late-bound // regions bound by `binder` are considered free. diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 8a7c7b38287..5424b1c8cae 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -346,7 +346,7 @@ pub fn build_session_(sopts: config::Options, local_crate_source_file: local_crate_source_file, working_dir: os::getcwd().unwrap(), lint_store: RefCell::new(lint::LintStore::new()), - lints: RefCell::new(NodeMap::new()), + lints: RefCell::new(NodeMap()), crate_types: RefCell::new(Vec::new()), crate_metadata: RefCell::new(Vec::new()), features: RefCell::new(feature_gate::Features::new()), diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 044534ae852..7aa126371c4 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -15,7 +15,7 @@ use std::collections::hash_state::{DefaultState}; use std::collections::{HashMap, HashSet}; use std::default::Default; -use std::hash::{Hasher, Writer}; +use std::hash::{Hasher, Writer, Hash}; use syntax::ast; pub type FnvHashMap = HashMap>; @@ -27,42 +27,18 @@ pub type DefIdMap = FnvHashMap; pub type NodeSet = FnvHashSet; pub type DefIdSet = FnvHashSet; -// Hacks to get good names -pub mod FnvHashMap { - use std::hash::Hash; - use std::default::Default; - pub fn new + Eq, V>() -> super::FnvHashMap { - Default::default() - } +pub fn FnvHashMap + Eq, V>() -> FnvHashMap { + Default::default() } -pub mod FnvHashSet { - use std::hash::Hash; - use std::default::Default; - pub fn new + Eq>() -> super::FnvHashSet { - Default::default() - } -} -pub mod NodeMap { - pub fn new() -> super::NodeMap { - super::FnvHashMap::new() - } -} -pub mod DefIdMap { - pub fn new() -> super::DefIdMap { - super::FnvHashMap::new() - } -} -pub mod NodeSet { - pub fn new() -> super::NodeSet { - super::FnvHashSet::new() - } -} -pub mod DefIdSet { - pub fn new() -> super::DefIdSet { - super::FnvHashSet::new() - } +pub fn FnvHashSet + Eq>() -> FnvHashSet { + Default::default() } +pub fn NodeMap() -> NodeMap { FnvHashMap() } +pub fn DefIdMap() -> DefIdMap { FnvHashMap() } +pub fn NodeSet() -> NodeSet { FnvHashSet() } +pub fn DefIdSet() -> DefIdSet { FnvHashSet() } + /// A speedy hash algorithm for node ids and def ids. The hashmap in /// libcollections by default uses SipHash which isn't quite as speedy as we /// want. In the compiler we're not really worried about DOS attempts, so we diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 21b3c910d32..9236a6bda59 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -209,12 +209,12 @@ impl<'tcx> MoveData<'tcx> { pub fn new() -> MoveData<'tcx> { MoveData { paths: RefCell::new(Vec::new()), - path_map: RefCell::new(FnvHashMap::new()), + path_map: RefCell::new(FnvHashMap()), moves: RefCell::new(Vec::new()), path_assignments: RefCell::new(Vec::new()), var_assignments: RefCell::new(Vec::new()), variant_matches: RefCell::new(Vec::new()), - assignee_ids: RefCell::new(NodeSet::new()), + assignee_ids: RefCell::new(NodeSet()), fragments: RefCell::new(fragments::FragmentSets::new()), } } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9b5913c659b..e12c195a3af 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1539,7 +1539,7 @@ pub fn check_crate(tcx: &ty::ctxt, // Figure out who everyone's parent is let mut visitor = ParentVisitor { - parents: NodeMap::new(), + parents: NodeMap(), curparent: ast::DUMMY_NODE_ID, }; visit::walk_crate(&mut visitor, krate); @@ -1569,9 +1569,9 @@ pub fn check_crate(tcx: &ty::ctxt, // items which are reachable from external crates based on visibility. let mut visitor = EmbargoVisitor { tcx: tcx, - exported_items: NodeSet::new(), - public_items: NodeSet::new(), - reexports: NodeSet::new(), + exported_items: NodeSet(), + public_items: NodeSet(), + reexports: NodeSet(), export_map: export_map, prev_exported: true, prev_public: true, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 153333c6782..31999faa6df 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -523,7 +523,7 @@ impl Module { children: RefCell::new(HashMap::new()), imports: RefCell::new(Vec::new()), external_module_children: RefCell::new(HashMap::new()), - anonymous_children: RefCell::new(NodeMap::new()), + anonymous_children: RefCell::new(NodeMap()), import_resolutions: RefCell::new(HashMap::new()), glob_count: Cell::new(0), resolved_import_count: Cell::new(0), @@ -943,8 +943,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { graph_root: graph_root, - trait_item_map: FnvHashMap::new(), - structs: FnvHashMap::new(), + trait_item_map: FnvHashMap(), + structs: FnvHashMap(), unresolved_imports: 0, @@ -961,16 +961,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { primitive_type_table: PrimitiveTypeTable::new(), - def_map: RefCell::new(NodeMap::new()), - freevars: RefCell::new(NodeMap::new()), - freevars_seen: RefCell::new(NodeMap::new()), - capture_mode_map: NodeMap::new(), - export_map: NodeMap::new(), - trait_map: NodeMap::new(), + def_map: RefCell::new(NodeMap()), + freevars: RefCell::new(NodeMap()), + freevars_seen: RefCell::new(NodeMap()), + capture_mode_map: NodeMap(), + export_map: NodeMap(), + trait_map: NodeMap(), used_imports: HashSet::new(), used_crates: HashSet::new(), - external_exports: DefIdSet::new(), - last_private: NodeMap::new(), + external_exports: DefIdSet(), + last_private: NodeMap(), emit_errors: true, make_glob_map: make_glob_map == MakeGlobMap::Yes, @@ -2635,7 +2635,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut seen = self.freevars_seen.borrow_mut(); let seen = match seen.entry(function_id) { Occupied(v) => v.into_mut(), - Vacant(v) => v.insert(NodeSet::new()), + Vacant(v) => v.insert(NodeSet()), }; if seen.contains(&node_id) { continue; diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index be927503bad..9f3c55d4f68 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -1306,7 +1306,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat, let ccx = bcx.ccx(); let tcx = bcx.tcx(); let reassigned = is_discr_reassigned(bcx, discr, body); - let mut bindings_map = FnvHashMap::new(); + let mut bindings_map = FnvHashMap(); pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| { let ident = path1.node; let variable_ty = node_id_type(bcx, p_id); diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 037f20ee4c5..eed61ae59a2 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -1461,8 +1461,8 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, needs_ret_allocas: nested_returns, personality: Cell::new(None), caller_expects_out_pointer: uses_outptr, - lllocals: RefCell::new(NodeMap::new()), - llupvars: RefCell::new(NodeMap::new()), + lllocals: RefCell::new(NodeMap()), + llupvars: RefCell::new(NodeMap()), id: id, param_substs: param_substs, span: sp, diff --git a/src/librustc_trans/trans/builder.rs b/src/librustc_trans/trans/builder.rs index 75194e3d21f..187b3e2cf21 100644 --- a/src/librustc_trans/trans/builder.rs +++ b/src/librustc_trans/trans/builder.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Build version of path with cycles removed. // Pass 1: scan table mapping str -> rightmost pos. - let mut mm = FnvHashMap::new(); + let mut mm = FnvHashMap(); let len = v.len(); let mut i = 0u; while i < len { diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 3eee4637de1..312fd33ef1f 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -176,7 +176,7 @@ pub fn unsized_part_of_type<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> // cleanups. pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { return memoized(ccx.needs_unwind_cleanup_cache(), ty, |ty| { - type_needs_unwind_cleanup_(ccx.tcx(), ty, &mut FnvHashSet::new()) + type_needs_unwind_cleanup_(ccx.tcx(), ty, &mut FnvHashSet()) }); fn type_needs_unwind_cleanup_<'tcx>(tcx: &ty::ctxt<'tcx>, diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 1abf3b0b886..10edb72f0e2 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -253,7 +253,7 @@ impl<'tcx> SharedCrateContext<'tcx> { metadata_llcx: metadata_llcx, export_map: export_map, reachable: reachable, - item_symbols: RefCell::new(NodeMap::new()), + item_symbols: RefCell::new(NodeMap()), link_meta: link_meta, symbol_hasher: RefCell::new(symbol_hasher), tcx: tcx, @@ -267,11 +267,11 @@ impl<'tcx> SharedCrateContext<'tcx> { n_inlines: Cell::new(0u), n_closures: Cell::new(0u), n_llvm_insns: Cell::new(0u), - llvm_insns: RefCell::new(FnvHashMap::new()), + llvm_insns: RefCell::new(FnvHashMap()), fn_stats: RefCell::new(Vec::new()), }, - available_monomorphizations: RefCell::new(FnvHashSet::new()), - available_drop_glues: RefCell::new(FnvHashMap::new()), + available_monomorphizations: RefCell::new(FnvHashSet()), + available_drop_glues: RefCell::new(FnvHashMap()), }; for i in range(0, local_count) { @@ -387,39 +387,39 @@ impl<'tcx> LocalCrateContext<'tcx> { llcx: llcx, td: td, tn: TypeNames::new(), - externs: RefCell::new(FnvHashMap::new()), - item_vals: RefCell::new(NodeMap::new()), - needs_unwind_cleanup_cache: RefCell::new(FnvHashMap::new()), - fn_pointer_shims: RefCell::new(FnvHashMap::new()), - drop_glues: RefCell::new(FnvHashMap::new()), - tydescs: RefCell::new(FnvHashMap::new()), + externs: RefCell::new(FnvHashMap()), + item_vals: RefCell::new(NodeMap()), + needs_unwind_cleanup_cache: RefCell::new(FnvHashMap()), + fn_pointer_shims: RefCell::new(FnvHashMap()), + drop_glues: RefCell::new(FnvHashMap()), + tydescs: RefCell::new(FnvHashMap()), finished_tydescs: Cell::new(false), - external: RefCell::new(DefIdMap::new()), - external_srcs: RefCell::new(NodeMap::new()), - monomorphized: RefCell::new(FnvHashMap::new()), - monomorphizing: RefCell::new(DefIdMap::new()), - vtables: RefCell::new(FnvHashMap::new()), - const_cstr_cache: RefCell::new(FnvHashMap::new()), - const_globals: RefCell::new(FnvHashMap::new()), - const_values: RefCell::new(NodeMap::new()), - static_values: RefCell::new(NodeMap::new()), - extern_const_values: RefCell::new(DefIdMap::new()), - impl_method_cache: RefCell::new(FnvHashMap::new()), - closure_bare_wrapper_cache: RefCell::new(FnvHashMap::new()), - lltypes: RefCell::new(FnvHashMap::new()), - llsizingtypes: RefCell::new(FnvHashMap::new()), - adt_reprs: RefCell::new(FnvHashMap::new()), - type_hashcodes: RefCell::new(FnvHashMap::new()), - all_llvm_symbols: RefCell::new(FnvHashSet::new()), + external: RefCell::new(DefIdMap()), + external_srcs: RefCell::new(NodeMap()), + monomorphized: RefCell::new(FnvHashMap()), + monomorphizing: RefCell::new(DefIdMap()), + vtables: RefCell::new(FnvHashMap()), + const_cstr_cache: RefCell::new(FnvHashMap()), + const_globals: RefCell::new(FnvHashMap()), + const_values: RefCell::new(NodeMap()), + static_values: RefCell::new(NodeMap()), + extern_const_values: RefCell::new(DefIdMap()), + impl_method_cache: RefCell::new(FnvHashMap()), + closure_bare_wrapper_cache: RefCell::new(FnvHashMap()), + lltypes: RefCell::new(FnvHashMap()), + llsizingtypes: RefCell::new(FnvHashMap()), + adt_reprs: RefCell::new(FnvHashMap()), + type_hashcodes: RefCell::new(FnvHashMap()), + all_llvm_symbols: RefCell::new(FnvHashSet()), int_type: Type::from_ref(ptr::null_mut()), opaque_vec_type: Type::from_ref(ptr::null_mut()), builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), - unboxed_closure_vals: RefCell::new(FnvHashMap::new()), + unboxed_closure_vals: RefCell::new(FnvHashMap()), dbg_cx: dbg_cx, eh_personality: RefCell::new(None), - intrinsics: RefCell::new(FnvHashMap::new()), + intrinsics: RefCell::new(FnvHashMap()), n_llvm_insns: Cell::new(0u), - trait_cache: RefCell::new(FnvHashMap::new()), + trait_cache: RefCell::new(FnvHashMap()), }; local_ccx.int_type = Type::int(&local_ccx.dummy_ccx(shared)); diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index a03a5090c05..5ffaa9486b3 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -271,9 +271,9 @@ impl<'tcx> TypeMap<'tcx> { fn new() -> TypeMap<'tcx> { TypeMap { unique_id_interner: Interner::new(), - type_to_metadata: FnvHashMap::new(), - unique_id_to_metadata: FnvHashMap::new(), - type_to_unique_id: FnvHashMap::new(), + type_to_metadata: FnvHashMap(), + unique_id_to_metadata: FnvHashMap(), + type_to_unique_id: FnvHashMap(), } } @@ -672,11 +672,11 @@ impl<'tcx> CrateDebugContext<'tcx> { llcontext: llcontext, builder: builder, current_debug_location: Cell::new(UnknownLocation), - created_files: RefCell::new(FnvHashMap::new()), - created_enum_disr_types: RefCell::new(DefIdMap::new()), + created_files: RefCell::new(FnvHashMap()), + created_enum_disr_types: RefCell::new(DefIdMap()), type_map: RefCell::new(TypeMap::new()), - namespace_map: RefCell::new(FnvHashMap::new()), - composite_types_completed: RefCell::new(FnvHashSet::new()), + namespace_map: RefCell::new(FnvHashMap()), + composite_types_completed: RefCell::new(FnvHashSet()), }; } } @@ -3228,7 +3228,7 @@ fn create_scope_map(cx: &CrateContext, fn_metadata: DISubprogram, fn_ast_id: ast::NodeId) -> NodeMap { - let mut scope_map = NodeMap::new(); + let mut scope_map = NodeMap(); let def_map = &cx.tcx().def_map; diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/trans/type_.rs index 0124ab72f6b..07eb17e6300 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -352,7 +352,7 @@ pub struct TypeNames { impl TypeNames { pub fn new() -> TypeNames { TypeNames { - named_types: RefCell::new(FnvHashMap::new()) + named_types: RefCell::new(FnvHashMap()) } } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index f2927dfd843..37487cbfc7e 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1711,7 +1711,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, let mut builtin_bounds = ty::empty_builtin_bounds(); let mut region_bounds = Vec::new(); let mut trait_bounds = Vec::new(); - let mut trait_def_ids = DefIdMap::new(); + let mut trait_def_ids = DefIdMap(); for ast_bound in ast_bounds.iter() { match *ast_bound { ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 47346592c86..bc2f291007d 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -592,7 +592,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, .collect::>(); // Keep track of which fields have already appeared in the pattern. - let mut used_fields = FnvHashMap::new(); + let mut used_fields = FnvHashMap(); // Typecheck each field. for &Spanned { node: ref field, span } in fields.iter() { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 7e38321049e..a4fa594621e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -373,16 +373,16 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> { -> Inherited<'a, 'tcx> { Inherited { infcx: infer::new_infer_ctxt(tcx), - locals: RefCell::new(NodeMap::new()), + locals: RefCell::new(NodeMap()), param_env: param_env, - node_types: RefCell::new(NodeMap::new()), - item_substs: RefCell::new(NodeMap::new()), - adjustments: RefCell::new(NodeMap::new()), - method_map: RefCell::new(FnvHashMap::new()), - object_cast_map: RefCell::new(NodeMap::new()), - upvar_borrow_map: RefCell::new(FnvHashMap::new()), - unboxed_closures: RefCell::new(DefIdMap::new()), - fn_sig_map: RefCell::new(NodeMap::new()), + node_types: RefCell::new(NodeMap()), + item_substs: RefCell::new(NodeMap()), + adjustments: RefCell::new(NodeMap()), + method_map: RefCell::new(FnvHashMap()), + object_cast_map: RefCell::new(NodeMap()), + upvar_borrow_map: RefCell::new(FnvHashMap()), + unboxed_closures: RefCell::new(DefIdMap()), + fn_sig_map: RefCell::new(NodeMap()), fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()), } } @@ -3153,7 +3153,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, enum_id_opt: Option) { let tcx = fcx.ccx.tcx; - let mut class_field_map = FnvHashMap::new(); + let mut class_field_map = FnvHashMap(); let mut fields_found = 0; for field in field_types.iter() { class_field_map.insert(field.name, (field.id, false)); diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index a7ef4c1e9f2..350cee99f6a 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -595,7 +595,7 @@ pub fn check_coherence(crate_context: &CrateCtxt) { CoherenceChecker { crate_context: crate_context, inference_context: new_infer_ctxt(crate_context.tcx), - inherent_impls: RefCell::new(FnvHashMap::new()), + inherent_impls: RefCell::new(FnvHashMap()), }.check(crate_context.tcx.map.krate()); impls::check(crate_context.tcx); unsafety::check(crate_context.tcx); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index c56952abc44..d1d81eba329 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -449,7 +449,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CollectCtxt<'a, 'tcx>, rcvr_ty_generics.repr(ccx.tcx)); let tcx = ccx.tcx; - let mut seen_methods = FnvHashSet::new(); + let mut seen_methods = FnvHashSet(); for m in ms { if !seen_methods.insert(m.pe_ident().repr(tcx)) { tcx.sess.span_err(m.span, "duplicate method in trait impl"); @@ -737,7 +737,7 @@ fn convert_struct<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>, let tcx = ccx.tcx; // Write the type of each of the members and check for duplicate fields. - let mut seen_fields: FnvHashMap = FnvHashMap::new(); + let mut seen_fields: FnvHashMap = FnvHashMap(); let field_tys = struct_def.fields.iter().map(|f| { let result = convert_field(ccx, &scheme.generics, f, local_def(id)); diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index b33921e07e8..86447e76a89 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -288,7 +288,7 @@ fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>, let mut terms_cx = TermsContext { tcx: tcx, arena: arena, - inferred_map: NodeMap::new(), + inferred_map: NodeMap(), inferred_infos: Vec::new(), // cache and share the variance struct used for items with diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 839dfa339b3..ab9700d966a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -313,7 +313,7 @@ pub fn run(mut krate: clean::Crate, let analysis = ::ANALYSISKEY.with(|a| a.clone()); let analysis = analysis.borrow(); let public_items = analysis.as_ref().map(|a| a.public_items.clone()); - let public_items = public_items.unwrap_or(NodeSet::new()); + let public_items = public_items.unwrap_or(NodeSet()); let paths: HashMap, ItemType)> = analysis.as_ref().map(|a| { let paths = a.external_paths.borrow_mut().take().unwrap();