From 658e745071fb093b6fe13b034b92ab24ae988df1 Mon Sep 17 00:00:00 2001 From: pierwill Date: Mon, 13 Dec 2021 11:33:30 -0600 Subject: [PATCH 1/3] Make top level session option fields private --- compiler/rustc_session/src/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index a6506dbad1600..ac4413163d1df 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -68,7 +68,7 @@ macro_rules! top_level_options { pub struct Options { $( $( #[$attr] )* - pub $opt: $t + $opt: $t ),* } From e672c3ec69a7974b3b54b4f1261dfa546359036b Mon Sep 17 00:00:00 2001 From: pierwill Date: Wed, 16 Mar 2022 14:57:44 -0500 Subject: [PATCH 2/3] idea: add get_incremental method --- compiler/rustc_session/src/options.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index ac4413163d1df..5ca63a81ce880 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -121,6 +121,10 @@ impl Options { self.cg.instrument_coverage.unwrap_or(InstrumentCoverage::Off) == InstrumentCoverage::ExceptUnusedFunctions } + + pub fn get_incremental(&self) -> Option { + self.incremental + } } top_level_options!( From 6e4071881aa98ec7df1f769be26f0b188102b956 Mon Sep 17 00:00:00 2001 From: pierwill Date: Wed, 16 Mar 2022 14:58:09 -0500 Subject: [PATCH 3/3] use a getter method --- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_session/src/session.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 1d36ff059de81..00755dc39f1c0 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -809,7 +809,7 @@ impl Default for Options { impl Options { /// Returns `true` if there is a reason to build the dep graph. pub fn build_dep_graph(&self) -> bool { - self.incremental.is_some() + self.get_incremental().is_some() || self.debugging_opts.dump_dep_graph || self.debugging_opts.query_dep_graph } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index eabebfcf3eae5..ee08e0c29d720 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -865,7 +865,7 @@ impl Session { } pub fn incr_comp_session_dir_opt(&self) -> Option> { - self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir()) + self.opts.get_incremental().as_ref().map(|_| self.incr_comp_session_dir()) } pub fn print_perf_stats(&self) { @@ -937,7 +937,7 @@ impl Session { // If incremental compilation is turned on, we default to a high number // codegen units in order to reduce the "collateral damage" small // changes cause. - if self.opts.incremental.is_some() { + if self.opts.get_incremental().is_some() { return 256; }