Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove predecessors_for
There is no `Arc::map` equivalent to `LockGuard::map`
  • Loading branch information
ecstatic-morse committed Apr 23, 2020
commit 740f228b5b68f4db74318e0f234786aa3bc4e982
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let cleanup_kinds = analyze::cleanup_kinds(&mir);
// Allocate a `Block` for every basic block, except
// the start block, if nothing loops back to it.
let reentrant_start_block = !mir.predecessors_for(mir::START_BLOCK).is_empty();
let reentrant_start_block = !mir.predecessors()[mir::START_BLOCK].is_empty();
let block_bxs: IndexVec<mir::BasicBlock, Bx::BasicBlock> = mir
.basic_blocks()
.indices()
Expand Down
13 changes: 1 addition & 12 deletions src/librustc_middle/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ use rustc_ast::ast::Name;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::dominators::{dominators, Dominators};
use rustc_data_structures::graph::{self, GraphSuccessors};
use rustc_data_structures::sync::MappedLockGuard;
use rustc_index::bit_set::BitMatrix;
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
use rustc_serialize::{Decodable, Encodable};
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::fmt::{self, Debug, Display, Formatter, Write};
use std::ops::{Index, IndexMut};
Expand Down Expand Up @@ -392,15 +390,6 @@ impl<'tcx> Body<'tcx> {
Location { block: bb, statement_index: self[bb].statements.len() }
}

#[inline]
pub fn predecessors_for(
&self,
bb: BasicBlock,
) -> impl std::ops::Deref<Target = SmallVec<[BasicBlock; 4]>> + '_ {
let predecessors = self.predecessor_cache.compute(&self.basic_blocks);
MappedLockGuard::map(predecessors, |preds| &mut preds[bb])
}

#[inline]
pub fn predecessors(&self) -> impl std::ops::Deref<Target = Predecessors> + '_ {
self.predecessor_cache.compute(&self.basic_blocks)
Expand Down Expand Up @@ -2676,7 +2665,7 @@ impl graph::GraphPredecessors<'graph> for Body<'tcx> {
impl graph::WithPredecessors for Body<'tcx> {
#[inline]
fn predecessors(&self, node: Self::Node) -> <Self as graph::GraphPredecessors<'_>>::Iter {
self.predecessors_for(node).clone().into_iter()
self.predecessors()[node].clone().into_iter()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location,
) -> impl Iterator<Item = Location> + 'a {
if location.statement_index == 0 {
let predecessors = body.predecessors_for(location.block).to_vec();
let predecessors = body.predecessors()[location.block].to_vec();
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))
} else {
Either::Right(std::iter::once(Location {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl RegionValueElements {
// If this is a basic block head, then the predecessors are
// the terminators of other basic blocks
stack.extend(
body.predecessors_for(block)
body.predecessors()[block]
.iter()
.map(|&pred_bb| body.terminator_loc(pred_bb))
.map(|pred_loc| self.point_from_location(pred_loc)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
}

let body = self.cx.body;
for &pred_block in body.predecessors_for(block).iter() {
for &pred_block in body.predecessors()[block].iter() {
debug!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,);

// Check whether the variable is (at least partially)
Expand Down