]> git.lizzy.rs Git - rust.git/commitdiff
rename `ConstraintIndex` to `OutlivesConstraintIndex`
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 4 Jun 2019 21:39:12 +0000 (17:39 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 2 Jul 2019 16:15:19 +0000 (12:15 -0400)
src/librustc_mir/borrow_check/nll/constraints/graph.rs
src/librustc_mir/borrow_check/nll/constraints/mod.rs

index c4b2a5daef89ab50c8ed4a1e7fd78fedeeac8e78..78d49309d021468b692ab7bccf80f723f52049ff 100644 (file)
@@ -1,5 +1,5 @@
 use crate::borrow_check::nll::type_check::Locations;
-use crate::borrow_check::nll::constraints::ConstraintIndex;
+use crate::borrow_check::nll::constraints::OutlivesConstraintIndex;
 use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
 use rustc::mir::ConstraintCategory;
 use rustc::ty::RegionVid;
@@ -12,8 +12,8 @@
 /// -> R2` or `R2 -> R1` depending on the direction type `D`.
 crate struct ConstraintGraph<D: ConstraintGraphDirecton> {
     _direction: D,
-    first_constraints: IndexVec<RegionVid, Option<ConstraintIndex>>,
-    next_constraints: IndexVec<ConstraintIndex, Option<ConstraintIndex>>,
+    first_constraints: IndexVec<RegionVid, Option<OutlivesConstraintIndex>>,
+    next_constraints: IndexVec<OutlivesConstraintIndex, Option<OutlivesConstraintIndex>>,
 }
 
 crate type NormalConstraintGraph = ConstraintGraph<Normal>;
@@ -81,9 +81,9 @@ impl<D: ConstraintGraphDirecton> ConstraintGraph<D> {
         num_region_vars: usize,
     ) -> Self {
         let mut first_constraints = IndexVec::from_elem_n(None, num_region_vars);
-        let mut next_constraints = IndexVec::from_elem(None, &set.constraints);
+        let mut next_constraints = IndexVec::from_elem(None, &set.outlives);
 
-        for (idx, constraint) in set.constraints.iter_enumerated().rev() {
+        for (idx, constraint) in set.outlives.iter_enumerated().rev() {
             let head = &mut first_constraints[D::start_region(constraint)];
             let next = &mut next_constraints[idx];
             debug_assert!(next.is_none());
@@ -143,7 +143,7 @@ impl<D: ConstraintGraphDirecton> ConstraintGraph<D> {
 crate struct Edges<'s, D: ConstraintGraphDirecton> {
     graph: &'s ConstraintGraph<D>,
     constraints: &'s ConstraintSet,
-    pointer: Option<ConstraintIndex>,
+    pointer: Option<OutlivesConstraintIndex>,
     next_static_idx: Option<usize>,
     static_region: RegionVid,
 }
index b1091eb5ac81f8578225f187cdc73ce9b6ac0f02..a4c66d5ef6e0ff540a57f7fdae9bd60a5f8af5c7 100644 (file)
@@ -9,9 +9,13 @@
 
 crate mod graph;
 
+/// A set of NLL region constraints. These include "outlives"
+/// constraints of the form `R1: R2`. Each constraint is identified by
+/// a unique `OutlivesConstraintIndex` and you can index into the set
+/// (`constraint_set[i]`) to access the constraint details.
 #[derive(Clone, Default)]
 crate struct ConstraintSet {
-    constraints: IndexVec<ConstraintIndex, OutlivesConstraint>,
+    outlives: IndexVec<OutlivesConstraintIndex, OutlivesConstraint>,
 }
 
 impl ConstraintSet {
@@ -24,7 +28,7 @@ impl ConstraintSet {
             // 'a: 'a is pretty uninteresting
             return;
         }
-        self.constraints.push(constraint);
+        self.outlives.push(constraint);
     }
 
     /// Constructs a "normal" graph from the constraint set; the graph makes it
@@ -57,10 +61,10 @@ impl ConstraintSet {
 }
 
 impl Deref for ConstraintSet {
-    type Target = IndexVec<ConstraintIndex, OutlivesConstraint>;
+    type Target = IndexVec<OutlivesConstraintIndex, OutlivesConstraint>;
 
     fn deref(&self) -> &Self::Target {
-        &self.constraints
+        &self.outlives
     }
 }
 
@@ -94,8 +98,8 @@ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 newtype_index! {
-    pub struct ConstraintIndex {
-        DEBUG_FORMAT = "ConstraintIndex({})"
+    pub struct OutlivesConstraintIndex {
+        DEBUG_FORMAT = "OutlivesConstraintIndex({})"
     }
 }