pub fn create_global_ctxt(
        s: &'tcx Session,
        lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
        local_providers: ty::query::Providers,
        extern_providers: ty::query::Providers,
        arena: &'tcx WorkerLocal<Arena<'tcx>>,
        resolutions: ty::ResolverOutputs,
        krate: &'tcx hir::Crate<'tcx>,
        definitions: &'tcx Definitions,
        dep_graph: DepGraph,
        on_disk_query_result_cache: query::OnDiskCache<'tcx>,
        crate_name: &str,
        output_filenames: &OutputFilenames,
    ) -> GlobalCtxt<'tcx> {
        let data_layout = TargetDataLayout::parse(&s.target.target).unwrap_or_else(|err| {
            s.fatal(&err);
        });
        let interners = CtxtInterners::new(arena);
        let common_types = CommonTypes::new(&interners);
        let common_lifetimes = CommonLifetimes::new(&interners);
        let common_consts = CommonConsts::new(&interners, &common_types);
        let cstore = resolutions.cstore;
        let crates = cstore.crates_untracked();
        let max_cnum = 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;

        let def_path_hash_to_def_id = if s.opts.build_dep_graph() {
            let def_path_tables = crates
                .iter()
                .map(|&cnum| (cnum, cstore.def_path_table(cnum)))
                .chain(iter::once((LOCAL_CRATE, definitions.def_path_table())));

            // Precompute the capacity of the hashmap so we don't have to
            // re-allocate when populating it.
            let capacity = def_path_tables.clone().map(|(_, t)| t.size()).sum::<usize>();

            let mut map: FxHashMap<_, _> =
                FxHashMap::with_capacity_and_hasher(capacity, ::std::default::Default::default());

            for (cnum, def_path_table) in def_path_tables {
                def_path_table.add_def_path_hashes_to(cnum, &mut map);
            }

            Some(map)
        } else {
            None
        };

        let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
        for (hir_id, v) in krate.trait_map.iter() {
            let map = trait_map.entry(hir_id.owner).or_default();
            map.insert(hir_id.local_id, StableVec::new(v.to_vec()));
        }

        GlobalCtxt {
            sess: s,
            lint_store,
            cstore,
            arena,
            interners,
            dep_graph,
            prof: s.prof.clone(),
            types: common_types,
            lifetimes: common_lifetimes,
            consts: common_consts,
            extern_crate_map: resolutions.extern_crate_map,
            trait_map,
            export_map: resolutions.export_map,
            maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
            maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates,
            glob_map: resolutions.glob_map,
            extern_prelude: resolutions.extern_prelude,
            untracked_crate: krate,
            definitions,
            def_path_hash_to_def_id,
            queries: query::Queries::new(providers, extern_providers, on_disk_query_result_cache),
            ty_rcache: Default::default(),
            pred_rcache: Default::default(),
            selection_cache: Default::default(),
            evaluation_cache: Default::default(),
            crate_name: Symbol::intern(crate_name),
            data_layout,
            layout_interner: Default::default(),
            stability_interner: Default::default(),
            const_stability_interner: Default::default(),
            allocation_interner: Default::default(),
            alloc_map: Lock::new(interpret::AllocMap::new()),
            output_filenames: Arc::new(output_filenames.clone()),
        }
    }
/// Creates 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.
Creates 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.
Creates 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_global_ctxt(
        s: &'tcx Session,
        lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
        local_providers: ty::query::Providers,
        extern_providers: ty::query::Providers,
        arena: &'tcx WorkerLocal<Arena<'tcx>>,
        resolutions: ty::ResolverOutputs,
        krate: &'tcx hir::Crate<'tcx>,
        definitions: &'tcx Definitions,
        dep_graph: DepGraph,
        on_disk_query_result_cache: query::OnDiskCache<'tcx>,
        crate_name: &str,
        output_filenames: &OutputFilenames,
    ) -> GlobalCtxt<'tcx> {
        let data_layout = TargetDataLayout::parse(&s.target.target).unwrap_or_else(|err| {
            s.fatal(&err);
        });
        let interners = CtxtInterners::new(arena);
        let common_types = CommonTypes::new(&interners);
        let common_lifetimes = CommonLifetimes::new(&interners);
        let common_consts = CommonConsts::new(&interners, &common_types);
        let cstore = resolutions.cstore;
        let crates = cstore.crates_untracked();
        let max_cnum = 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;
        let def_path_hash_to_def_id = if s.opts.build_dep_graph() {
            let def_path_tables = crates
                .iter()
                .map(|&cnum| (cnum, cstore.def_path_table(cnum)))
                .chain(iter::once((LOCAL_CRATE, definitions.def_path_table())));
            // Precompute the capacity of the hashmap so we don't have to
            // re-allocate when populating it.
            let capacity = def_path_tables.clone().map(|(_, t)| t.size()).sum::<usize>();
            let mut map: FxHashMap<_, _> =
                FxHashMap::with_capacity_and_hasher(capacity, ::std::default::Default::default());
            for (cnum, def_path_table) in def_path_tables {
                def_path_table.add_def_path_hashes_to(cnum, &mut map);
            }
            Some(map)
        } else {
            None
        };
        let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
        for (hir_id, v) in krate.trait_map.iter() {
            let map = trait_map.entry(hir_id.owner).or_default();
            map.insert(hir_id.local_id, StableVec::new(v.to_vec()));
        }
        GlobalCtxt {
            sess: s,
            lint_store,
            cstore,
            arena,
            interners,
            dep_graph,
            prof: s.prof.clone(),
            types: common_types,
            lifetimes: common_lifetimes,
            consts: common_consts,
            extern_crate_map: resolutions.extern_crate_map,
            trait_map,
            export_map: resolutions.export_map,
            maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
            maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates,
            glob_map: resolutions.glob_map,
            extern_prelude: resolutions.extern_prelude,
            untracked_crate: krate,
            definitions,
            def_path_hash_to_def_id,
            queries: query::Queries::new(providers, extern_providers, on_disk_query_result_cache),
            ty_rcache: Default::default(),
            pred_rcache: Default::default(),
            selection_cache: Default::default(),
            evaluation_cache: Default::default(),
            crate_name: Symbol::intern(crate_name),
            data_layout,
            layout_interner: Default::default(),
            stability_interner: Default::default(),
            const_stability_interner: Default::default(),
            allocation_interner: Default::default(),
            alloc_map: Lock::new(interpret::AllocMap::new()),
            output_filenames: Arc::new(output_filenames.clone()),
        }
    }
pub fn create_global_ctxt ( s : & ' tcx Session , lint_store : Lrc < dyn Any + sync :: Send + sync :: Sync > , local_providers : ty :: query :: Providers , extern_providers : ty :: query :: Providers , arena : & ' tcx WorkerLocal < Arena < ' tcx > > , resolutions : ty :: ResolverOutputs , krate : & ' tcx hir :: Crate < ' tcx > , definitions : & ' tcx Definitions , dep_graph : DepGraph , on_disk_query_result_cache : query :: OnDiskCache < ' tcx > , crate_name : & str , output_filenames : & OutputFilenames , ) -> GlobalCtxt < ' tcx > { let data_layout = TargetDataLayout :: parse ( & s . target . target ) . unwrap_or_else ( | err | { s . fatal ( & err ) ; } ) ; let interners = CtxtInterners :: new ( arena ) ; let common_types = CommonTypes :: new ( & interners ) ; let common_lifetimes = CommonLifetimes :: new ( & interners ) ; let common_consts = CommonConsts :: new ( & interners , & common_types ) ; let cstore = resolutions . cstore ; let crates = cstore . crates_untracked ( ) ; let max_cnum = 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 ; let def_path_hash_to_def_id = if s . opts . build_dep_graph ( ) { let def_path_tables = crates . iter ( ) . map ( | & cnum | ( cnum , cstore . def_path_table ( cnum ) ) ) . chain ( iter :: once ( ( LOCAL_CRATE , definitions . def_path_table ( ) ) ) ) ; // Precompute the capacity of the hashmap so we don't have to // re-allocate when populating it. let capacity = def_path_tables . clone ( ) . map ( | ( _ , t ) | t . size ( ) ) . sum :: < usize > ( ) ; let mut map : FxHashMap < _ , _ > = FxHashMap :: with_capacity_and_hasher ( capacity , :: std :: default :: Default :: default ( ) ) ; for ( cnum , def_path_table ) in def_path_tables { def_path_table . add_def_path_hashes_to ( cnum , & mut map ) ; } Some ( map ) } else { None } ; let mut trait_map : FxHashMap < _ , FxHashMap < _ , _ > > = FxHashMap :: default ( ) ; for ( hir_id , v ) in krate . trait_map . iter ( ) { let map = trait_map . entry ( hir_id . owner ) . or_default ( ) ; map . insert ( hir_id . local_id , StableVec :: new ( v . to_vec ( ) ) ) ; } GlobalCtxt { sess : s , lint_store , cstore , arena , interners , dep_graph , prof : s . prof . clone ( ) , types : common_types , lifetimes : common_lifetimes , consts : common_consts , extern_crate_map : resolutions . extern_crate_map , trait_map , export_map : resolutions . export_map , maybe_unused_trait_imports : resolutions . maybe_unused_trait_imports , maybe_unused_extern_crates : resolutions . maybe_unused_extern_crates , glob_map : resolutions . glob_map , extern_prelude : resolutions . extern_prelude , untracked_crate : krate , definitions , def_path_hash_to_def_id , queries : query :: Queries :: new ( providers , extern_providers , on_disk_query_result_cache ) , ty_rcache : Default :: default ( ) , pred_rcache : Default :: default ( ) , selection_cache : Default :: default ( ) , evaluation_cache : Default :: default ( ) , crate_name : Symbol :: intern ( crate_name ) , data_layout , layout_interner : Default :: default ( ) , stability_interner : Default :: default ( ) , const_stability_interner : Default :: default ( ) , allocation_interner : Default :: default ( ) , alloc_map : Lock :: new ( interpret :: AllocMap :: new ( ) ) , output_filenames : Arc :: new ( output_filenames . clone ( ) ) , } }
Creates a type context and call the closure with a `TyCtxt` reference
to the context.
Creates a type context and call the closure with a ` TyCtxt ` reference to the context .
s
&'tcx Session
lint_store
Lrc<dyn Any + sync::Send + sync::Sync>
local_providers
ty::query::Providers
extern_providers
ty::query::Providers
arena
&'tcx WorkerLocal<Arena<'tcx>>
resolutions
ty::ResolverOutputs
krate
&'tcx hir::Crate<'tcx>
definitions
&'tcx Definitions
dep_graph
DepGraph
on_disk_query_result_cache
query::OnDiskCache<'tcx>
crate_name
&str
output_filenames
&OutputFilenames
s
&'tcx Session
lint_store
Lrc<dyn Any + sync::Send + sync::Sync>
local_providers
ty::query::Providers
extern_providers
ty::query::Providers
arena
&'tcx WorkerLocal<Arena<'tcx>>
resolutions
ty::ResolverOutputs
krate
&'tcx hir::Crate<'tcx>
definitions
&'tcx Definitions
dep_graph
DepGraph
on_disk_query_result_cache
query::OnDiskCache<'tcx>
crate_name
&str
output_filenames
&OutputFilenames