]> git.lizzy.rs Git - rust.git/commitdiff
add some comments
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 29 Aug 2018 17:02:13 +0000 (13:02 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Sun, 9 Sep 2018 18:14:41 +0000 (14:14 -0400)
src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs

index 0badef49f669e43a3b66e48aba0f994a7e383fcf..0e945ad33419e0b35f073a31375e3ee36f6eddcc 100644 (file)
@@ -194,6 +194,14 @@ fn create_scope(
         scope
     }
 
+    /// When we encounter binders during the type traversal, we record
+    /// the value to substitute for each of the things contained in
+    /// that binder. (This will be either a universal placeholder or
+    /// an existential inference variable.) Given the debruijn index
+    /// `debruijn` (and name `br`) of some binder we have now
+    /// encountered, this routine finds the value that we instantiated
+    /// the region with; to do so, it indexes backwards into the list
+    /// of ambient scopes `scopes`.
     fn lookup_bound_region(
         &self,
         debruijn: ty::DebruijnIndex,
@@ -211,6 +219,9 @@ fn lookup_bound_region(
         scope.map[br]
     }
 
+    /// If `r` is a bound region, find the scope in which it is bound
+    /// (from `scopes`) and return the value that we instantiated it
+    /// with. Otherwise just return `r`.
     fn replace_bound_region(
         &self,
         universal_regions: &UniversalRegions<'tcx>,
@@ -226,6 +237,8 @@ fn replace_bound_region(
         }
     }
 
+    /// Push a new outlives requirement into our output set of
+    /// constraints.
     fn push_outlives(&mut self, sup: RegionVid, sub: RegionVid) {
         debug!("push_outlives({:?}: {:?})", sup, sub);
 
@@ -243,6 +256,9 @@ fn push_outlives(&mut self, sup: RegionVid, sub: RegionVid) {
         }
     }
 
+    /// When we encounter a canonical variable `var` in the output,
+    /// equate it with `kind`. If the variable has been previously
+    /// equated, then equate it again.
     fn equate_var(
         &mut self,
         var: CanonicalVar,