Auto merge of #29564 - gereeter:no-freevar-refcell, r=sanxiyn
This commit is contained in:
commit
11e55e4de1
|
@ -456,7 +456,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
def_map: DefMap,
|
def_map: DefMap,
|
||||||
named_region_map: resolve_lifetime::NamedRegionMap,
|
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||||
map: ast_map::Map<'tcx>,
|
map: ast_map::Map<'tcx>,
|
||||||
freevars: RefCell<FreevarMap>,
|
freevars: FreevarMap,
|
||||||
region_maps: RegionMaps,
|
region_maps: RegionMaps,
|
||||||
lang_items: middle::lang_items::LanguageItems,
|
lang_items: middle::lang_items::LanguageItems,
|
||||||
stability: stability::Index<'tcx>,
|
stability: stability::Index<'tcx>,
|
||||||
|
@ -489,7 +489,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
super_predicates: RefCell::new(DefIdMap()),
|
super_predicates: RefCell::new(DefIdMap()),
|
||||||
fulfilled_predicates: RefCell::new(traits::FulfilledPredicates::new()),
|
fulfilled_predicates: RefCell::new(traits::FulfilledPredicates::new()),
|
||||||
map: map,
|
map: map,
|
||||||
freevars: freevars,
|
freevars: RefCell::new(freevars),
|
||||||
tcache: RefCell::new(DefIdMap()),
|
tcache: RefCell::new(DefIdMap()),
|
||||||
rcache: RefCell::new(FnvHashMap()),
|
rcache: RefCell::new(FnvHashMap()),
|
||||||
tc_cache: RefCell::new(FnvHashMap()),
|
tc_cache: RefCell::new(FnvHashMap()),
|
||||||
|
|
|
@ -1151,8 +1151,8 @@ pub struct Resolver<'a, 'tcx:'a> {
|
||||||
primitive_type_table: PrimitiveTypeTable,
|
primitive_type_table: PrimitiveTypeTable,
|
||||||
|
|
||||||
def_map: DefMap,
|
def_map: DefMap,
|
||||||
freevars: RefCell<FreevarMap>,
|
freevars: FreevarMap,
|
||||||
freevars_seen: RefCell<NodeMap<NodeMap<usize>>>,
|
freevars_seen: NodeMap<NodeMap<usize>>,
|
||||||
export_map: ExportMap,
|
export_map: ExportMap,
|
||||||
trait_map: TraitMap,
|
trait_map: TraitMap,
|
||||||
external_exports: ExternalExports,
|
external_exports: ExternalExports,
|
||||||
|
@ -1227,8 +1227,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
primitive_type_table: PrimitiveTypeTable::new(),
|
primitive_type_table: PrimitiveTypeTable::new(),
|
||||||
|
|
||||||
def_map: RefCell::new(NodeMap()),
|
def_map: RefCell::new(NodeMap()),
|
||||||
freevars: RefCell::new(NodeMap()),
|
freevars: NodeMap(),
|
||||||
freevars_seen: RefCell::new(NodeMap()),
|
freevars_seen: NodeMap(),
|
||||||
export_map: NodeMap(),
|
export_map: NodeMap(),
|
||||||
trait_map: NodeMap(),
|
trait_map: NodeMap(),
|
||||||
used_imports: HashSet::new(),
|
used_imports: HashSet::new(),
|
||||||
|
@ -3081,7 +3081,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve a local definition, potentially adjusting for closures.
|
// 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 {
|
let ribs = match local_def.ribs {
|
||||||
Some((TypeNS, i)) => &self.type_ribs[i+1..],
|
Some((TypeNS, i)) => &self.type_ribs[i+1..],
|
||||||
Some((ValueNS, i)) => &self.value_ribs[i+1..],
|
Some((ValueNS, i)) => &self.value_ribs[i+1..],
|
||||||
|
@ -3103,15 +3103,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
let prev_def = def;
|
let prev_def = def;
|
||||||
let node_def_id = self.ast_map.local_def_id(node_id);
|
let node_def_id = self.ast_map.local_def_id(node_id);
|
||||||
|
|
||||||
let mut seen = self.freevars_seen.borrow_mut();
|
let seen = self.freevars_seen.entry(function_id)
|
||||||
let seen = seen.entry(function_id).or_insert_with(|| NodeMap());
|
.or_insert_with(|| NodeMap());
|
||||||
if let Some(&index) = seen.get(&node_id) {
|
if let Some(&index) = seen.get(&node_id) {
|
||||||
def = DefUpvar(node_def_id, node_id, index, function_id);
|
def = DefUpvar(node_def_id, node_id, index, function_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut freevars = self.freevars.borrow_mut();
|
let vec = self.freevars.entry(function_id)
|
||||||
let vec = freevars.entry(function_id)
|
.or_insert_with(|| vec![]);
|
||||||
.or_insert_with(|| vec![]);
|
|
||||||
let depth = vec.len();
|
let depth = vec.len();
|
||||||
vec.push(Freevar { def: prev_def, span: span });
|
vec.push(Freevar { def: prev_def, span: span });
|
||||||
|
|
||||||
|
@ -4028,7 +4027,7 @@ fn module_to_string(module: &Module) -> String {
|
||||||
|
|
||||||
pub struct CrateMap {
|
pub struct CrateMap {
|
||||||
pub def_map: DefMap,
|
pub def_map: DefMap,
|
||||||
pub freevars: RefCell<FreevarMap>,
|
pub freevars: FreevarMap,
|
||||||
pub export_map: ExportMap,
|
pub export_map: ExportMap,
|
||||||
pub trait_map: TraitMap,
|
pub trait_map: TraitMap,
|
||||||
pub external_exports: ExternalExports,
|
pub external_exports: ExternalExports,
|
||||||
|
|
Loading…
Reference in New Issue