Skip to content

Commit f96e960

Browse files
committed
Access the session directly from DepContext.
1 parent 83b30a6 commit f96e960

File tree

9 files changed

+21
-40
lines changed

9 files changed

+21
-40
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,6 +4203,7 @@ dependencies = [
42034203
"rustc_index",
42044204
"rustc_macros",
42054205
"rustc_serialize",
4206+
"rustc_session",
42064207
"rustc_span",
42074208
"smallvec 1.6.1",
42084209
"tracing",

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::ich::StableHashingContext;
22
use crate::ty::{self, TyCtxt};
33
use rustc_data_structures::profiling::SelfProfilerRef;
44
use rustc_data_structures::sync::Lock;
5+
use rustc_session::Session;
56

67
#[macro_use]
78
mod dep_node;
@@ -101,20 +102,18 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
101102
TyCtxt::create_stable_hashing_context(*self)
102103
}
103104

104-
fn debug_dep_tasks(&self) -> bool {
105-
self.sess.opts.debugging_opts.dep_tasks
106-
}
107-
fn debug_dep_node(&self) -> bool {
108-
self.sess.opts.debugging_opts.incremental_info
109-
|| self.sess.opts.debugging_opts.query_dep_graph
110-
}
111-
112105
#[inline]
113106
fn dep_graph(&self) -> &DepGraph {
114107
&self.dep_graph
115108
}
116109

110+
#[inline(always)]
117111
fn profiler(&self) -> &SelfProfilerRef {
118112
&self.prof
119113
}
114+
115+
#[inline(always)]
116+
fn sess(&self) -> &Session {
117+
self.sess
118+
}
120119
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ impl HasDepContext for QueryCtxt<'tcx> {
4747
impl QueryContext for QueryCtxt<'tcx> {
4848
type Query = Query<'tcx>;
4949

50-
fn incremental_verify_ich(&self) -> bool {
51-
self.sess.opts.debugging_opts.incremental_verify_ich
52-
}
53-
fn verbose(&self) -> bool {
54-
self.sess.verbose()
55-
}
56-
5750
fn def_path_str(&self, def_id: DefId) -> String {
5851
self.tcx.def_path_str(def_id)
5952
}
@@ -132,14 +125,6 @@ impl QueryContext for QueryCtxt<'tcx> {
132125
(cb.force_from_dep_node)(*self, dep_node)
133126
}
134127

135-
fn has_errors_or_delayed_span_bugs(&self) -> bool {
136-
self.sess.has_errors_or_delayed_span_bugs()
137-
}
138-
139-
fn diagnostic(&self) -> &rustc_errors::Handler {
140-
self.sess.diagnostic()
141-
}
142-
143128
// Interactions with on_disk_cache
144129
fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic> {
145130
self.on_disk_cache

compiler/rustc_query_system/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustc_errors = { path = "../rustc_errors" }
1616
rustc_macros = { path = "../rustc_macros" }
1717
rustc_index = { path = "../rustc_index" }
1818
rustc_serialize = { path = "../rustc_serialize" }
19+
rustc_session = { path = "../rustc_session" }
1920
rustc_span = { path = "../rustc_span" }
2021
parking_lot = "0.11"
2122
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }

compiler/rustc_query_system/src/dep_graph/dep_node.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ impl<K: DepKind> DepNode<K> {
8787

8888
#[cfg(debug_assertions)]
8989
{
90-
if !kind.can_reconstruct_query_key() && tcx.debug_dep_node() {
90+
if !kind.can_reconstruct_query_key()
91+
&& (tcx.sess().opts.debugging_opts.incremental_info
92+
|| tcx.sess().opts.debugging_opts.query_dep_graph)
93+
{
9194
tcx.dep_graph().register_dep_node_debug_str(dep_node, || arg.to_debug_str(tcx));
9295
}
9396
}

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<K: DepKind> DepGraph<K> {
280280
let mut hcx = dcx.create_stable_hashing_context();
281281
let current_fingerprint = hash_result(&mut hcx, &result);
282282

283-
let print_status = cfg!(debug_assertions) && dcx.debug_dep_tasks();
283+
let print_status = cfg!(debug_assertions) && dcx.sess().opts.debugging_opts.dep_tasks;
284284

285285
// Intern the new `DepNode`.
286286
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> {
731731
return None;
732732
}
733733
None => {
734-
if !tcx.has_errors_or_delayed_span_bugs() {
734+
if !tcx.dep_context().sess().has_errors_or_delayed_span_bugs() {
735735
panic!(
736736
"try_mark_previous_green() - Forcing the DepNode \
737737
should have set its color"
@@ -835,7 +835,7 @@ impl<K: DepKind> DepGraph<K> {
835835
// Promote the previous diagnostics to the current session.
836836
tcx.store_diagnostics(dep_node_index, diagnostics.clone().into());
837837

838-
let handle = tcx.diagnostic();
838+
let handle = tcx.dep_context().sess().diagnostic();
839839

840840
for diagnostic in diagnostics {
841841
handle.emit_diagnostic(&diagnostic);

compiler/rustc_query_system/src/dep_graph/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
1313

1414
use rustc_data_structures::profiling::SelfProfilerRef;
1515
use rustc_data_structures::sync::Lock;
16+
use rustc_session::Session;
1617

1718
use std::fmt;
1819
use std::hash::Hash;
@@ -24,16 +25,16 @@ pub trait DepContext: Copy {
2425
/// Create a hashing context for hashing new results.
2526
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
2627

27-
fn debug_dep_tasks(&self) -> bool;
28-
fn debug_dep_node(&self) -> bool;
29-
3028
/// Access the DepGraph.
3129
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
3230

3331
fn register_reused_dep_node(&self, dep_node: &DepNode<Self::DepKind>);
3432

3533
/// Access the profiler.
3634
fn profiler(&self) -> &SelfProfilerRef;
35+
36+
/// Access the compiler session.
37+
fn sess(&self) -> &Session;
3738
}
3839

3940
pub trait HasDepContext: Copy {

compiler/rustc_query_system/src/query/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use rustc_span::def_id::DefId;
2626
pub trait QueryContext: HasDepContext {
2727
type Query: Clone + HashStable<Self::StableHashingContext>;
2828

29-
fn incremental_verify_ich(&self) -> bool;
30-
fn verbose(&self) -> bool;
31-
3229
/// Get string representation from DefPath.
3330
fn def_path_str(&self, def_id: DefId) -> String;
3431

@@ -43,12 +40,6 @@ pub trait QueryContext: HasDepContext {
4340
/// Try to force a dep node to execute and see if it's green.
4441
fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
4542

46-
/// Return whether the current session is tainted by errors.
47-
fn has_errors_or_delayed_span_bugs(&self) -> bool;
48-
49-
/// Return the diagnostic handler.
50-
fn diagnostic(&self) -> &rustc_errors::Handler;
51-
5243
/// Load diagnostics associated to the node in the previous session.
5344
fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>;
5445

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ where
550550

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

0 commit comments

Comments
 (0)