diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-07-04 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-07-07 08:11:49 +0200 |
| commit | c9dd1d9983b9a08159c2e3c86071d1a5ef7ebb20 (patch) | |
| tree | 821f63c3785e5599f0252939c2289414b947d530 /compiler/rustc_mir_transform/src/coverage/spans.rs | |
| parent | fac8fa56726f7a5b2d4880a4719c5f99beec8328 (diff) | |
| download | rust-c9dd1d9983b9a08159c2e3c86071d1a5ef7ebb20.tar.gz rust-c9dd1d9983b9a08159c2e3c86071d1a5ef7ebb20.zip | |
Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/spans.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/spans.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 82070b90325..423e78317aa 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -321,7 +321,8 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> { } fn mir_to_initial_sorted_coverage_spans(&self) -> Vec<CoverageSpan> { - let mut initial_spans = Vec::<CoverageSpan>::with_capacity(self.mir_body.num_nodes() * 2); + let mut initial_spans = + Vec::<CoverageSpan>::with_capacity(self.mir_body.basic_blocks.len() * 2); for (bcb, bcb_data) in self.basic_coverage_blocks.iter_enumerated() { initial_spans.extend(self.bcb_to_initial_coverage_spans(bcb, bcb_data)); } |
