diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-10-31 14:43:23 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-12-14 14:24:35 +0000 |
| commit | 6ece8036329ac01eca7724c3b4b691b258d04e16 (patch) | |
| tree | 999f31984013365fba76f1f7c73f9f995e780d92 /compiler/rustc_interface/src/passes.rs | |
| parent | ed141926048597e3649bb238ca3dc417904cd56c (diff) | |
| download | rust-6ece8036329ac01eca7724c3b4b691b258d04e16.tar.gz rust-6ece8036329ac01eca7724c3b4b691b258d04e16.zip | |
Get rid of of the global_ctxt query
Diffstat (limited to 'compiler/rustc_interface/src/passes.rs')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 430bc7db077..dea434b556b 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -41,7 +41,7 @@ use tracing::{info, instrument}; use crate::interface::Compiler; use crate::{errors, proc_macro_decls, util}; -pub(crate) fn parse<'a>(sess: &'a Session) -> ast::Crate { +pub fn parse<'a>(sess: &'a Session) -> ast::Crate { let krate = sess .time("parse_crate", || { let mut parser = unwrap_or_emit_fatal(match &sess.io.input { @@ -709,7 +709,22 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| { *providers }); -pub(crate) fn create_global_ctxt<'tcx>( +pub fn create_and_enter_global_ctxt<'tcx, T>( + compiler: &'tcx Compiler, + krate: rustc_ast::Crate, + f: impl for<'a> FnOnce(TyCtxt<'a>) -> T, +) -> T { + let gcx_cell = OnceLock::new(); + let arena = WorkerLocal::new(|_| Arena::default()); + let hir_arena = WorkerLocal::new(|_| rustc_hir::Arena::default()); + + let gcx = create_global_ctxt(compiler, krate, &gcx_cell, &arena, &hir_arena); + let ret = gcx.enter(f); + gcx.finish(); + ret +} + +fn create_global_ctxt<'tcx>( compiler: &'tcx Compiler, mut krate: rustc_ast::Crate, gcx_cell: &'tcx OnceLock<GlobalCtxt<'tcx>>, |
