Auto merge of #21269 - alexcrichton:issue-6936, r=pnkfelix
This commit modifies resolve to prevent conflicts with typedef names in the same method that conflits are prevented with enum names. This is a breaking change due to the differing semantics in resolve, and any errors generated on behalf of this change require that a conflicting typedef, module, or structure to be renamed so they do not conflict. [breaking-change] Closes #6936
This commit is contained in:
commit
cda3490f8f
@ -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;
|
||||
|
@ -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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,8 @@ pub struct CStore {
|
||||
impl CStore {
|
||||
pub fn new(intr: Rc<IdentInterner>) -> 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()),
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<CFGIndex> {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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<Node> {
|
||||
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);
|
||||
|
@ -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<VarValue>,
|
||||
errors: &mut Vec<RegionResolutionError<'tcx>>)
|
||||
{
|
||||
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
|
||||
|
@ -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); )*
|
||||
|
||||
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub type PatIdMap = FnvHashMap<ast::Ident, ast::NodeId>;
|
||||
// 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);
|
||||
});
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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()),
|
||||
|
@ -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<K, V> = HashMap<K, V, DefaultState<FnvHasher>>;
|
||||
@ -27,42 +27,18 @@ pub type DefIdMap<T> = FnvHashMap<ast::DefId, T>;
|
||||
pub type NodeSet = FnvHashSet<ast::NodeId>;
|
||||
pub type DefIdSet = FnvHashSet<ast::DefId>;
|
||||
|
||||
// Hacks to get good names
|
||||
pub mod FnvHashMap {
|
||||
use std::hash::Hash;
|
||||
use std::default::Default;
|
||||
pub fn new<K: Hash<super::FnvHasher> + Eq, V>() -> super::FnvHashMap<K, V> {
|
||||
Default::default()
|
||||
}
|
||||
pub fn FnvHashMap<K: Hash<FnvHasher> + Eq, V>() -> FnvHashMap<K, V> {
|
||||
Default::default()
|
||||
}
|
||||
pub mod FnvHashSet {
|
||||
use std::hash::Hash;
|
||||
use std::default::Default;
|
||||
pub fn new<V: Hash<super::FnvHasher> + Eq>() -> super::FnvHashSet<V> {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
pub mod NodeMap {
|
||||
pub fn new<T>() -> super::NodeMap<T> {
|
||||
super::FnvHashMap::new()
|
||||
}
|
||||
}
|
||||
pub mod DefIdMap {
|
||||
pub fn new<T>() -> super::DefIdMap<T> {
|
||||
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<V: Hash<FnvHasher> + Eq>() -> FnvHashSet<V> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
pub fn NodeMap<T>() -> NodeMap<T> { FnvHashMap() }
|
||||
pub fn DefIdMap<T>() -> DefIdMap<T> { 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
|
||||
|
@ -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()),
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -321,9 +321,19 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
// These items live in the type namespace.
|
||||
ItemTy(..) => {
|
||||
let name_bindings =
|
||||
self.add_child(name, parent, ForbidDuplicateTypesAndModules, sp);
|
||||
self.add_child(name, parent, ForbidDuplicateTypesAndModules,
|
||||
sp);
|
||||
|
||||
name_bindings.define_type(DefTy(local_def(item.id), false), sp, modifiers);
|
||||
name_bindings.define_type(DefTy(local_def(item.id), false), sp,
|
||||
modifiers);
|
||||
|
||||
let parent_link = self.get_parent_link(parent, name);
|
||||
name_bindings.set_module_kind(parent_link,
|
||||
Some(local_def(item.id)),
|
||||
TypeModuleKind,
|
||||
false,
|
||||
is_public,
|
||||
sp);
|
||||
parent.clone()
|
||||
}
|
||||
|
||||
@ -412,118 +422,116 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
match mod_name {
|
||||
let mod_name = match mod_name {
|
||||
Some(mod_name) => mod_name,
|
||||
None => {
|
||||
self.resolve_error(ty.span,
|
||||
"inherent implementations may \
|
||||
only be implemented in the same \
|
||||
module as the type they are \
|
||||
implemented for")
|
||||
implemented for");
|
||||
return parent.clone();
|
||||
}
|
||||
Some(mod_name) => {
|
||||
// Create the module and add all methods.
|
||||
let parent_opt = parent.children.borrow().get(&mod_name).cloned();
|
||||
let new_parent = match parent_opt {
|
||||
// It already exists
|
||||
Some(ref child) if child.get_module_if_available()
|
||||
.is_some() &&
|
||||
(child.get_module().kind.get() == ImplModuleKind ||
|
||||
child.get_module().kind.get() == TraitModuleKind) => {
|
||||
child.get_module()
|
||||
}
|
||||
Some(ref child) if child.get_module_if_available()
|
||||
.is_some() &&
|
||||
child.get_module().kind.get() ==
|
||||
EnumModuleKind => child.get_module(),
|
||||
// Create the module
|
||||
_ => {
|
||||
let name_bindings =
|
||||
self.add_child(mod_name, parent, ForbidDuplicateModules, sp);
|
||||
};
|
||||
// Create the module and add all methods.
|
||||
let child_opt = parent.children.borrow().get(&mod_name)
|
||||
.and_then(|m| m.get_module_if_available());
|
||||
let new_parent = match child_opt {
|
||||
// It already exists
|
||||
Some(ref child) if (child.kind.get() == ImplModuleKind ||
|
||||
child.kind.get() == TraitModuleKind) => {
|
||||
child.clone()
|
||||
}
|
||||
Some(ref child) if child.kind.get() == EnumModuleKind ||
|
||||
child.kind.get() == TypeModuleKind => {
|
||||
child.clone()
|
||||
}
|
||||
// Create the module
|
||||
_ => {
|
||||
let name_bindings =
|
||||
self.add_child(mod_name, parent, ForbidDuplicateModules, sp);
|
||||
|
||||
let parent_link = self.get_parent_link(parent, name);
|
||||
let def_id = local_def(item.id);
|
||||
let ns = TypeNS;
|
||||
let is_public =
|
||||
!name_bindings.defined_in_namespace(ns) ||
|
||||
name_bindings.defined_in_public_namespace(ns);
|
||||
let parent_link = self.get_parent_link(parent, name);
|
||||
let def_id = local_def(item.id);
|
||||
let ns = TypeNS;
|
||||
let is_public =
|
||||
!name_bindings.defined_in_namespace(ns) ||
|
||||
name_bindings.defined_in_public_namespace(ns);
|
||||
|
||||
name_bindings.define_module(parent_link,
|
||||
Some(def_id),
|
||||
ImplModuleKind,
|
||||
false,
|
||||
is_public,
|
||||
sp);
|
||||
name_bindings.define_module(parent_link,
|
||||
Some(def_id),
|
||||
ImplModuleKind,
|
||||
false,
|
||||
is_public,
|
||||
sp);
|
||||
|
||||
name_bindings.get_module()
|
||||
}
|
||||
};
|
||||
name_bindings.get_module()
|
||||
}
|
||||
};
|
||||
|
||||
// For each implementation item...
|
||||
for impl_item in impl_items.iter() {
|
||||
match *impl_item {
|
||||
MethodImplItem(ref method) => {
|
||||
// Add the method to the module.
|
||||
let name = method.pe_ident().name;
|
||||
let method_name_bindings =
|
||||
self.add_child(name,
|
||||
&new_parent,
|
||||
ForbidDuplicateValues,
|
||||
method.span);
|
||||
let def = match method.pe_explicit_self()
|
||||
.node {
|
||||
SelfStatic => {
|
||||
// Static methods become
|
||||
// `DefStaticMethod`s.
|
||||
DefStaticMethod(local_def(method.id),
|
||||
FromImpl(local_def(item.id)))
|
||||
}
|
||||
_ => {
|
||||
// Non-static methods become
|
||||
// `DefMethod`s.
|
||||
DefMethod(local_def(method.id),
|
||||
None,
|
||||
FromImpl(local_def(item.id)))
|
||||
}
|
||||
};
|
||||
// For each implementation item...
|
||||
for impl_item in impl_items.iter() {
|
||||
match *impl_item {
|
||||
MethodImplItem(ref method) => {
|
||||
// Add the method to the module.
|
||||
let name = method.pe_ident().name;
|
||||
let method_name_bindings =
|
||||
self.add_child(name,
|
||||
&new_parent,
|
||||
ForbidDuplicateValues,
|
||||
method.span);
|
||||
let def = match method.pe_explicit_self()
|
||||
.node {
|
||||
SelfStatic => {
|
||||
// Static methods become
|
||||
// `DefStaticMethod`s.
|
||||
DefStaticMethod(local_def(method.id),
|
||||
FromImpl(local_def(item.id)))
|
||||
}
|
||||
_ => {
|
||||
// Non-static methods become
|
||||
// `DefMethod`s.
|
||||
DefMethod(local_def(method.id),
|
||||
None,
|
||||
FromImpl(local_def(item.id)))
|
||||
}
|
||||
};
|
||||
|
||||
// NB: not IMPORTABLE
|
||||
let modifiers = if method.pe_vis() == ast::Public {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
method_name_bindings.define_value(
|
||||
def,
|
||||
method.span,
|
||||
modifiers);
|
||||
}
|
||||
TypeImplItem(ref typedef) => {
|
||||
// Add the typedef to the module.
|
||||
let name = typedef.ident.name;
|
||||
let typedef_name_bindings =
|
||||
self.add_child(
|
||||
name,
|
||||
&new_parent,
|
||||
ForbidDuplicateTypesAndModules,
|
||||
typedef.span);
|
||||
let def = DefAssociatedTy(local_def(
|
||||
typedef.id));
|
||||
// NB: not IMPORTABLE
|
||||
let modifiers = if typedef.vis == ast::Public {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
typedef_name_bindings.define_type(
|
||||
def,
|
||||
typedef.span,
|
||||
modifiers);
|
||||
}
|
||||
}
|
||||
// NB: not IMPORTABLE
|
||||
let modifiers = if method.pe_vis() == ast::Public {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
method_name_bindings.define_value(
|
||||
def,
|
||||
method.span,
|
||||
modifiers);
|
||||
}
|
||||
TypeImplItem(ref typedef) => {
|
||||
// Add the typedef to the module.
|
||||
let name = typedef.ident.name;
|
||||
let typedef_name_bindings =
|
||||
self.add_child(
|
||||
name,
|
||||
&new_parent,
|
||||
ForbidDuplicateTypesAndModules,
|
||||
typedef.span);
|
||||
let def = DefAssociatedTy(local_def(
|
||||
typedef.id));
|
||||
// NB: not IMPORTABLE
|
||||
let modifiers = if typedef.vis == ast::Public {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
typedef_name_bindings.define_type(
|
||||
def,
|
||||
typedef.span,
|
||||
modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent.clone()
|
||||
}
|
||||
|
||||
@ -859,7 +867,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
let kind = match def {
|
||||
DefTy(_, true) => EnumModuleKind,
|
||||
DefStruct(..) | DefTy(..) => ImplModuleKind,
|
||||
DefTy(_, false) => TypeModuleKind,
|
||||
DefStruct(..) => ImplModuleKind,
|
||||
_ => NormalModuleKind
|
||||
};
|
||||
|
||||
|
@ -459,6 +459,7 @@ enum ModuleKind {
|
||||
TraitModuleKind,
|
||||
ImplModuleKind,
|
||||
EnumModuleKind,
|
||||
TypeModuleKind,
|
||||
AnonymousModuleKind,
|
||||
}
|
||||
|
||||
@ -522,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),
|
||||
@ -942,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,
|
||||
|
||||
@ -960,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,
|
||||
@ -2240,6 +2241,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
TraitModuleKind |
|
||||
ImplModuleKind |
|
||||
EnumModuleKind |
|
||||
TypeModuleKind |
|
||||
AnonymousModuleKind => {
|
||||
search_module = parent_module_node.upgrade().unwrap();
|
||||
}
|
||||
@ -2337,6 +2339,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
TraitModuleKind |
|
||||
ImplModuleKind |
|
||||
EnumModuleKind |
|
||||
TypeModuleKind |
|
||||
AnonymousModuleKind => module_ = new_module,
|
||||
}
|
||||
}
|
||||
@ -2353,6 +2356,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
TraitModuleKind |
|
||||
ImplModuleKind |
|
||||
EnumModuleKind |
|
||||
TypeModuleKind |
|
||||
AnonymousModuleKind => {
|
||||
match self.get_nearest_normal_module_parent(module_.clone()) {
|
||||
None => module_,
|
||||
@ -2631,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;
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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>,
|
||||
|
@ -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));
|
||||
|
@ -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()),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -3225,7 +3225,7 @@ fn create_scope_map(cx: &CrateContext,
|
||||
fn_metadata: DISubprogram,
|
||||
fn_ast_id: ast::NodeId)
|
||||
-> NodeMap<DIScope> {
|
||||
let mut scope_map = NodeMap::new();
|
||||
let mut scope_map = NodeMap();
|
||||
|
||||
let def_map = &cx.tcx().def_map;
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1719,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) => {
|
||||
|
@ -592,7 +592,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
.collect::<FnvHashMap<_, _>>();
|
||||
|
||||
// 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() {
|
||||
|
@ -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<ast::DefId>) {
|
||||
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));
|
||||
|
@ -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);
|
||||
|
@ -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<ast::Name, Span> = FnvHashMap::new();
|
||||
let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
|
||||
let field_tys = struct_def.fields.iter().map(|f| {
|
||||
let result = convert_field(ccx, &scheme.generics, f, local_def(id));
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<ast::DefId, (Vec<String>, ItemType)> =
|
||||
analysis.as_ref().map(|a| {
|
||||
let paths = a.external_paths.borrow_mut().take().unwrap();
|
||||
|
44
src/test/compile-fail/issue-6936.rs
Normal file
44
src/test/compile-fail/issue-6936.rs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct T;
|
||||
|
||||
mod t1 {
|
||||
type Foo = ::T;
|
||||
mod Foo {} //~ ERROR: duplicate definition of type or module `Foo`
|
||||
}
|
||||
|
||||
mod t2 {
|
||||
type Foo = ::T;
|
||||
struct Foo; //~ ERROR: duplicate definition of type or module `Foo`
|
||||
}
|
||||
|
||||
mod t3 {
|
||||
type Foo = ::T;
|
||||
enum Foo {} //~ ERROR: duplicate definition of type or module `Foo`
|
||||
}
|
||||
|
||||
mod t4 {
|
||||
type Foo = ::T;
|
||||
fn Foo() {} // ok
|
||||
}
|
||||
|
||||
mod t5 {
|
||||
type Bar<T> = T;
|
||||
mod Bar {} //~ ERROR: duplicate definition of type or module `Bar`
|
||||
}
|
||||
|
||||
mod t6 {
|
||||
type Foo = ::T;
|
||||
impl Foo {} // ok
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user