From 22c0cbfa8675bf81091bd4bcf50b824fbffba108 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 18 Nov 2017 11:19:38 -0500 Subject: [PATCH] remove `generator_interiors` map --- src/librustc/ty/context.rs | 23 ----------------------- src/librustc_mir/transform/generator.rs | 6 +++++- src/librustc_typeck/check/mod.rs | 3 --- src/librustc_typeck/check/writeback.rs | 13 ------------- 4 files changed, 5 insertions(+), 40 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 862d3e9bb8a..dbcdd17480e 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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>, - /// 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> - { - LocalTableInContext { - local_id_root: self.local_id_root, - data: &self.generator_interiors, - } - } - - pub fn generator_interiors_mut(&mut self) - -> LocalTableInContextMut> - { - LocalTableInContextMut { - local_id_root: self.local_id_root, - data: &mut self.generator_interiors, - } - } } impl<'gcx> HashStable> for TypeckTables<'gcx> { @@ -699,7 +678,6 @@ impl<'gcx> HashStable> 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> 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); diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 7d12d50355b..d46aa1c7aef 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -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; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 2a23a6f82af..b70c62cd733 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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 diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 57cebc12a44..d3991850121 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -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);