/// Create a type context and call the closure with a `TyCtxt` reference
/// to the context. The closure enforces that the type context and any interned
/// value (types, substs, etc.) can only be used while `ty::tls` has a valid
/// reference to the context, to allow formatting values that need it.
Create a type context and call the closure with a `TyCtxt` reference
to the context. The closure enforces that the type context and any interned
value (types, substs, etc.) can only be used while `ty::tls` has a valid
reference to the context, to allow formatting values that need it.
Create a type context and call the closure with a ` TyCtxt ` reference to the context . The closure enforces that the type context and any interned value ( types substs etc . ) can only be used while ` ty :: tls ` has a valid reference to the context to allow formatting values that need it .
pub fn create_and_enter<F, R>(s: &'tcx Session,
                                  local_providers: ty::maps::Providers<'tcx>,
                                  extern_providers: ty::maps::Providers<'tcx>,
                                  mir_passes: Rc<Passes>,
                                  arenas: &'tcx GlobalArenas<'tcx>,
                                  arena: &'tcx DroplessArena,
                                  resolutions: ty::Resolutions,
                                  named_region_map: resolve_lifetime::NamedRegionMap,
                                  hir: hir_map::Map<'tcx>,
                                  lang_items: middle::lang_items::LanguageItems,
                                  stability: stability::Index<'tcx>,
                                  crate_name: &str,
                                  f: F) -> R
                                  where F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'tcx>) -> R
    {
        let data_layout = TargetDataLayout::parse(s);
        let interners = CtxtInterners::new(arena);
        let common_types = CommonTypes::new(&interners);
        let dep_graph = hir.dep_graph.clone();
        let fulfilled_predicates = traits::GlobalFulfilledPredicates::new(dep_graph.clone());
        let max_cnum = s.cstore.crates().iter().map(|c| c.as_usize()).max().unwrap_or(0);
        let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
        providers[LOCAL_CRATE] = local_providers;
        tls::enter_global(GlobalCtxt {
            sess: s,
            trans_trait_caches: traits::trans::TransTraitCaches::new(dep_graph.clone()),
            specializes_cache: RefCell::new(traits::SpecializesCache::new()),
            global_arenas: arenas,
            global_interners: interners,
            dep_graph: dep_graph.clone(),
            types: common_types,
            named_region_map: named_region_map,
            variance_computed: Cell::new(false),
            trait_map: resolutions.trait_map,
            export_map: resolutions.export_map,
            fulfilled_predicates: RefCell::new(fulfilled_predicates),
            hir: hir,
            maps: maps::Maps::new(dep_graph, providers),
            mir_passes,
            freevars: RefCell::new(resolutions.freevars),
            maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
            rcache: RefCell::new(FxHashMap()),
            normalized_cache: RefCell::new(FxHashMap()),
            inhabitedness_cache: RefCell::new(FxHashMap()),
            lang_items: lang_items,
            used_unsafe: RefCell::new(NodeSet()),
            used_mut_nodes: RefCell::new(NodeSet()),
            populated_external_types: RefCell::new(DefIdSet()),
            populated_external_primitive_impls: RefCell::new(DefIdSet()),
            stability: RefCell::new(stability),
            selection_cache: traits::SelectionCache::new(),
            evaluation_cache: traits::EvaluationCache::new(),
            rvalue_promotable_to_static: RefCell::new(NodeMap()),
            fragment_infos: RefCell::new(DefIdMap()),
            crate_name: Symbol::intern(crate_name),
            data_layout: data_layout,
            layout_cache: RefCell::new(FxHashMap()),
            layout_interner: RefCell::new(FxHashSet()),
            code_extent_interner: RefCell::new(FxHashSet()),
            layout_depth: Cell::new(0),
            derive_macros: RefCell::new(NodeMap()),
            stability_interner: RefCell::new(FxHashSet()),
            all_traits: RefCell::new(None),
            ast_ty_to_ty_cache: RefCell::new(NodeMap()),
       }, f)
    }
pub fn create_and_enter < F , R > ( s : & ' tcx Session , local_providers : ty :: maps :: Providers < ' tcx > , extern_providers : ty :: maps :: Providers < ' tcx > , mir_passes : Rc < Passes > , arenas : & ' tcx GlobalArenas < ' tcx > , arena : & ' tcx DroplessArena , resolutions : ty :: Resolutions , named_region_map : resolve_lifetime :: NamedRegionMap , hir : hir_map :: Map < ' tcx > , lang_items : middle :: lang_items :: LanguageItems , stability : stability :: Index < ' tcx > , crate_name : & str , f : F ) -> R where F : for < ' b > FnOnce ( TyCtxt < ' b , ' tcx , ' tcx > ) -> R { let data_layout = TargetDataLayout :: parse ( s ) ; let interners = CtxtInterners :: new ( arena ) ; let common_types = CommonTypes :: new ( & interners ) ; let dep_graph = hir . dep_graph . clone ( ) ; let fulfilled_predicates = traits :: GlobalFulfilledPredicates :: new ( dep_graph . clone ( ) ) ; let max_cnum = s . cstore . crates ( ) . iter ( ) . map ( | c | c . as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ; let mut providers = IndexVec :: from_elem_n ( extern_providers , max_cnum + 1 ) ; providers [ LOCAL_CRATE ] = local_providers ; tls :: enter_global ( GlobalCtxt { sess : s , trans_trait_caches : traits :: trans :: TransTraitCaches :: new ( dep_graph . clone ( ) ) , specializes_cache : RefCell :: new ( traits :: SpecializesCache :: new ( ) ) , global_arenas : arenas , global_interners : interners , dep_graph : dep_graph . clone ( ) , types : common_types , named_region_map : named_region_map , variance_computed : Cell :: new ( false ) , trait_map : resolutions . trait_map , export_map : resolutions . export_map , fulfilled_predicates : RefCell :: new ( fulfilled_predicates ) , hir : hir , maps : maps :: Maps :: new ( dep_graph , providers ) , mir_passes , freevars : RefCell :: new ( resolutions . freevars ) , maybe_unused_trait_imports : resolutions . maybe_unused_trait_imports , rcache : RefCell :: new ( FxHashMap ( ) ) , normalized_cache : RefCell :: new ( FxHashMap ( ) ) , inhabitedness_cache : RefCell :: new ( FxHashMap ( ) ) , lang_items : lang_items , used_unsafe : RefCell :: new ( NodeSet ( ) ) , used_mut_nodes : RefCell :: new ( NodeSet ( ) ) , populated_external_types : RefCell :: new ( DefIdSet ( ) ) , populated_external_primitive_impls : RefCell :: new ( DefIdSet ( ) ) , stability : RefCell :: new ( stability ) , selection_cache : traits :: SelectionCache :: new ( ) , evaluation_cache : traits :: EvaluationCache :: new ( ) , rvalue_promotable_to_static : RefCell :: new ( NodeMap ( ) ) , fragment_infos : RefCell :: new ( DefIdMap ( ) ) , crate_name : Symbol :: intern ( crate_name ) , data_layout : data_layout , layout_cache : RefCell :: new ( FxHashMap ( ) ) , layout_interner : RefCell :: new ( FxHashSet ( ) ) , code_extent_interner : RefCell :: new ( FxHashSet ( ) ) , layout_depth : Cell :: new ( 0 ) , derive_macros : RefCell :: new ( NodeMap ( ) ) , stability_interner : RefCell :: new ( FxHashSet ( ) ) , all_traits : RefCell :: new ( None ) , ast_ty_to_ty_cache : RefCell :: new ( NodeMap ( ) ) , } , f ) }
Create a type context and call the closure with a `TyCtxt` reference
to the context.
Create a type context and call the closure with a ` TyCtxt ` reference to the context .
s
&'tcx Session
local_providers
ty::maps::Providers<'tcx>
extern_providers
ty::maps::Providers<'tcx>
mir_passes
Rc<Passes>
arenas
&'tcx GlobalArenas<'tcx>
arena
&'tcx DroplessArena
resolutions
ty::Resolutions
named_region_map
resolve_lifetime::NamedRegionMap
hir
hir_map::Map<'tcx>
lang_items
middle::lang_items::LanguageItems
stability
stability::Index<'tcx>
crate_name
&str
f
F