1use rustc_middle::ty::RegionVid;
2use rustc_mir_dataflow::points::PointIndex;
34/// A localized outlives constraint reifies the CFG location where the outlives constraint holds,
5/// within the origins themselves as if they were different from point to point: from `a: b`
6/// outlives constraints to `a@p: b@p`, where `p` is the point in the CFG.
7///
8/// This models two sources of constraints:
9/// - constraints that traverse the subsets between regions at a given point, `a@p: b@p`. These
10/// depend on typeck constraints generated via assignments, calls, etc.
11/// - constraints that traverse the CFG via the same region, `a@p: a@q`, where `p` is a predecessor
12/// of `q`. These depend on the liveness of the regions at these points, as well as their
13/// variance.
14///
15/// The `source` origin at `from` flows into the `target` origin at `to`.
16///
17/// This dual of NLL's [crate::constraints::OutlivesConstraint] therefore encodes the
18/// position-dependent outlives constraints used by Polonius, to model the flow-sensitive loan
19/// propagation via reachability within a graph of localized constraints.
20#[derive(#[automatically_derived]
impl ::core::marker::Copy for LocalizedOutlivesConstraint { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LocalizedOutlivesConstraint {
#[inline]
fn clone(&self) -> LocalizedOutlivesConstraint {
let _: ::core::clone::AssertParamIsClone<RegionVid>;
let _: ::core::clone::AssertParamIsClone<PointIndex>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LocalizedOutlivesConstraint {
#[inline]
fn eq(&self, other: &LocalizedOutlivesConstraint) -> bool {
self.source == other.source && self.from == other.from &&
self.target == other.target && self.to == other.to
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LocalizedOutlivesConstraint {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<RegionVid>;
let _: ::core::cmp::AssertParamIsEq<PointIndex>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for LocalizedOutlivesConstraint {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"LocalizedOutlivesConstraint", "source", &self.source, "from",
&self.from, "target", &self.target, "to", &&self.to)
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for LocalizedOutlivesConstraint {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.source, state);
::core::hash::Hash::hash(&self.from, state);
::core::hash::Hash::hash(&self.target, state);
::core::hash::Hash::hash(&self.to, state)
}
}Hash)]
21pub(crate) struct LocalizedOutlivesConstraint {
22pub source: RegionVid,
23pub from: PointIndex,
24pub target: RegionVid,
25pub to: PointIndex,
26}
2728/// A container of [LocalizedOutlivesConstraint]s that can be turned into a traversable
29/// `rustc_data_structures` graph.
30#[derive(#[automatically_derived]
impl ::core::clone::Clone for LocalizedOutlivesConstraintSet {
#[inline]
fn clone(&self) -> LocalizedOutlivesConstraintSet {
LocalizedOutlivesConstraintSet {
outlives: ::core::clone::Clone::clone(&self.outlives),
}
}
}Clone, #[automatically_derived]
impl ::core::default::Default for LocalizedOutlivesConstraintSet {
#[inline]
fn default() -> LocalizedOutlivesConstraintSet {
LocalizedOutlivesConstraintSet {
outlives: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::fmt::Debug for LocalizedOutlivesConstraintSet {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"LocalizedOutlivesConstraintSet", "outlives", &&self.outlives)
}
}Debug)]
31pub(crate) struct LocalizedOutlivesConstraintSet {
32pub outlives: Vec<LocalizedOutlivesConstraint>,
33}
3435impl LocalizedOutlivesConstraintSet {
36pub(crate) fn push(&mut self, constraint: LocalizedOutlivesConstraint) {
37if constraint.source == constraint.target && constraint.from == constraint.to {
38// 'a@p: 'a@p is pretty uninteresting
39return;
40 }
41self.outlives.push(constraint);
42 }
43}