File tree 3 files changed +24
-2
lines changed
compiler/rustc_session/src
3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -159,8 +159,24 @@ pub enum CoverageLevel {
159
159
Block ,
160
160
/// Also instrument branch points (includes block coverage).
161
161
Branch ,
162
- /// Instrument for MC/DC. Mostly a superset of branch coverage, but might
163
- /// differ in some corner cases.
162
+ /// Same as branch condition, with a single different case:
163
+ /// In boolean expressions that are not inside a control-flow decision,
164
+ /// it will intentionally insert an instrumented branch for the last operand.
165
+ ///
166
+ /// Example:
167
+ /// ```
168
+ /// # let (a, b) = (false, true);
169
+ /// let x = a && b;
170
+ /// // ^ last operand
171
+ /// ```
172
+ /// Condition coverage does track true/false coverage for `b`,
173
+ /// but branch coverage doesn't.
174
+ ///
175
+ /// The main purpose of this coverage level is to be reused by MCDC.
176
+ Condition ,
177
+ /// Instrument for MC/DC. Enables condition coverage under the hood.
178
+ /// Mostly a superset of branch coverage, but might differ in some
179
+ /// corner cases.
164
180
Mcdc ,
165
181
}
166
182
Original file line number Diff line number Diff line change @@ -961,6 +961,7 @@ mod parse {
961
961
match option {
962
962
"block" => slot. level = CoverageLevel :: Block ,
963
963
"branch" => slot. level = CoverageLevel :: Branch ,
964
+ "condition" => slot. level = CoverageLevel :: Condition ,
964
965
"mcdc" => slot. level = CoverageLevel :: Mcdc ,
965
966
_ => return false ,
966
967
}
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