From 260cfaba1259e8551aec02ef4b846900517be8e5 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 25 Mar 2020 08:02:27 +0100 Subject: [PATCH] Don't allow access to the Session. --- Cargo.lock | 1 - src/librustc/ty/query/plumbing.rs | 8 +++++--- src/librustc_query_system/Cargo.toml | 1 - src/librustc_query_system/query/config.rs | 7 +++---- src/librustc_query_system/query/plumbing.rs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0a5bed778e..f61f333b6c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4047,7 +4047,6 @@ dependencies = [ "rustc_errors", "rustc_index", "rustc_macros", - "rustc_session", "rustc_span", "serialize", "smallvec 1.0.0", diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 8cdc1ae27ee..c60fdd2f4fc 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -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 { diff --git a/src/librustc_query_system/Cargo.toml b/src/librustc_query_system/Cargo.toml index 6304e632b51..e1657a8f3c6 100644 --- a/src/librustc_query_system/Cargo.toml +++ b/src/librustc_query_system/Cargo.toml @@ -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"] } diff --git a/src/librustc_query_system/query/config.rs b/src/librustc_query_system/query/config.rs index 106688d2b54..46a48a31161 100644 --- a/src/librustc_query_system/query/config.rs +++ b/src/librustc_query_system/query/config.rs @@ -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; @@ -33,8 +32,8 @@ pub trait QueryConfig { pub trait QueryContext: DepContext { type Query: Clone + HashStable; - /// 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; @@ -101,7 +100,7 @@ where M: QueryAccessors, { 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::(); diff --git a/src/librustc_query_system/query/plumbing.rs b/src/librustc_query_system/query/plumbing.rs index b3187ba9189..97b68042039 100644 --- a/src/librustc_query_system/query/plumbing.rs +++ b/src/librustc_query_system/query/plumbing.rs @@ -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::(tcx, &result, dep_node, dep_node_index); }