Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the RefCell around freevars and freevars_seen in librustc_resolve #29564

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl<'tcx> ctxt<'tcx> {
def_map: DefMap,
named_region_map: resolve_lifetime::NamedRegionMap,
map: ast_map::Map<'tcx>,
freevars: RefCell<FreevarMap>,
freevars: FreevarMap,
region_maps: RegionMaps,
lang_items: middle::lang_items::LanguageItems,
stability: stability::Index<'tcx>,
Expand Down Expand Up @@ -481,7 +481,7 @@ impl<'tcx> ctxt<'tcx> {
super_predicates: RefCell::new(DefIdMap()),
fulfilled_predicates: RefCell::new(traits::FulfilledPredicates::new()),
map: map,
freevars: freevars,
freevars: RefCell::new(freevars),
tcache: RefCell::new(DefIdMap()),
rcache: RefCell::new(FnvHashMap()),
tc_cache: RefCell::new(FnvHashMap()),
Expand Down
21 changes: 10 additions & 11 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ pub struct Resolver<'a, 'tcx:'a> {
primitive_type_table: PrimitiveTypeTable,

def_map: DefMap,
freevars: RefCell<FreevarMap>,
freevars_seen: RefCell<NodeMap<NodeMap<usize>>>,
freevars: FreevarMap,
freevars_seen: NodeMap<NodeMap<usize>>,
export_map: ExportMap,
trait_map: TraitMap,
external_exports: ExternalExports,
Expand Down Expand Up @@ -1227,8 +1227,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
primitive_type_table: PrimitiveTypeTable::new(),

def_map: RefCell::new(NodeMap()),
freevars: RefCell::new(NodeMap()),
freevars_seen: RefCell::new(NodeMap()),
freevars: NodeMap(),
freevars_seen: NodeMap(),
export_map: NodeMap(),
trait_map: NodeMap(),
used_imports: HashSet::new(),
Expand Down Expand Up @@ -3081,7 +3081,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

// Resolve a local definition, potentially adjusting for closures.
fn adjust_local_def(&self, local_def: LocalDef, span: Span) -> Option<Def> {
fn adjust_local_def(&mut self, local_def: LocalDef, span: Span) -> Option<Def> {
let ribs = match local_def.ribs {
Some((TypeNS, i)) => &self.type_ribs[i+1..],
Some((ValueNS, i)) => &self.value_ribs[i+1..],
Expand All @@ -3103,15 +3103,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let prev_def = def;
let node_def_id = self.ast_map.local_def_id(node_id);

let mut seen = self.freevars_seen.borrow_mut();
let seen = seen.entry(function_id).or_insert_with(|| NodeMap());
let seen = self.freevars_seen.entry(function_id)
.or_insert_with(|| NodeMap());
if let Some(&index) = seen.get(&node_id) {
def = DefUpvar(node_def_id, node_id, index, function_id);
continue;
}
let mut freevars = self.freevars.borrow_mut();
let vec = freevars.entry(function_id)
.or_insert_with(|| vec![]);
let vec = self.freevars.entry(function_id)
.or_insert_with(|| vec![]);
let depth = vec.len();
vec.push(Freevar { def: prev_def, span: span });

Expand Down Expand Up @@ -4028,7 +4027,7 @@ fn module_to_string(module: &Module) -> String {

pub struct CrateMap {
pub def_map: DefMap,
pub freevars: RefCell<FreevarMap>,
pub freevars: FreevarMap,
pub export_map: ExportMap,
pub trait_map: TraitMap,
pub external_exports: ExternalExports,
Expand Down