]> git.lizzy.rs Git - rust.git/commitdiff
rename `constraint_set` to `constraints`
authorNiko Matsakis <niko@alum.mit.edu>
Sun, 1 Jul 2018 14:29:18 +0000 (10:29 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 12 Jul 2018 04:38:40 +0000 (00:38 -0400)
also promote to its own directory, make local to nll

src/librustc_mir/borrow_check/nll/constraint_set.rs [deleted file]
src/librustc_mir/borrow_check/nll/constraints/mod.rs [new file with mode: 0644]
src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs

diff --git a/src/librustc_mir/borrow_check/nll/constraint_set.rs b/src/librustc_mir/borrow_check/nll/constraint_set.rs
deleted file mode 100644 (file)
index eab1de0..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rustc::ty::RegionVid;
-use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use borrow_check::nll::type_check::Locations;
-
-use std::fmt;
-use std::ops::Deref;
-
-#[derive(Clone, Default)]
-crate struct ConstraintSet {
-    constraints: IndexVec<ConstraintIndex, OutlivesConstraint>,
-}
-
-impl ConstraintSet {
-    pub fn push(&mut self, constraint: OutlivesConstraint) {
-        debug!(
-            "ConstraintSet::push({:?}: {:?} @ {:?}",
-            constraint.sup, constraint.sub, constraint.locations
-        );
-        if constraint.sup == constraint.sub {
-            // 'a: 'a is pretty uninteresting
-            return;
-        }
-        self.constraints.push(constraint);
-    }
-}
-
-impl Deref for ConstraintSet {
-    type Target = IndexVec<ConstraintIndex, OutlivesConstraint>;
-
-    fn deref(&self) -> &Self::Target { &self.constraints }
-}
-
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
-pub struct OutlivesConstraint {
-    // NB. The ordering here is not significant for correctness, but
-    // it is for convenience. Before we dump the constraints in the
-    // debugging logs, we sort them, and we'd like the "super region"
-    // to be first, etc. (In particular, span should remain last.)
-    /// The region SUP must outlive SUB...
-    pub sup: RegionVid,
-
-    /// Region that must be outlived.
-    pub sub: RegionVid,
-
-    /// Where did this constraint arise?
-    pub locations: Locations,
-}
-
-impl fmt::Debug for OutlivesConstraint {
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
-        write!(
-            formatter,
-            "({:?}: {:?}) due to {:?}",
-            self.sup, self.sub, self.locations
-        )
-    }
-}
-
-newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
-
-crate struct ConstraintGraph {
-    first_constraints: IndexVec<RegionVid, Option<ConstraintIndex>>,
-    next_constraints: IndexVec<ConstraintIndex, Option<ConstraintIndex>>,
-}
-
-impl ConstraintGraph {
-    /// Constraint a graph where each region constraint `R1: R2` is
-    /// treated as an edge `R2 -> R1`. This is useful for cheaply
-    /// finding dirty constraints.
-    crate fn new(set: &ConstraintSet, 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);
-
-        for (idx, constraint) in set.constraints.iter_enumerated().rev() {
-            let mut head = &mut first_constraints[constraint.sub];
-            let mut next = &mut next_constraints[idx];
-            debug_assert!(next.is_none());
-            *next = *head;
-            *head = Some(idx);
-        }
-
-        ConstraintGraph { first_constraints, next_constraints }
-    }
-
-    /// Invokes `op` with the index of any constraints of the form
-    /// `region_sup: region_sub`.  These are the constraints that must
-    /// be reprocessed when the value of `R1` changes. If you think of
-    /// each constraint `R1: R2` as an edge `R2 -> R1`, then this
-    /// gives the set of successors to R2.
-    crate fn for_each_dependent(
-        &self,
-        region_sub: RegionVid,
-        mut op: impl FnMut(ConstraintIndex),
-    ) {
-        let mut p = self.first_constraints[region_sub];
-        while let Some(dep_idx) = p {
-            op(dep_idx);
-            p = self.next_constraints[dep_idx];
-        }
-    }
-}
-
diff --git a/src/librustc_mir/borrow_check/nll/constraints/mod.rs b/src/librustc_mir/borrow_check/nll/constraints/mod.rs
new file mode 100644 (file)
index 0000000..eab1de0
--- /dev/null
@@ -0,0 +1,112 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use rustc::ty::RegionVid;
+use rustc_data_structures::indexed_vec::{Idx, IndexVec};
+use borrow_check::nll::type_check::Locations;
+
+use std::fmt;
+use std::ops::Deref;
+
+#[derive(Clone, Default)]
+crate struct ConstraintSet {
+    constraints: IndexVec<ConstraintIndex, OutlivesConstraint>,
+}
+
+impl ConstraintSet {
+    pub fn push(&mut self, constraint: OutlivesConstraint) {
+        debug!(
+            "ConstraintSet::push({:?}: {:?} @ {:?}",
+            constraint.sup, constraint.sub, constraint.locations
+        );
+        if constraint.sup == constraint.sub {
+            // 'a: 'a is pretty uninteresting
+            return;
+        }
+        self.constraints.push(constraint);
+    }
+}
+
+impl Deref for ConstraintSet {
+    type Target = IndexVec<ConstraintIndex, OutlivesConstraint>;
+
+    fn deref(&self) -> &Self::Target { &self.constraints }
+}
+
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
+pub struct OutlivesConstraint {
+    // NB. The ordering here is not significant for correctness, but
+    // it is for convenience. Before we dump the constraints in the
+    // debugging logs, we sort them, and we'd like the "super region"
+    // to be first, etc. (In particular, span should remain last.)
+    /// The region SUP must outlive SUB...
+    pub sup: RegionVid,
+
+    /// Region that must be outlived.
+    pub sub: RegionVid,
+
+    /// Where did this constraint arise?
+    pub locations: Locations,
+}
+
+impl fmt::Debug for OutlivesConstraint {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        write!(
+            formatter,
+            "({:?}: {:?}) due to {:?}",
+            self.sup, self.sub, self.locations
+        )
+    }
+}
+
+newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
+
+crate struct ConstraintGraph {
+    first_constraints: IndexVec<RegionVid, Option<ConstraintIndex>>,
+    next_constraints: IndexVec<ConstraintIndex, Option<ConstraintIndex>>,
+}
+
+impl ConstraintGraph {
+    /// Constraint a graph where each region constraint `R1: R2` is
+    /// treated as an edge `R2 -> R1`. This is useful for cheaply
+    /// finding dirty constraints.
+    crate fn new(set: &ConstraintSet, 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);
+
+        for (idx, constraint) in set.constraints.iter_enumerated().rev() {
+            let mut head = &mut first_constraints[constraint.sub];
+            let mut next = &mut next_constraints[idx];
+            debug_assert!(next.is_none());
+            *next = *head;
+            *head = Some(idx);
+        }
+
+        ConstraintGraph { first_constraints, next_constraints }
+    }
+
+    /// Invokes `op` with the index of any constraints of the form
+    /// `region_sup: region_sub`.  These are the constraints that must
+    /// be reprocessed when the value of `R1` changes. If you think of
+    /// each constraint `R1: R2` as an edge `R2 -> R1`, then this
+    /// gives the set of successors to R2.
+    crate fn for_each_dependent(
+        &self,
+        region_sub: RegionVid,
+        mut op: impl FnMut(ConstraintIndex),
+    ) {
+        let mut p = self.first_constraints[region_sub];
+        while let Some(dep_idx) = p {
+            op(dep_idx);
+            p = self.next_constraints[dep_idx];
+        }
+    }
+}
+
index 1891cac268c527455d3834300c4815d54c0c9f92..26298a289fc61815ababfe5ea7407533d8dabd4d 100644 (file)
@@ -45,7 +45,7 @@
 crate mod type_check;
 mod universal_regions;
 
-crate mod constraint_set;
+mod constraints;
 
 use self::facts::AllFacts;
 use self::region_infer::RegionInferenceContext;
index 0116fbcfc8860d39e648cb4b7cf7e774985624be..8be51257cd6cb7ac9ec444f75c71a6ba278069ed 100644 (file)
@@ -17,7 +17,7 @@
 use std::borrow::Cow;
 use std::io::{self, Write};
 use super::*;
-use borrow_check::nll::constraint_set::OutlivesConstraint;
+use borrow_check::nll::constraints::OutlivesConstraint;
 
 
 impl<'tcx> RegionInferenceContext<'tcx> {
index f0ada4a85a146b03ca31dea4ecd776c90a85f05e..e4426ff3869e725f736efa8b97d3cbd796bc5fb0 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use super::universal_regions::UniversalRegions;
-use borrow_check::nll::constraint_set::{
+use borrow_check::nll::constraints::{
     ConstraintIndex, ConstraintGraph, ConstraintSet, OutlivesConstraint
 };
 use borrow_check::nll::type_check::Locations;
index a5a159fbb1c3d434ba720f55572905522cf1e1d5..64a61972a2206de18fdb52f5b5be8b20e67945d4 100644 (file)
@@ -9,12 +9,11 @@
 // except according to those terms.
 
 use borrow_check::location::LocationTable;
-use borrow_check::nll::constraint_set::OutlivesConstraint;
+use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
 use borrow_check::nll::facts::AllFacts;
 use borrow_check::nll::region_infer::{RegionTest, TypeTest};
 use borrow_check::nll::type_check::Locations;
 use borrow_check::nll::universal_regions::UniversalRegions;
-use borrow_check::nll::constraint_set::ConstraintSet;
 use rustc::infer::canonical::QueryRegionConstraint;
 use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
 use rustc::infer::region_constraints::{GenericKind, VerifyBound};
index 97a74e0d3365bbc701e823985ce4ae2980f7500c..25f2be231772d58cfaaea9e108a6ca6cda522802 100644 (file)
@@ -13,7 +13,7 @@
 
 use borrow_check::borrow_set::BorrowSet;
 use borrow_check::location::LocationTable;
-use borrow_check::nll::constraint_set::{ConstraintSet, OutlivesConstraint};
+use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
 use borrow_check::nll::facts::AllFacts;
 use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest};
 use borrow_check::nll::universal_regions::UniversalRegions;