Adjust ConstraintGraphDirection
methods.
This facilitates the next commit.
This commit is contained in:
parent
00f245915b
commit
60bf07a26c
1 changed files with 12 additions and 12 deletions
|
@ -23,8 +23,8 @@ pub(crate) type ReverseConstraintGraph = ConstraintGraph<Reverse>;
|
||||||
/// Marker trait that controls whether a `R1: R2` constraint
|
/// Marker trait that controls whether a `R1: R2` constraint
|
||||||
/// represents an edge `R1 -> R2` or `R2 -> R1`.
|
/// represents an edge `R1 -> R2` or `R2 -> R1`.
|
||||||
pub(crate) trait ConstraintGraphDirection: Copy + 'static {
|
pub(crate) trait ConstraintGraphDirection: Copy + 'static {
|
||||||
fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid;
|
fn start_region(sup: RegionVid, sub: RegionVid) -> RegionVid;
|
||||||
fn end_region(c: &OutlivesConstraint<'_>) -> RegionVid;
|
fn end_region(sup: RegionVid, sub: RegionVid) -> RegionVid;
|
||||||
fn is_normal() -> bool;
|
fn is_normal() -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ pub(crate) trait ConstraintGraphDirection: Copy + 'static {
|
||||||
pub(crate) struct Normal;
|
pub(crate) struct Normal;
|
||||||
|
|
||||||
impl ConstraintGraphDirection for Normal {
|
impl ConstraintGraphDirection for Normal {
|
||||||
fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid {
|
fn start_region(sup: RegionVid, _sub: RegionVid) -> RegionVid {
|
||||||
c.sup
|
sup
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_region(c: &OutlivesConstraint<'_>) -> RegionVid {
|
fn end_region(_sup: RegionVid, sub: RegionVid) -> RegionVid {
|
||||||
c.sub
|
sub
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_normal() -> bool {
|
fn is_normal() -> bool {
|
||||||
|
@ -57,12 +57,12 @@ impl ConstraintGraphDirection for Normal {
|
||||||
pub(crate) struct Reverse;
|
pub(crate) struct Reverse;
|
||||||
|
|
||||||
impl ConstraintGraphDirection for Reverse {
|
impl ConstraintGraphDirection for Reverse {
|
||||||
fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid {
|
fn start_region(_sup: RegionVid, sub: RegionVid) -> RegionVid {
|
||||||
c.sub
|
sub
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_region(c: &OutlivesConstraint<'_>) -> RegionVid {
|
fn end_region(sup: RegionVid, _sub: RegionVid) -> RegionVid {
|
||||||
c.sup
|
sup
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_normal() -> bool {
|
fn is_normal() -> bool {
|
||||||
|
@ -84,7 +84,7 @@ impl<D: ConstraintGraphDirection> ConstraintGraph<D> {
|
||||||
let mut next_constraints = IndexVec::from_elem(None, &set.outlives);
|
let mut next_constraints = IndexVec::from_elem(None, &set.outlives);
|
||||||
|
|
||||||
for (idx, constraint) in set.outlives.iter_enumerated().rev() {
|
for (idx, constraint) in set.outlives.iter_enumerated().rev() {
|
||||||
let head = &mut first_constraints[D::start_region(constraint)];
|
let head = &mut first_constraints[D::start_region(constraint.sup, constraint.sub)];
|
||||||
let next = &mut next_constraints[idx];
|
let next = &mut next_constraints[idx];
|
||||||
debug_assert!(next.is_none());
|
debug_assert!(next.is_none());
|
||||||
*next = *head;
|
*next = *head;
|
||||||
|
@ -207,7 +207,7 @@ impl<'a, 'tcx, D: ConstraintGraphDirection> Iterator for Successors<'a, 'tcx, D>
|
||||||
type Item = RegionVid;
|
type Item = RegionVid;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
self.edges.next().map(|c| D::end_region(&c))
|
self.edges.next().map(|c| D::end_region(c.sup, c.sub))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue