Skip to content
Permalink
Browse files

more centril nits

  • Loading branch information...
nikomatsakis committed Jun 24, 2019
1 parent d9f4d2a commit 0dd074e8548ce386d38e647a47d41ec75c93f307
@@ -27,7 +27,7 @@ impl<N: Idx> VecGraph<N> {

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
@@ -8,18 +8,18 @@ use std::ops::Index;
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
@@ -38,10 +38,10 @@ crate struct NllMemberConstraint<'tcx> {
/// 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 @@ impl Default for MemberConstraintSet<'tcx, ty::RegionVid> {
}

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 @@ where
// 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 @@ where
}
}

impl<'tcx, R> MemberConstraintSet<'tcx, R>
impl<R> MemberConstraintSet<'tcx, R>
where
R: Copy + Hash + Eq,
{
@@ -169,7 +178,7 @@ where
}

/// 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]
@@ -221,7 +221,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
.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)
@@ -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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// 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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
}

// 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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
);
}

/// 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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
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 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// 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();

0 comments on commit 0dd074e

Please sign in to comment.
You can’t perform that action at this time.