Skip to content

Commit 7fecc3a

Browse files
Move instrument coverage config getters to Options
1 parent a68202d commit 7fecc3a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ impl Options {
107107
.mir_opt_level
108108
.unwrap_or_else(|| if self.optimize != OptLevel::No { 2 } else { 1 })
109109
}
110+
111+
pub fn instrument_coverage(&self) -> bool {
112+
self.debugging_opts.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
113+
!= InstrumentCoverage::Off
114+
}
115+
116+
pub fn instrument_coverage_except_unused_generics(&self) -> bool {
117+
self.debugging_opts.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
118+
== InstrumentCoverage::ExceptUnusedGenerics
119+
}
120+
121+
pub fn instrument_coverage_except_unused_functions(&self) -> bool {
122+
self.debugging_opts.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
123+
== InstrumentCoverage::ExceptUnusedFunctions
124+
}
110125
}
111126

112127
top_level_options!(

compiler/rustc_session/src/session.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,18 +1044,15 @@ impl Session {
10441044
}
10451045

10461046
pub fn instrument_coverage(&self) -> bool {
1047-
self.opts.debugging_opts.instrument_coverage.unwrap_or(config::InstrumentCoverage::Off)
1048-
!= config::InstrumentCoverage::Off
1047+
self.opts.instrument_coverage()
10491048
}
10501049

10511050
pub fn instrument_coverage_except_unused_generics(&self) -> bool {
1052-
self.opts.debugging_opts.instrument_coverage.unwrap_or(config::InstrumentCoverage::Off)
1053-
== config::InstrumentCoverage::ExceptUnusedGenerics
1051+
self.opts.instrument_coverage_except_unused_generics()
10541052
}
10551053

10561054
pub fn instrument_coverage_except_unused_functions(&self) -> bool {
1057-
self.opts.debugging_opts.instrument_coverage.unwrap_or(config::InstrumentCoverage::Off)
1058-
== config::InstrumentCoverage::ExceptUnusedFunctions
1055+
self.opts.instrument_coverage_except_unused_functions()
10591056
}
10601057

10611058
pub fn is_proc_macro_attr(&self, attr: &Attribute) -> bool {

0 commit comments

Comments
 (0)