Skip to content

Commit

Permalink
Simplify TyCtxt::create_and_enter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Dec 19, 2016
1 parent 39e6ae2 commit f705c69
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
10 changes: 4 additions & 6 deletions src/librustc/ty/context.rs
Expand Up @@ -762,11 +762,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// 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>,
Expand All @@ -790,7 +788,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
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())),
Expand All @@ -802,8 +800,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
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()),
Expand Down
9 changes: 8 additions & 1 deletion src/librustc/ty/mod.rs
Expand Up @@ -17,7 +17,7 @@ pub use self::LvaluePreference::*;
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};
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 3 additions & 13 deletions src/librustc_driver/driver.rs
Expand Up @@ -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;
Expand All @@ -20,7 +19,7 @@ use rustc::session::search_paths::PathKind;
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;
Expand Down Expand Up @@ -59,13 +58,6 @@ use syntax_ext;

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,
Expand Down Expand Up @@ -864,11 +856,9 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,

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,
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_driver/pretty.rs
Expand Up @@ -15,10 +15,9 @@ pub use self::PpSourceMode::*;
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;
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_driver/test.rs
Expand Up @@ -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,
Expand Down

0 comments on commit f705c69

Please sign in to comment.