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 @@ -157,8 +157,24 @@ 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 (a, b) = (false, true);
167
+ /// let x = a && b;
168
+ /// // ^ last operand
169
+ /// ```
170
+ /// Condition coverage does track true/false coverage for `b`,
171
+ /// but branch coverage doesn't.
172
+ ///
173
+ /// The main purpose of this coverage level is to be reused by MCDC.
174
+ Condition ,
175
+ /// Instrument for MC/DC. Enables condition coverage under the hood.
176
+ /// Mostly a superset of branch coverage, but might differ in some
177
+ /// corner cases.
162
178
Mcdc ,
163
179
}
164
180
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