|
2 | 2 |
|
3 | 3 | use rustc_index::IndexVec;
|
4 | 4 | use rustc_macros::HashStable;
|
5 |
| -use rustc_span::Symbol; |
| 5 | +use rustc_span::{Span, Symbol}; |
6 | 6 |
|
7 | 7 | use std::fmt::{self, Debug, Formatter};
|
8 | 8 |
|
@@ -93,7 +93,7 @@ pub enum CoverageKind {
|
93 | 93 | SpanMarker,
|
94 | 94 |
|
95 | 95 | /// Marks its enclosing basic block with an ID that can be referred to by
|
96 |
| - /// other data in the MIR body. |
| 96 | + /// side data in [`BranchInfo`]. |
97 | 97 | ///
|
98 | 98 | /// Has no effect during codegen.
|
99 | 99 | BlockMarker { id: BlockMarkerId },
|
@@ -218,3 +218,22 @@ pub struct FunctionCoverageInfo {
|
218 | 218 | pub expressions: IndexVec<ExpressionId, Expression>,
|
219 | 219 | pub mappings: Vec<Mapping>,
|
220 | 220 | }
|
| 221 | + |
| 222 | +/// Branch information recorded during THIR-to-MIR lowering, and stored in MIR. |
| 223 | +#[derive(Clone, Debug)] |
| 224 | +#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)] |
| 225 | +pub struct BranchInfo { |
| 226 | + /// 1 more than the highest-numbered [`CoverageKind::BlockMarker`] that was |
| 227 | + /// injected into the MIR body. This makes it possible to allocate per-ID |
| 228 | + /// data structures without having to scan the entire body first. |
| 229 | + pub num_block_markers: usize, |
| 230 | + pub branch_spans: Vec<BranchSpan>, |
| 231 | +} |
| 232 | + |
| 233 | +#[derive(Clone, Debug)] |
| 234 | +#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)] |
| 235 | +pub struct BranchSpan { |
| 236 | + pub span: Span, |
| 237 | + pub true_marker: BlockMarkerId, |
| 238 | + pub false_marker: BlockMarkerId, |
| 239 | +} |
0 commit comments