Skip to content

Commit f496e83

Browse files
committed
coverage: Simplify access to debug/testing -Zcoverage-options flags
1 parent fb39d3e commit f496e83

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn fill_region_tables<'tcx>(
131131
// codegen needs to handle that gracefully to avoid #133606.
132132
// It's hard for tests to trigger this organically, so instead we set
133133
// `-Zcoverage-options=discard-all-spans-in-codegen` to force it to occur.
134-
let discard_all = tcx.sess.coverage_discard_all_spans_in_codegen();
134+
let discard_all = tcx.sess.coverage_options().discard_all_spans_in_codegen;
135135
let make_coords = |span: Span| {
136136
if discard_all { None } else { spans::make_coords(source_map, &source_file, span) }
137137
};

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ pub enum InstrumentCoverage {
182182
pub struct CoverageOptions {
183183
pub level: CoverageLevel,
184184

185+
/// **(internal test-only flag)**
185186
/// `-Zcoverage-options=discard-all-spans-in-codegen`: During codegen,
186187
/// discard all coverage spans as though they were invalid. Needed by
187188
/// regression tests for #133606, because we don't have an easy way to

compiler/rustc_session/src/session.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use rustc_target::spec::{
3939
use crate::code_stats::CodeStats;
4040
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
4141
use crate::config::{
42-
self, CoverageLevel, CrateType, DebugInfo, ErrorOutputType, FunctionReturn, Input,
43-
InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
42+
self, CoverageLevel, CoverageOptions, CrateType, DebugInfo, ErrorOutputType, FunctionReturn,
43+
Input, InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
4444
SwitchWithOptPath,
4545
};
4646
use crate::filesearch::FileSearch;
@@ -359,9 +359,11 @@ impl Session {
359359
&& self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Mcdc
360360
}
361361

362-
/// True if `-Zcoverage-options=discard-all-spans-in-codegen` was passed.
363-
pub fn coverage_discard_all_spans_in_codegen(&self) -> bool {
364-
self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen
362+
/// Provides direct access to the `CoverageOptions` struct, so that
363+
/// individual flags for debugging/testing coverage instrumetation don't
364+
/// need separate accessors.
365+
pub fn coverage_options(&self) -> &CoverageOptions {
366+
&self.opts.unstable_opts.coverage_options
365367
}
366368

367369
pub fn is_sanitizer_cfi_enabled(&self) -> bool {

0 commit comments

Comments
 (0)