Skip to content

Commit 39d9c1c

Browse files
committed
Move predecessors from Body to BasicBlocks
1 parent 2446b17 commit 39d9c1c

File tree

9 files changed

+10
-16
lines changed

9 files changed

+10
-16
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16281628
location: Location,
16291629
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
16301630
if location.statement_index == 0 {
1631-
let predecessors = body.predecessors()[location.block].to_vec();
1631+
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
16321632
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))
16331633
} else {
16341634
Either::Right(std::iter::once(Location {

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
258258

259259
let block = self.cx.elements.to_location(block_start).block;
260260
self.stack.extend(
261-
self.cx.body.predecessors()[block]
261+
self.cx.body.basic_blocks.predecessors()[block]
262262
.iter()
263263
.map(|&pred_bb| self.cx.body.terminator_loc(pred_bb))
264264
.map(|pred_loc| self.cx.elements.point_from_location(pred_loc)),
@@ -354,7 +354,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
354354
}
355355

356356
let body = self.cx.body;
357-
for &pred_block in body.predecessors()[block].iter() {
357+
for &pred_block in body.basic_blocks.predecessors()[block].iter() {
358358
debug!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,);
359359

360360
// Check whether the variable is (at least partially)

compiler/rustc_middle/src/mir/mod.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use std::fmt::{self, Debug, Display, Formatter, Write};
4141
use std::ops::{ControlFlow, Index, IndexMut};
4242
use std::{iter, mem};
4343

44-
use self::predecessors::Predecessors;
4544
pub use self::query::*;
4645
use self::switch_sources::SwitchSources;
4746
pub use basic_blocks::BasicBlocks;
@@ -449,11 +448,6 @@ impl<'tcx> Body<'tcx> {
449448
.unwrap_or_else(|| Either::Right(block_data.terminator()))
450449
}
451450

452-
#[inline]
453-
pub fn predecessors(&self) -> &Predecessors {
454-
self.basic_blocks.predecessors()
455-
}
456-
457451
/// `body.switch_sources()[&(target, switch)]` returns a list of switch
458452
/// values that lead to a `target` block from a `switch` block.
459453
#[inline]
@@ -2837,7 +2831,7 @@ impl Location {
28372831
return true;
28382832
}
28392833

2840-
let predecessors = body.predecessors();
2834+
let predecessors = body.basic_blocks.predecessors();
28412835

28422836
// If we're in another block, then we want to check that block is a predecessor of `other`.
28432837
let mut queue: Vec<BasicBlock> = predecessors[other.block].to_vec();

compiler/rustc_mir_dataflow/src/framework/direction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Direction for Backward {
228228
) where
229229
A: Analysis<'tcx>,
230230
{
231-
for pred in body.predecessors()[bb].iter().copied() {
231+
for pred in body.basic_blocks.predecessors()[bb].iter().copied() {
232232
match body[pred].terminator().kind {
233233
// Apply terminator-specific edge effects.
234234
//

compiler/rustc_mir_transform/src/add_call_guards.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
3939
impl AddCallGuards {
4040
pub fn add_call_guards(&self, body: &mut Body<'_>) {
4141
let mut pred_count: IndexVec<_, _> =
42-
body.predecessors().iter().map(|ps| ps.len()).collect();
42+
body.basic_blocks.predecessors().iter().map(|ps| ps.len()).collect();
4343
pred_count[START_BLOCK] += 1;
4444

4545
// We need a place to store the new blocks generated

compiler/rustc_mir_transform/src/coverage/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CoverageGraph {
9595
let mut basic_blocks = Vec::new();
9696
for (bb, data) in mir_cfg_without_unwind {
9797
if let Some(last) = basic_blocks.last() {
98-
let predecessors = &mir_body.predecessors()[bb];
98+
let predecessors = &mir_body.basic_blocks.predecessors()[bb];
9999
if predecessors.len() > 1 || !predecessors.contains(last) {
100100
// The `bb` has more than one _incoming_ edge, and should start its own
101101
// `BasicCoverageBlockData`. (Note, the `basic_blocks` vector does not yet

compiler/rustc_mir_transform/src/nrvo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn find_local_assigned_to_return_place(
133133
return local;
134134
}
135135

136-
match body.predecessors()[block].as_slice() {
136+
match body.basic_blocks.predecessors()[block].as_slice() {
137137
&[pred] => block = pred,
138138
_ => return None,
139139
}

compiler/rustc_mir_transform/src/separate_const_switch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> MirPass<'tcx> for SeparateConstSwitch {
6161
/// Returns the amount of blocks that were duplicated
6262
pub fn separate_const_switch(body: &mut Body<'_>) -> usize {
6363
let mut new_blocks: SmallVec<[(BasicBlock, BasicBlock); 6]> = SmallVec::new();
64-
let predecessors = body.predecessors();
64+
let predecessors = body.basic_blocks.predecessors();
6565
'block_iter: for (block_id, block) in body.basic_blocks().iter_enumerated() {
6666
if let TerminatorKind::SwitchInt {
6767
discr: Operand::Copy(switch_place) | Operand::Move(switch_place),

src/tools/clippy/clippy_lints/src/redundant_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
161161
// `arg` is a reference as it is `.deref()`ed in the previous block.
162162
// Look into the predecessor block and find out the source of deref.
163163

164-
let ps = &mir.predecessors()[bb];
164+
let ps = &mir.basic_blocks.predecessors()[bb];
165165
if ps.len() != 1 {
166166
continue;
167167
}

0 commit comments

Comments
 (0)