self.global_arenas.adt_def.alloc(def)
}
- pub fn alloc_byte_array(self, bytes: &[u8]) -> &'gcx [u8] {
- if bytes.is_empty() {
- &[]
- } else {
- self.global_interners.arena.alloc_slice(bytes)
- }
- }
-
pub fn intern_const_alloc(
self,
alloc: Allocation,
sync::assert_send_val(&gcx);
- tls::enter_global(gcx, f)
+ let r = tls::enter_global(gcx, f);
+
+ gcx.queries.record_computed_queries(s);
+
+ r
}
pub fn consider_optimizing<T: Fn() -> String>(&self, msg: T) -> bool {
let new_icx = ty::tls::ImplicitCtxt {
tcx,
query: icx.query.clone(),
+ diagnostics: icx.diagnostics,
layout_depth: icx.layout_depth,
- task: icx.task,
+ task_deps: icx.task_deps,
};
ty::tls::enter_context(&new_icx, |_| {
f(tcx)
impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
type Lifted = &'tcx mir::interpret::Allocation;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
- assert!(tcx.global_interners.arena.in_arena(*self as *const _));
+ assert!(tcx.global_arenas.const_allocs.in_arena(*self as *const _));
Some(unsafe { mem::transmute(*self) })
}
}
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
use rustc_data_structures::OnDrop;
use rustc_data_structures::sync::{self, Lrc, Lock};
- use dep_graph::OpenTask;
+ use rustc_data_structures::thin_vec::ThinVec;
+ use dep_graph::TaskDeps;
#[cfg(not(parallel_queries))]
use std::cell::Cell;
/// by `enter_local` with a new local interner
pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
- /// The current query job, if any. This is updated by start_job in
+ /// The current query job, if any. This is updated by JobOwner::start in
/// ty::query::plumbing when executing a query
pub query: Option<Lrc<query::QueryJob<'gcx>>>,
+ /// Where to store diagnostics for the current query job, if any.
+ /// This is updated by JobOwner::start in ty::query::plumbing when executing a query
+ pub diagnostics: Option<&'a Lock<ThinVec<Diagnostic>>>,
+
/// Used to prevent layout from recursing too deeply.
pub layout_depth: usize,
/// The current dep graph task. This is used to add dependencies to queries
/// when executing them
- pub task: &'a OpenTask,
+ pub task_deps: Option<&'a Lock<TaskDeps>>,
}
/// Sets Rayon's thread local variable which is preserved for Rayon jobs
fn track_diagnostic(diagnostic: &Diagnostic) {
with_context_opt(|icx| {
if let Some(icx) = icx {
- if let Some(ref query) = icx.query {
- query.diagnostics.lock().push(diagnostic.clone());
+ if let Some(ref diagnostics) = icx.diagnostics {
+ let mut diagnostics = diagnostics.lock();
+ diagnostics.extend(Some(diagnostic.clone()));
}
}
})
let icx = ImplicitCtxt {
tcx,
query: None,
+ diagnostics: None,
layout_depth: 0,
- task: &OpenTask::Ignore,
+ task_deps: None,
};
enter_context(&icx, |_| {
f(tcx)
};
let icx = ImplicitCtxt {
query: None,
+ diagnostics: None,
tcx,
layout_depth: 0,
- task: &OpenTask::Ignore,
+ task_deps: None,
};
enter_context(&icx, |_| f(tcx))
}
}
pub fn provide(providers: &mut ty::query::Providers<'_>) {
- // FIXME(#44234): almost all of these queries have no sub-queries and
- // therefore no actual inputs, they're just reading tables calculated in
- // resolve! Does this work? Unsure! That's what the issue is about.
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id).cloned();
providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).cloned();
providers.crate_name = |tcx, id| {