]> git.lizzy.rs Git - rust.git/commitdiff
Simplify `TyCtxt::create_and_enter`.
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Thu, 15 Dec 2016 11:13:24 +0000 (11:13 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Mon, 19 Dec 2016 20:57:03 +0000 (20:57 +0000)
src/librustc/ty/context.rs
src/librustc/ty/mod.rs
src/librustc_driver/driver.rs
src/librustc_driver/pretty.rs
src/librustc_driver/test.rs

index 4854a14f733f552c89e10e3252e1cbdb72a792ec..20405398effd78946b9f4c9b2d3701602932b9af 100644 (file)
@@ -762,11 +762,9 @@ fn is_global(self) -> bool {
     /// reference to the context, to allow formatting values that need it.
     pub fn create_and_enter<F, R>(s: &'tcx Session,
                                   arenas: &'tcx CtxtArenas<'tcx>,
-                                  trait_map: TraitMap,
+                                  resolutions: ty::Resolutions,
                                   named_region_map: resolve_lifetime::NamedRegionMap,
                                   map: ast_map::Map<'tcx>,
-                                  freevars: FreevarMap,
-                                 maybe_unused_trait_imports: NodeSet,
                                   region_maps: RegionMaps,
                                   lang_items: middle::lang_items::LanguageItems,
                                   stability: stability::Index<'tcx>,
@@ -790,7 +788,7 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
             item_variance_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             variance_computed: Cell::new(false),
             sess: s,
-            trait_map: trait_map,
+            trait_map: resolutions.trait_map,
             tables: RefCell::new(Tables::empty()),
             impl_trait_refs: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             trait_defs: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
@@ -802,8 +800,8 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
             fulfilled_predicates: RefCell::new(fulfilled_predicates),
             map: map,
             mir_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            freevars: RefCell::new(freevars),
-            maybe_unused_trait_imports: maybe_unused_trait_imports,
+            freevars: RefCell::new(resolutions.freevars),
+            maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
             item_types: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             rcache: RefCell::new(FxHashMap()),
             tc_cache: RefCell::new(FxHashMap()),
index df12c252907a5a5f319ef34f8e2d10c21b3514c5..8f478435efd90d15b6fc5d0e2d33475670242f88 100644 (file)
@@ -17,7 +17,7 @@
 pub use self::fold::TypeFoldable;
 
 use dep_graph::{self, DepNode};
-use hir::map as ast_map;
+use hir::{map as ast_map, FreevarMap, TraitMap};
 use middle;
 use hir::def::{Def, CtorKind, ExportMap};
 use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
@@ -112,6 +112,13 @@ pub struct CrateAnalysis<'tcx> {
     pub hir_ty_to_ty: NodeMap<Ty<'tcx>>,
 }
 
+#[derive(Clone)]
+pub struct Resolutions {
+    pub freevars: FreevarMap,
+    pub trait_map: TraitMap,
+    pub maybe_unused_trait_imports: NodeSet,
+}
+
 #[derive(Copy, Clone)]
 pub enum DtorKind {
     NoDtor,
index ace00f031859dd43e30afdf6b1a958726ecb4e22..360933c6b669532457f61cf647dccf7a96813bee 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use rustc::hir;
-use rustc::hir::{map as hir_map, FreevarMap, TraitMap};
+use rustc::hir::{self, map as hir_map};
 use rustc::hir::lowering::lower_crate;
 use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_mir as mir;
@@ -20,7 +19,7 @@
 use rustc::lint;
 use rustc::middle::{self, dependency_format, stability, reachable};
 use rustc::middle::privacy::AccessLevels;
-use rustc::ty::{self, TyCtxt};
+use rustc::ty::{self, TyCtxt, Resolutions};
 use rustc::util::common::time;
 use rustc::util::nodemap::{NodeSet, NodeMap};
 use rustc_borrowck as borrowck;
 
 use derive_registrar;
 
-#[derive(Clone)]
-pub struct Resolutions {
-    pub freevars: FreevarMap,
-    pub trait_map: TraitMap,
-    pub maybe_unused_trait_imports: NodeSet,
-}
-
 pub fn compile_input(sess: &Session,
                      cstore: &CStore,
                      input: &Input,
@@ -864,11 +856,9 @@ macro_rules! try_with_f {
 
     TyCtxt::create_and_enter(sess,
                              arenas,
-                             resolutions.trait_map,
+                             resolutions,
                              named_region_map,
                              hir_map,
-                             resolutions.freevars,
-                             resolutions.maybe_unused_trait_imports,
                              region_map,
                              lang_items,
                              index,
index b055b043723e4ab769304d1a249fa2feff74cd38..74df1e52bde43143a7dab39a42aee28611022fc9 100644 (file)
 pub use self::PpMode::*;
 use self::NodesMatchingUII::*;
 
-use abort_on_err;
-use driver::{self, Resolutions};
+use {abort_on_err, driver};
 
-use rustc::ty::{self, TyCtxt};
+use rustc::ty::{self, TyCtxt, Resolutions};
 use rustc::cfg;
 use rustc::cfg::graphviz::LabelledCFG;
 use rustc::dep_graph::DepGraph;
index 2f8550e5acda70dcca033d3dbdd07de56cd18fc2..cbab39c390829422419cbacd3e6bd51320dee7fc 100644 (file)
@@ -138,11 +138,9 @@ fn test_env<F>(source_string: &str,
     let index = stability::Index::new(&ast_map);
     TyCtxt::create_and_enter(&sess,
                              &arenas,
-                             resolutions.trait_map,
+                             resolutions,
                              named_region_map.unwrap(),
                              ast_map,
-                             resolutions.freevars,
-                             resolutions.maybe_unused_trait_imports,
                              region_map,
                              lang_items,
                              index,