Skip to content

Commit 85fc539

Browse files
committed
Access the session directly from DepContext.
1 parent d23e084 commit 85fc539

File tree

9 files changed

+22
-41
lines changed

9 files changed

+22
-41
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,6 +4084,7 @@ dependencies = [
40844084
"rustc_index",
40854085
"rustc_macros",
40864086
"rustc_serialize",
4087+
"rustc_session",
40874088
"rustc_span",
40884089
"smallvec 1.4.2",
40894090
"tracing",

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_data_structures::sync::Lock;
66
use rustc_data_structures::thin_vec::ThinVec;
77
use rustc_errors::Diagnostic;
88
use rustc_hir::def_id::{DefPathHash, LocalDefId};
9+
use rustc_session::Session;
910

1011
mod dep_node;
1112

@@ -101,12 +102,14 @@ 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
105+
#[inline(always)]
106+
fn profiler(&self) -> &SelfProfilerRef {
107+
&self.prof
106108
}
107-
fn debug_dep_node(&self) -> bool {
108-
self.sess.opts.debugging_opts.incremental_info
109-
|| self.sess.opts.debugging_opts.query_dep_graph
109+
110+
#[inline(always)]
111+
fn sess(&self) -> &Session {
112+
self.sess
110113
}
111114

112115
fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool {
@@ -156,14 +159,6 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
156159
ty::query::force_from_dep_node(*self, dep_node)
157160
}
158161

159-
fn has_errors_or_delayed_span_bugs(&self) -> bool {
160-
self.sess.has_errors_or_delayed_span_bugs()
161-
}
162-
163-
fn diagnostic(&self) -> &rustc_errors::Handler {
164-
self.sess.diagnostic()
165-
}
166-
167162
// Interactions with on_disk_cache
168163
fn try_load_from_on_disk_cache(&self, dep_node: &DepNode) {
169164
try_load_from_on_disk_cache(*self, dep_node)
@@ -192,10 +187,6 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
192187
c.store_diagnostics_for_anon_node(dep_node_index, diagnostics)
193188
}
194189
}
195-
196-
fn profiler(&self) -> &SelfProfilerRef {
197-
&self.prof
198-
}
199190
}
200191

201192
fn def_id_corresponds_to_hir_dep_node(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {

compiler/rustc_middle/src/ty/query/plumbing.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ use rustc_span::Span;
1919
impl QueryContext for TyCtxt<'tcx> {
2020
type Query = Query<'tcx>;
2121

22-
fn incremental_verify_ich(&self) -> bool {
23-
self.sess.opts.debugging_opts.incremental_verify_ich
24-
}
25-
fn verbose(&self) -> bool {
26-
self.sess.verbose()
27-
}
28-
2922
fn def_path_str(&self, def_id: DefId) -> String {
3023
TyCtxt::def_path_str(*self, def_id)
3124
}

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.0", 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
@@ -88,7 +88,10 @@ impl<K: DepKind> DepNode<K> {
8888

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

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<K: DepKind> DepGraph<K> {
258258
task_deps.map(|lock| lock.into_inner()),
259259
);
260260

261-
let print_status = cfg!(debug_assertions) && cx.debug_dep_tasks();
261+
let print_status = cfg!(debug_assertions) && cx.sess().opts.debugging_opts.dep_tasks;
262262

263263
// Determine the color of the new DepNode.
264264
if let Some(prev_index) = data.previous.node_to_index_opt(&key) {
@@ -645,7 +645,7 @@ impl<K: DepKind> DepGraph<K> {
645645
return None;
646646
}
647647
None => {
648-
if !tcx.has_errors_or_delayed_span_bugs() {
648+
if !tcx.sess().has_errors_or_delayed_span_bugs() {
649649
panic!(
650650
"try_mark_previous_green() - Forcing the DepNode \
651651
should have set its color"
@@ -753,7 +753,7 @@ impl<K: DepKind> DepGraph<K> {
753753
// Promote the previous diagnostics to the current session.
754754
tcx.store_diagnostics(dep_node_index, diagnostics.clone().into());
755755

756-
let handle = tcx.diagnostic();
756+
let handle = tcx.sess().diagnostic();
757757

758758
for diagnostic in diagnostics {
759759
handle.emit_diagnostic(&diagnostic);

compiler/rustc_query_system/src/dep_graph/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
1515
use rustc_data_structures::sync::Lock;
1616
use rustc_data_structures::thin_vec::ThinVec;
1717
use rustc_errors::Diagnostic;
18+
use rustc_session::Session;
1819
use rustc_span::def_id::DefPathHash;
1920

2021
use std::fmt;
@@ -27,20 +28,11 @@ pub trait DepContext: Copy {
2728
/// Create a hashing context for hashing new results.
2829
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
2930

30-
fn debug_dep_tasks(&self) -> bool;
31-
fn debug_dep_node(&self) -> bool;
32-
3331
/// Try to force a dep node to execute and see if it's green.
3432
fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
3533

3634
fn register_reused_dep_path_hash(&self, hash: DefPathHash);
3735

38-
/// Return whether the current session is tainted by errors.
39-
fn has_errors_or_delayed_span_bugs(&self) -> bool;
40-
41-
/// Return the diagnostic handler.
42-
fn diagnostic(&self) -> &rustc_errors::Handler;
43-
4436
/// Load data from the on-disk cache.
4537
fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>);
4638

@@ -59,6 +51,9 @@ pub trait DepContext: Copy {
5951

6052
/// Access the profiler.
6153
fn profiler(&self) -> &SelfProfilerRef;
54+
55+
/// Access the compiler session.
56+
fn sess(&self) -> &Session;
6257
}
6358

6459
/// Describe the different families of dependency nodes.

compiler/rustc_query_system/src/query/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use rustc_span::def_id::DefId;
2626
pub trait QueryContext: DepContext {
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

compiler/rustc_query_system/src/query/plumbing.rs

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

531531
// If `-Zincremental-verify-ich` is specified, re-hash results from
532532
// the cache and make sure that they have the expected fingerprint.
533-
if unlikely!(tcx.incremental_verify_ich()) {
533+
if unlikely!(tcx.sess().opts.debugging_opts.incremental_verify_ich) {
534534
incremental_verify_ich(tcx, &result, dep_node, dep_node_index, query);
535535
}
536536

0 commit comments

Comments
 (0)