]> git.lizzy.rs Git - rust.git/commitdiff
more centril nits
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 24 Jun 2019 19:34:37 +0000 (15:34 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 2 Jul 2019 16:25:23 +0000 (12:25 -0400)
src/librustc_data_structures/graph/vec_graph/mod.rs
src/librustc_mir/borrow_check/nll/member_constraints.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs

index c425502f219488ac6ab3d66e52300455dee965cc..6fb1bb42d2cfd396b7c75a3c5110aef71d86ddc6 100644 (file)
@@ -27,7 +27,7 @@ pub fn new(
 
         let num_edges = edge_pairs.len();
 
-        // Store the *target* of each edge into `edge_targets`
+        // Store the *target* of each edge into `edge_targets`.
         let edge_targets: Vec<N> = edge_pairs.iter().map(|&(_, target)| target).collect();
 
         // Create the *edge starts* array. We are iterating over over
index 43212ffddf3a5be2a4afd475d5a25d37d92bf0bd..b5e2e111f38e518828a10d30581ed9badf3adef3 100644 (file)
@@ -8,18 +8,18 @@
 use syntax_pos::Span;
 
 /// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
-/// indexed by the region R0.
+/// indexed by the region `R0`.
 crate struct MemberConstraintSet<'tcx, R>
 where
     R: Copy + Hash + Eq,
 {
-    /// Stores the first "member" constraint for a given R0. This is an
+    /// Stores the first "member" constraint for a given `R0`. This is an
     /// index into the `constraints` vector below.
     first_constraints: FxHashMap<R, NllMemberConstraintIndex>,
 
     /// Stores the data about each `R0 member of [R1..Rn]` constraint.
     /// These are organized into a linked list, so each constraint
-    /// contains the index of the next constraint with the same R0.
+    /// contains the index of the next constraint with the same `R0`.
     constraints: IndexVec<NllMemberConstraintIndex, NllMemberConstraint<'tcx>>,
 
     /// Stores the `R1..Rn` regions for *all* sets. For any given
     /// The span where the hidden type was instantiated.
     crate definition_span: Span,
 
-    /// The hidden type in which R0 appears. (Used in error reporting.)
+    /// The hidden type in which `R0` appears. (Used in error reporting.)
     crate hidden_ty: Ty<'tcx>,
 
-    /// The region R0.
+    /// The region `R0`.
     crate member_region_vid: ty::RegionVid,
 
     /// Index of `R1` in `choice_regions` vector from `MemberConstraintSet`.
@@ -68,6 +68,15 @@ fn default() -> Self {
 }
 
 impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
+    /// Pushes a member constraint into the set.
+    ///
+    /// The input member constraint `m_c` is in the form produced by
+    /// the the `rustc::infer` code.
+    ///
+    /// The `to_region_vid` callback fn is used to convert the regions
+    /// within into `RegionVid` format -- it typically consults the
+    /// `UniversalRegions` data structure that is known to the caller
+    /// (but which this code is unaware of).
     crate fn push_constraint(
         &mut self,
         m_c: &MemberConstraint<'tcx>,
@@ -93,14 +102,14 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
     }
 }
 
-impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
+impl<R1> MemberConstraintSet<'tcx, R1>
 where
     R1: Copy + Hash + Eq,
 {
     /// Remap the "member region" key using `map_fn`, producing a new
-    /// pick-constraint set.  This is used in the NLL code to map from
+    /// member constraint set.  This is used in the NLL code to map from
     /// the original `RegionVid` to an scc index. In some cases, we
-    /// may have multiple R1 values mapping to the same R2 key -- that
+    /// may have multiple `R1` values mapping to the same `R2` key -- that
     /// is ok, the two sets will be merged.
     crate fn into_mapped<R2>(
         self,
@@ -112,12 +121,12 @@ impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
         // We can re-use most of the original data, just tweaking the
         // linked list links a bit.
         //
-        // For example if we had two keys Ra and Rb that both now wind
-        // up mapped to the same key S, we would append the linked
-        // list for Ra onto the end of the linked list for Rb (or vice
-        // versa) -- this basically just requires rewriting the final
-        // link from one list to point at the othe other (see
-        // `append_list`).
+        // For example if we had two keys `Ra` and `Rb` that both now
+        // wind up mapped to the same key `S`, we would append the
+        // linked list for `Ra` onto the end of the linked list for
+        // `Rb` (or vice versa) -- this basically just requires
+        // rewriting the final link from one list to point at the othe
+        // other (see `append_list`).
 
         let MemberConstraintSet { first_constraints, mut constraints, choice_regions } = self;
 
@@ -140,7 +149,7 @@ impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
     }
 }
 
-impl<'tcx, R> MemberConstraintSet<'tcx, R>
+impl<R> MemberConstraintSet<'tcx, R>
 where
     R: Copy + Hash + Eq,
 {
@@ -169,7 +178,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R>
     }
 
     /// Returns the "choice regions" for a given member
-    /// constraint. This is the R1..Rn from a constraint like:
+    /// constraint. This is the `R1..Rn` from a constraint like:
     ///
     /// ```
     /// R0 member of [R1..Rn]
index b3649b2179fff2fbbd69bb977c042ecdb905b5f4..9e08961f440f2ab42ae1c05eac54047e31c53228 100644 (file)
@@ -221,7 +221,7 @@ fn find_constraint_paths_between_regions(
                 .outgoing_edges(r, &self.constraints, fr_static);
 
 
-            // But pick-constraints can also give rise to `'r: 'x`
+            // But member constraints can also give rise to `'r: 'x`
             // edges that were not part of the graph initially, so
             // watch out for those.
             let outgoing_edges_from_picks = self.applied_member_constraints(r)
index 78f6e731ce2442e476b72db873d21fa8c5b71a28..7e83ea2aa4ed98ee7097fee4ebb9900dd7498ad0 100644 (file)
@@ -75,7 +75,7 @@ pub struct RegionInferenceContext<'tcx> {
     /// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
     member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>,
 
-    /// Records the pick-constraints that we applied to each scc.
+    /// Records the member constraints that we applied to each scc.
     /// This is useful for error reporting. Once constraint
     /// propagation is done, this vector is sorted according to
     /// `member_region_scc`.
@@ -447,7 +447,7 @@ pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
     }
 
     /// Once region solving has completed, this function will return
-    /// the pick-constraints that were applied to the value of a given
+    /// the member constraints that were applied to the value of a given
     /// region `r`. See `AppliedMemberConstraint`.
     fn applied_member_constraints(&self, r: impl ToRegionVid) -> &[AppliedMemberConstraint] {
         let scc = self.constraint_sccs.scc(r.to_region_vid());
@@ -598,7 +598,7 @@ fn propagate_constraint_sccs_new(
             }
         }
 
-        // Now take member constraints into account
+        // Now take member constraints into account
         let member_constraints = self.member_constraints.clone();
         for m_c_i in member_constraints.indices(scc_a) {
             self.apply_member_constraint(
@@ -615,7 +615,7 @@ fn propagate_constraint_sccs_new(
         );
     }
 
-    /// Invoked for each `member R0 of [R1..Rn]` constraint.
+    /// Invoked for each `R0 member of [R1..Rn]` constraint.
     ///
     /// `scc` is the SCC containing R0, and `choice_regions` are the
     /// `R1..Rn` regions -- they are always known to be universal
@@ -659,16 +659,16 @@ fn apply_member_constraint(
         assert!(self.scc_universes[scc] == ty::UniverseIndex::ROOT);
         debug_assert!(
             self.scc_values.placeholders_contained_in(scc).next().is_none(),
-            "scc {:?} in a pick-constraint has placeholder value: {:?}",
+            "scc {:?} in a member constraint has placeholder value: {:?}",
             scc,
             self.scc_values.region_value_str(scc),
         );
 
         // The existing value for `scc` is a lower-bound. This will
-        // consist of some set {P} + {LB} of points {P} and
-        // lower-bound free regions {LB}. As each choice region O is a
-        // free region, it will outlive the points. But we can only
-        // consider the option O if O: LB.
+        // consist of some set `{P} + {LB}` of points `{P}` and
+        // lower-bound free regions `{LB}`. As each choice region `O`
+        // is a free region, it will outlive the points. But we can
+        // only consider the option `O` if `O: LB`.
         choice_regions.retain(|&o_r| {
             self.scc_values
                 .universal_regions_outlived_by(scc)
@@ -677,8 +677,8 @@ fn apply_member_constraint(
         debug!("apply_member_constraint: after lb, choice_regions={:?}", choice_regions);
 
         // Now find all the *upper bounds* -- that is, each UB is a
-        // free region that must outlive the member region R0 (`UB:
-        // R0`). Therefore, we need only keep an option O if `UB: O`
+        // free region that must outlive the member region `R0` (`UB:
+        // R0`). Therefore, we need only keep an option `O` if `UB: O`
         // for all UB.
         if choice_regions.len() > 1 {
             let universal_region_relations = self.universal_region_relations.clone();
@@ -755,7 +755,7 @@ fn upper_bounds(
         // I wanted to return an `impl Iterator` here, but it's
         // annoying because the `rev_constraint_graph` is in a local
         // variable. We'd need a "once-cell" or some such thing to let
-        // us borrow it for the right amount of time.
+        // us borrow it for the right amount of time. -- nikomatsakis
         let rev_constraint_graph = self.rev_constraint_graph();
         let scc_values = &self.scc_values;
         let mut duplicates = FxHashSet::default();