Skip to content

Commit

Permalink
Don't allow access to the Session.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 26, 2020
1 parent d224e21 commit 260cfab
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4047,7 +4047,6 @@ dependencies = [
"rustc_errors",
"rustc_index",
"rustc_macros",
"rustc_session",
"rustc_span",
"serialize",
"smallvec 1.0.0",
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, Handler, Level};
use rustc_session::Session;
use rustc_span::def_id::DefId;
use rustc_span::Span;

impl QueryContext for TyCtxt<'tcx> {
type Query = Query<'tcx>;

fn session(&self) -> &Session {
&self.sess
fn incremental_verify_ich(&self) -> bool {
self.sess.opts.debugging_opts.incremental_verify_ich
}
fn verbose(&self) -> bool {
self.sess.verbose()
}

fn def_path_str(&self, def_id: DefId) -> String {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_query_system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ rustc_errors = { path = "../librustc_errors" }
rustc_index = { path = "../librustc_index" }
rustc_macros = { path = "../librustc_macros" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_session = { path = "../librustc_session" }
rustc_span = { path = "../librustc_span" }
parking_lot = "0.9"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
7 changes: 3 additions & 4 deletions src/librustc_query_system/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use rustc_data_structures::stable_hasher::HashStable;
use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::Diagnostic;
use rustc_session::Session;
use std::borrow::Cow;
use std::fmt::Debug;
use std::hash::Hash;
Expand All @@ -33,8 +32,8 @@ pub trait QueryConfig<CTX> {
pub trait QueryContext: DepContext {
type Query: Clone + HashStable<Self::StableHashingContext>;

/// Access the session.
fn session(&self) -> &Session;
fn incremental_verify_ich(&self) -> bool;
fn verbose(&self) -> bool;

/// Get string representation from DefPath.
fn def_path_str(&self, def_id: DefId) -> String;
Expand Down Expand Up @@ -101,7 +100,7 @@ where
M: QueryAccessors<CTX, Key = DefId>,
{
default fn describe(tcx: CTX, def_id: DefId) -> Cow<'static, str> {
if !tcx.session().verbose() {
if !tcx.verbose() {
format!("processing `{}`", tcx.def_path_str(def_id)).into()
} else {
let name = ::std::any::type_name::<M>();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_query_system/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,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.session().opts.debugging_opts.incremental_verify_ich) {
if unlikely!(tcx.incremental_verify_ich()) {
incremental_verify_ich::<Q, _>(tcx, &result, dep_node, dep_node_index);
}

Expand Down

0 comments on commit 260cfab

Please sign in to comment.