1
Fork 0

Merge {With,Graph}{Successors,Predecessors} into {Successors,Predecessors}

Now with GAT!
This commit is contained in:
Maybe Waffle 2024-04-14 15:40:26 +00:00
parent 398da593a5
commit 0d5fc9bf58
15 changed files with 78 additions and 133 deletions

View file

@ -1,7 +1,7 @@
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::dominators::{self, Dominators};
use rustc_data_structures::graph::{self, DirectedGraph, GraphSuccessors, WithStartNode};
use rustc_data_structures::graph::{self, DirectedGraph, WithStartNode};
use rustc_index::bit_set::BitSet;
use rustc_index::IndexVec;
use rustc_middle::mir::{self, BasicBlock, Terminator, TerminatorKind};
@ -208,28 +208,20 @@ impl graph::WithStartNode for CoverageGraph {
}
}
type BcbSuccessors<'graph> = std::slice::Iter<'graph, BasicCoverageBlock>;
impl graph::Successors for CoverageGraph {
type Successors<'g> = std::iter::Cloned<std::slice::Iter<'g, BasicCoverageBlock>>;
impl<'graph> graph::GraphSuccessors<'graph> for CoverageGraph {
type Item = BasicCoverageBlock;
type Iter = std::iter::Cloned<BcbSuccessors<'graph>>;
}
impl graph::WithSuccessors for CoverageGraph {
#[inline]
fn successors(&self, node: Self::Node) -> <Self as GraphSuccessors<'_>>::Iter {
fn successors(&self, node: Self::Node) -> Self::Successors<'_> {
self.successors[node].iter().cloned()
}
}
impl<'graph> graph::GraphPredecessors<'graph> for CoverageGraph {
type Item = BasicCoverageBlock;
type Iter = std::iter::Copied<std::slice::Iter<'graph, BasicCoverageBlock>>;
}
impl graph::Predecessors for CoverageGraph {
type Predecessors<'g> = std::iter::Copied<std::slice::Iter<'g, BasicCoverageBlock>>;
impl graph::WithPredecessors for CoverageGraph {
#[inline]
fn predecessors(&self, node: Self::Node) -> <Self as graph::GraphPredecessors<'_>>::Iter {
fn predecessors(&self, node: Self::Node) -> Self::Predecessors<'_> {
self.predecessors[node].iter().copied()
}
}

View file

@ -28,8 +28,7 @@ use super::counters;
use super::graph::{self, BasicCoverageBlock};
use itertools::Itertools;
use rustc_data_structures::graph::WithSuccessors;
use rustc_data_structures::graph::DirectedGraph;
use rustc_data_structures::graph::{DirectedGraph, Successors};
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::*;
use rustc_middle::ty;