Skip to content

Commit

Permalink
Auto merge of #21269 - alexcrichton:issue-6936, r=pnkfelix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 19, 2015
2 parents 43f2c19 + 3121c04 commit cda3490
Show file tree
Hide file tree
Showing 41 changed files with 341 additions and 308 deletions.
4 changes: 2 additions & 2 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ pub struct RawPointerDerive {
impl RawPointerDerive {
pub fn new() -> RawPointerDerive {
RawPointerDerive {
checked_raw_pointers: NodeSet::new(),
checked_raw_pointers: NodeSet(),
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down Expand Up @@ -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()),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/check_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/infer/region_inference/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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); )*

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down
Loading

0 comments on commit cda3490

Please sign in to comment.