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`.
}
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>,
}
}
-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,
// 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;
}
}
-impl<'tcx, R> MemberConstraintSet<'tcx, R>
+impl<R> MemberConstraintSet<'tcx, R>
where
R: Copy + Hash + Eq,
{
}
/// 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]
/// 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`.
}
/// 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());
}
}
- // 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(
);
}
- /// 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
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)
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();
// 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();