Access the session directly from DepContext.

This commit is contained in:
Camille GILLOT 2020-11-12 20:48:37 +01:00
parent 83b30a639d
commit f96e960ccf
9 changed files with 21 additions and 40 deletions

View file

@ -87,7 +87,10 @@ impl<K: DepKind> DepNode<K> {
#[cfg(debug_assertions)]
{
if !kind.can_reconstruct_query_key() && tcx.debug_dep_node() {
if !kind.can_reconstruct_query_key()
&& (tcx.sess().opts.debugging_opts.incremental_info
|| tcx.sess().opts.debugging_opts.query_dep_graph)
{
tcx.dep_graph().register_dep_node_debug_str(dep_node, || arg.to_debug_str(tcx));
}
}

View file

@ -280,7 +280,7 @@ impl<K: DepKind> DepGraph<K> {
let mut hcx = dcx.create_stable_hashing_context();
let current_fingerprint = hash_result(&mut hcx, &result);
let print_status = cfg!(debug_assertions) && dcx.debug_dep_tasks();
let print_status = cfg!(debug_assertions) && dcx.sess().opts.debugging_opts.dep_tasks;
// Intern the new `DepNode`.
let dep_node_index = if let Some(prev_index) = data.previous.node_to_index_opt(&key) {
@ -731,7 +731,7 @@ impl<K: DepKind> DepGraph<K> {
return None;
}
None => {
if !tcx.has_errors_or_delayed_span_bugs() {
if !tcx.dep_context().sess().has_errors_or_delayed_span_bugs() {
panic!(
"try_mark_previous_green() - Forcing the DepNode \
should have set its color"
@ -835,7 +835,7 @@ impl<K: DepKind> DepGraph<K> {
// Promote the previous diagnostics to the current session.
tcx.store_diagnostics(dep_node_index, diagnostics.clone().into());
let handle = tcx.diagnostic();
let handle = tcx.dep_context().sess().diagnostic();
for diagnostic in diagnostics {
handle.emit_diagnostic(&diagnostic);

View file

@ -13,6 +13,7 @@ pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sync::Lock;
use rustc_session::Session;
use std::fmt;
use std::hash::Hash;
@ -24,9 +25,6 @@ pub trait DepContext: Copy {
/// Create a hashing context for hashing new results.
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
fn debug_dep_tasks(&self) -> bool;
fn debug_dep_node(&self) -> bool;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
@ -34,6 +32,9 @@ pub trait DepContext: Copy {
/// Access the profiler.
fn profiler(&self) -> &SelfProfilerRef;
/// Access the compiler session.
fn sess(&self) -> &Session;
}
pub trait HasDepContext: Copy {

View file

@ -26,9 +26,6 @@ use rustc_span::def_id::DefId;
pub trait QueryContext: HasDepContext {
type Query: Clone + HashStable<Self::StableHashingContext>;
fn incremental_verify_ich(&self) -> bool;
fn verbose(&self) -> bool;
/// Get string representation from DefPath.
fn def_path_str(&self, def_id: DefId) -> String;
@ -43,12 +40,6 @@ pub trait QueryContext: HasDepContext {
/// Try to force a dep node to execute and see if it's green.
fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
/// Return whether the current session is tainted by errors.
fn has_errors_or_delayed_span_bugs(&self) -> bool;
/// Return the diagnostic handler.
fn diagnostic(&self) -> &rustc_errors::Handler;
/// Load diagnostics associated to the node in the previous session.
fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>;

View file

@ -550,7 +550,7 @@ where
// If `-Zincremental-verify-ich` is specified, re-hash results from
// the cache and make sure that they have the expected fingerprint.
if unlikely!(tcx.incremental_verify_ich()) {
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query);
}