1
Fork 0

remove generator_interiors map

This commit is contained in:
Niko Matsakis 2017-11-18 11:19:38 -05:00
parent 413f07438e
commit 22c0cbfa86
4 changed files with 5 additions and 40 deletions

View file

@ -360,8 +360,6 @@ pub struct TypeckTables<'tcx> {
/// not all closures are present in the map.
closure_kind_origins: ItemLocalMap<(Span, ast::Name)>,
generator_interiors: ItemLocalMap<ty::GeneratorInterior<'tcx>>,
/// For each fn, records the "liberated" types of its arguments
/// and return type. Liberated means that all bound regions
/// (including late-bound regions) are replaced with free
@ -406,7 +404,6 @@ impl<'tcx> TypeckTables<'tcx> {
pat_binding_modes: ItemLocalMap(),
pat_adjustments: ItemLocalMap(),
upvar_capture_map: FxHashMap(),
generator_interiors: ItemLocalMap(),
closure_kind_origins: ItemLocalMap(),
liberated_fn_sigs: ItemLocalMap(),
fru_field_types: ItemLocalMap(),
@ -657,24 +654,6 @@ impl<'tcx> TypeckTables<'tcx> {
data: &mut self.cast_kinds
}
}
pub fn generator_interiors(&self)
-> LocalTableInContext<ty::GeneratorInterior<'tcx>>
{
LocalTableInContext {
local_id_root: self.local_id_root,
data: &self.generator_interiors,
}
}
pub fn generator_interiors_mut(&mut self)
-> LocalTableInContextMut<ty::GeneratorInterior<'tcx>>
{
LocalTableInContextMut {
local_id_root: self.local_id_root,
data: &mut self.generator_interiors,
}
}
}
impl<'gcx> HashStable<StableHashingContext<'gcx>> for TypeckTables<'gcx> {
@ -699,7 +678,6 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for TypeckTables<'gcx> {
ref used_trait_imports,
tainted_by_errors,
ref free_region_map,
ref generator_interiors,
} = *self;
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
@ -735,7 +713,6 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for TypeckTables<'gcx> {
liberated_fn_sigs.hash_stable(hcx, hasher);
fru_field_types.hash_stable(hcx, hasher);
cast_kinds.hash_stable(hcx, hasher);
generator_interiors.hash_stable(hcx, hasher);
used_trait_imports.hash_stable(hcx, hasher);
tainted_by_errors.hash_stable(hcx, hasher);
free_region_map.hash_stable(hcx, hasher);

View file

@ -768,7 +768,11 @@ impl MirPass for StateTransform {
let hir_id = tcx.hir.node_to_hir_id(node_id);
// Get the interior types which typeck computed
let interior = *tcx.typeck_tables_of(def_id).generator_interiors().get(hir_id).unwrap();
let tables = tcx.typeck_tables_of(def_id);
let interior = match tables.node_id_to_type(hir_id).sty {
ty::TyGenerator(_, _, interior) => interior,
ref t => bug!("type of generator not a generator: {:?}", t),
};
// The first argument is the generator type passed by value
let gen_ty = mir.local_decls.raw[1].ty;

View file

@ -1040,9 +1040,6 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
let witness = fcx.next_ty_var(TypeVariableOrigin::MiscVariable(span));
fcx.deferred_generator_interiors.borrow_mut().push((body.id(), witness));
let interior = ty::GeneratorInterior::new(witness);
inherited.tables.borrow_mut().generator_interiors_mut().insert(fn_hir_id, interior);
Some(GeneratorTypes { yield_ty: fcx.yield_ty.unwrap(), interior: interior })
} else {
None

View file

@ -46,7 +46,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
wbcx.visit_anon_types();
wbcx.visit_cast_types();
wbcx.visit_free_region_map();
wbcx.visit_generator_interiors();
let used_trait_imports = mem::replace(&mut self.tables.borrow_mut().used_trait_imports,
Rc::new(DefIdSet()));
@ -378,18 +377,6 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}
}
fn visit_generator_interiors(&mut self) {
let common_local_id_root = self.fcx.tables.borrow().local_id_root.unwrap();
for (&id, interior) in self.fcx.tables.borrow().generator_interiors().iter() {
let hir_id = hir::HirId {
owner: common_local_id_root.index,
local_id: id,
};
let interior = self.resolve(interior, &hir_id);
self.tables.generator_interiors_mut().insert(hir_id, interior);
}
}
fn visit_liberated_fn_sigs(&mut self) {
let fcx_tables = self.fcx.tables.borrow();
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);