From ead78fdfdf6692b2ecef7f47dfc934011c51fe4c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:40:36 +0000 Subject: Remove jobserver from Session It is effectively a global resource and the jobserver::Client in Session was a clone of GLOBAL_CLIENT anyway. --- compiler/rustc_session/src/session.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 993d111466b..160525cead0 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -8,7 +8,6 @@ use std::{env, fmt, io}; use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; -use rustc_data_structures::jobserver::{self, Client}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; use rustc_data_structures::sync::{ DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock, @@ -154,10 +153,6 @@ pub struct Session { /// Data about code being compiled, gathered during compilation. pub code_stats: CodeStats, - /// Loaded up early on in the initialization of this `Session` to avoid - /// false positives about a job server in our environment. - pub jobserver: Client, - /// This only ever stores a `LintStore` but we don't want a dependency on that type here. pub lint_store: Option>, @@ -1072,7 +1067,6 @@ pub fn build_session( incr_comp_session: RwLock::new(IncrCompSession::NotInitialized), prof, code_stats: Default::default(), - jobserver: jobserver::client(), lint_store: None, registered_lints: false, driver_lint_caps, -- cgit 1.4.1-3-g733a5 From 981f625ba7c8e8ddcf6e470eb54d822eaf9fb300 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:45:10 +0000 Subject: Remove registered_lints field from Session It only exists to pass some information from one part of the driver to another part. We can directly pass this information to the function that needs it to reduce the amount of mutation of the Session. --- compiler/rustc_driver_impl/src/lib.rs | 8 +++++--- compiler/rustc_interface/src/interface.rs | 1 - compiler/rustc_session/src/session.rs | 4 ---- src/librustdoc/lib.rs | 4 +++- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 2e01c385a66..b8d5281087e 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -350,6 +350,8 @@ fn run_compiler( callbacks.config(&mut config); + let registered_lints = config.register_lints.is_some(); + interface::run_compiler(config, |compiler| { let sess = &compiler.sess; let codegen_backend = &*compiler.codegen_backend; @@ -365,7 +367,7 @@ fn run_compiler( // `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because // it must happen after lints are registered, during session creation. if sess.opts.describe_lints { - describe_lints(sess); + describe_lints(sess, registered_lints); return early_exit(); } @@ -982,7 +984,7 @@ the command line flag directly. } /// Write to stdout lint command options, together with a list of all available lints -pub fn describe_lints(sess: &Session) { +pub fn describe_lints(sess: &Session, registered_lints: bool) { safe_println!( " Available lint options: @@ -1086,7 +1088,7 @@ Available lint options: print_lint_groups(builtin_groups, true); - match (sess.registered_lints, loaded.len(), loaded_groups.len()) { + match (registered_lints, loaded.len(), loaded_groups.len()) { (false, 0, _) | (false, _, 0) => { safe_println!("Lint tools like Clippy can load additional lints and lint groups."); } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 07ae24ee6d3..7ad893f61ab 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -479,7 +479,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); if let Some(register_lints) = config.register_lints.as_deref() { register_lints(&sess, &mut lint_store); - sess.registered_lints = true; } sess.lint_store = Some(Lrc::new(lint_store)); diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 160525cead0..9f6106f9cfb 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -156,9 +156,6 @@ pub struct Session { /// This only ever stores a `LintStore` but we don't want a dependency on that type here. pub lint_store: Option>, - /// Should be set if any lints are registered in `lint_store`. - pub registered_lints: bool, - /// Cap lint level specified by a driver specifically. pub driver_lint_caps: FxHashMap, @@ -1068,7 +1065,6 @@ pub fn build_session( prof, code_stats: Default::default(), lint_store: None, - registered_lints: false, driver_lint_caps, ctfe_backtrace, miri_unleashed_features: Lock::new(Default::default()), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a384c286039..5d82b8e309a 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -846,11 +846,13 @@ fn main_args( let config = core::create_config(input, options, &render_options, using_internal_features); + let registered_lints = config.register_lints.is_some(); + interface::run_compiler(config, |compiler| { let sess = &compiler.sess; if sess.opts.describe_lints { - rustc_driver::describe_lints(sess); + rustc_driver::describe_lints(sess, registered_lints); return; } -- cgit 1.4.1-3-g733a5