[−][src]Struct rustc_ap_rustc_data_structures::transitive_relation::TransitiveRelation
Implementations
impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn elements(&self) -> impl Iterator<Item = &T>
[src]
pub fn maybe_map<F, U>(&self, f: F) -> Option<TransitiveRelation<U>> where
F: FnMut(&T) -> Option<U>,
U: Clone + Debug + Eq + Hash,
[src]
F: FnMut(&T) -> Option<U>,
U: Clone + Debug + Eq + Hash,
Applies the (partial) function to each edge and returns a new
relation. If f
returns None
for any end-point, returns
None
.
pub fn add(&mut self, a: T, b: T)
[src]
Indicate that a < b
(where <
is this relation)
pub fn contains(&self, a: &T, b: &T) -> bool
[src]
Checks whether a < target
(transitively)
pub fn reachable_from(&self, a: &T) -> Vec<&T>
[src]
Thinking of x R y
as an edge x -> y
in a graph, this
returns all things reachable from a
.
Really this probably ought to be impl Iterator<Item = &T>
, but
I'm too lazy to make that work, and -- given the caching
strategy -- it'd be a touch tricky anyhow.
pub fn postdom_upper_bound(&self, a: &T, b: &T) -> Option<&T>
[src]
Picks what I am referring to as the "postdominating"
upper-bound for a
and b
. This is usually the least upper
bound, but in cases where there is no single least upper
bound, it is the "mutual immediate postdominator", if you
imagine a graph where a < b
means a -> b
.
This function is needed because region inference currently requires that we produce a single "UB", and there is no best choice for the LUB. Rather than pick arbitrarily, I pick a less good, but predictable choice. This should help ensure that region inference yields predictable results (though it itself is not fully sufficient).
Examples are probably clearer than any prose I could write
(there are corresponding tests below, btw). In each case,
the query is postdom_upper_bound(a, b)
:
// Returns Some(x), which is also LUB.
a -> a1 -> x
^
|
b -> b1 ---+
// Returns `Some(x)`, which is not LUB (there is none)
// diagonal edges run left-to-right.
a -> a1 -> x
\/ ^
/\ |
b -> b1 ---+
// Returns `None`.
a -> a1
b -> b1
pub fn mutual_immediate_postdominator<'a>(
&'a self,
mubs: Vec<&'a T>
) -> Option<&'a T>
[src]
&'a self,
mubs: Vec<&'a T>
) -> Option<&'a T>
Viewing the relation as a graph, computes the "mutual
immediate postdominator" of a set of points (if one
exists). See postdom_upper_bound
for details.
pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T>
[src]
Returns the set of bounds X
such that:
a < X
andb < X
- there is no
Y != X
such thata < Y
andY < X
- except for the case where
X < a
(i.e., a strongly connected component in the graph). In that case, the smallest representative of the SCC is returned (as determined by the internal indices).
- except for the case where
Note that this set can, in principle, have any size.
pub fn parents(&self, a: &T) -> Vec<&T>
[src]
Given an element A, returns the maximal set {B} of elements B such that
- A != B
- A R B is true
- for each i, j:
B[i]
RB[j]
does not hold
The intuition is that this moves "one step up" through a lattice
(where the relation is encoding the <=
relation for the lattice).
So e.g., if the relation is ->
and we have
a -> b -> d -> f | ^ +--> c -> e ---+
then parents(a)
returns [b, c]
. The postdom_parent
function
would further reduce this to just f
.
pub fn postdom_parent(&self, a: &T) -> Option<&T>
[src]
A "best" parent in some sense. See parents
and
postdom_upper_bound
for more details.
pub fn base_edges(&self) -> impl Iterator<Item = (&T, &T)>
[src]
Lists all the base edges in the graph: the initial non-transitive set of element relations, which will be later used as the basis for the transitive closure computation.
Trait Implementations
impl<T: Clone + Eq + Hash> Clone for TransitiveRelation<T>
[src]
fn clone(&self) -> TransitiveRelation<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug + Eq + Hash> Debug for TransitiveRelation<T>
[src]
impl<T> Decodable for TransitiveRelation<T> where
T: Clone + Decodable + Debug + Eq + Hash,
[src]
T: Clone + Decodable + Debug + Eq + Hash,
impl<T: Eq + Hash> Default for TransitiveRelation<T>
[src]
impl<T> Encodable for TransitiveRelation<T> where
T: Clone + Encodable + Debug + Eq + Hash,
[src]
T: Clone + Encodable + Debug + Eq + Hash,
impl<CTX, T> HashStable<CTX> for TransitiveRelation<T> where
T: HashStable<CTX> + Eq + Debug + Clone + Hash,
[src]
T: HashStable<CTX> + Eq + Debug + Clone + Hash,
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for TransitiveRelation<T>
impl<T> Send for TransitiveRelation<T> where
T: Send,
T: Send,
impl<T> !Sync for TransitiveRelation<T>
impl<T> Unpin for TransitiveRelation<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for TransitiveRelation<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Decodable for T where
T: UseSpecializedDecodable,
[src]
T: UseSpecializedDecodable,
impl<T> Encodable for T where
T: UseSpecializedEncodable + ?Sized,
[src]
T: UseSpecializedEncodable + ?Sized,
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<E> SpecializationError for E
[src]
default fn not_found<S, T>(
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
[src]
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,