File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
compiler/rustc_session/src Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,21 @@ pub enum CoverageLevel {
157
157
Block ,
158
158
/// Also instrument branch points (includes block coverage).
159
159
Branch ,
160
- /// Instrument for MC/DC. Mostly a superset of branch coverage, but might
161
- /// differ in some corner cases.
160
+ /// Same as branch condition, with a single different case:
161
+ /// In boolean expressions that are not inside a control-flow decision,
162
+ /// it will intentionally insert an instrumented branch for the last operand.
163
+ ///
164
+ /// Example:
165
+ /// ```
166
+ /// let x = a && b;
167
+ /// // ^ branch coverage does not track true/false coverage for `b`
168
+ /// // but condition coverage does.
169
+ /// ```
170
+ /// The main purpose of this coverage level is to be reused by MCDC.
171
+ Condition ,
172
+ /// Instrument for MC/DC. Enables condition coverage under the hood.
173
+ /// Mostly a superset of branch coverage, but might differ in some
174
+ /// corner cases.
162
175
Mcdc ,
163
176
}
164
177
Original file line number Diff line number Diff line change @@ -948,6 +948,7 @@ mod parse {
948
948
match option {
949
949
"block" => slot. level = CoverageLevel :: Block ,
950
950
"branch" => slot. level = CoverageLevel :: Branch ,
951
+ "condition" => slot. level = CoverageLevel :: Condition ,
951
952
"mcdc" => slot. level = CoverageLevel :: Mcdc ,
952
953
_ => return false ,
953
954
}
Original file line number Diff line number Diff line change @@ -353,6 +353,11 @@ impl Session {
353
353
&& self . opts . unstable_opts . coverage_options . level >= CoverageLevel :: Branch
354
354
}
355
355
356
+ pub fn instrument_coverage_condition ( & self ) -> bool {
357
+ self . instrument_coverage ( )
358
+ && self . opts . unstable_opts . coverage_options . level >= CoverageLevel :: Condition
359
+ }
360
+
356
361
pub fn instrument_coverage_mcdc ( & self ) -> bool {
357
362
self . instrument_coverage ( )
358
363
&& self . opts . unstable_opts . coverage_options . level >= CoverageLevel :: Mcdc
You can’t perform that action at this time.
0 commit comments