Skip to content

Commit a555d49

Browse files
authored
Add doc comments to librustc/infer/region_inference/mod.rs
1 parent 6f8426a commit a555d49

File tree

1 file changed

+66
-65
lines changed
  • src/librustc/infer/region_inference

1 file changed

+66
-65
lines changed

src/librustc/infer/region_inference/mod.rs

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ use std::u32;
3535

3636
mod graphviz;
3737

38-
// A constraint that influences the inference process.
38+
/// A constraint that influences the inference process.
3939
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
4040
pub enum Constraint<'tcx> {
41-
// One region variable is subregion of another
41+
/// One region variable is subregion of another
4242
ConstrainVarSubVar(RegionVid, RegionVid),
4343

44-
// Concrete region is subregion of region variable
44+
/// Concrete region is subregion of region variable
4545
ConstrainRegSubVar(Region<'tcx>, RegionVid),
4646

47-
// Region variable is subregion of concrete region. This does not
48-
// directly affect inference, but instead is checked after
49-
// inference is complete.
47+
/// Region variable is subregion of concrete region. This does not
48+
/// directly affect inference, but instead is checked after
49+
/// inference is complete.
5050
ConstrainVarSubReg(RegionVid, Region<'tcx>),
5151

52-
// A constraint where neither side is a variable. This does not
53-
// directly affect inference, but instead is checked after
54-
// inference is complete.
52+
/// A constraint where neither side is a variable. This does not
53+
/// directly affect inference, but instead is checked after
54+
/// inference is complete.
5555
ConstrainRegSubReg(Region<'tcx>, Region<'tcx>),
5656
}
5757

58-
// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
59-
// associated type) must outlive the region `R`. `T` is known to
60-
// outlive `RS`. Therefore verify that `R <= RS[i]` for some
61-
// `i`. Inference variables may be involved (but this verification
62-
// step doesn't influence inference).
58+
/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
59+
/// associated type) must outlive the region `R`. `T` is known to
60+
/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
61+
/// `i`. Inference variables may be involved (but this verification
62+
/// step doesn't influence inference).
6363
#[derive(Debug)]
6464
pub struct Verify<'tcx> {
6565
kind: GenericKind<'tcx>,
@@ -74,29 +74,29 @@ pub enum GenericKind<'tcx> {
7474
Projection(ty::ProjectionTy<'tcx>),
7575
}
7676

77-
// When we introduce a verification step, we wish to test that a
78-
// particular region (let's call it `'min`) meets some bound.
79-
// The bound is described the by the following grammar:
77+
/// When we introduce a verification step, we wish to test that a
78+
/// particular region (let's call it `'min`) meets some bound.
79+
/// The bound is described the by the following grammar:
8080
#[derive(Debug)]
8181
pub enum VerifyBound<'tcx> {
82-
// B = exists {R} --> some 'r in {R} must outlive 'min
83-
//
84-
// Put another way, the subject value is known to outlive all
85-
// regions in {R}, so if any of those outlives 'min, then the
86-
// bound is met.
82+
/// B = exists {R} --> some 'r in {R} must outlive 'min
83+
///
84+
/// Put another way, the subject value is known to outlive all
85+
/// regions in {R}, so if any of those outlives 'min, then the
86+
/// bound is met.
8787
AnyRegion(Vec<Region<'tcx>>),
8888

89-
// B = forall {R} --> all 'r in {R} must outlive 'min
90-
//
91-
// Put another way, the subject value is known to outlive some
92-
// region in {R}, so if all of those outlives 'min, then the bound
93-
// is met.
89+
/// B = forall {R} --> all 'r in {R} must outlive 'min
90+
///
91+
/// Put another way, the subject value is known to outlive some
92+
/// region in {R}, so if all of those outlives 'min, then the bound
93+
/// is met.
9494
AllRegions(Vec<Region<'tcx>>),
9595

96-
// B = exists {B} --> 'min must meet some bound b in {B}
96+
/// B = exists {B} --> 'min must meet some bound b in {B}
9797
AnyBound(Vec<VerifyBound<'tcx>>),
9898

99-
// B = forall {B} --> 'min must meet all bounds b in {B}
99+
/// B = forall {B} --> 'min must meet all bounds b in {B}
100100
AllBounds(Vec<VerifyBound<'tcx>>),
101101
}
102102

@@ -183,56 +183,57 @@ pub struct RegionVarBindings<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
183183
tcx: TyCtxt<'a, 'gcx, 'tcx>,
184184
var_origins: RefCell<Vec<RegionVariableOrigin>>,
185185

186-
// Constraints of the form `A <= B` introduced by the region
187-
// checker. Here at least one of `A` and `B` must be a region
188-
// variable.
186+
/// Constraints of the form `A <= B` introduced by the region
187+
/// checker. Here at least one of `A` and `B` must be a region
188+
/// variable.
189189
constraints: RefCell<FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>>,
190190

191-
// A "verify" is something that we need to verify after inference is
192-
// done, but which does not directly affect inference in any way.
193-
//
194-
// An example is a `A <= B` where neither `A` nor `B` are
195-
// inference variables.
191+
/// A "verify" is something that we need to verify after inference is
192+
/// done, but which does not directly affect inference in any way.
193+
///
194+
/// An example is a `A <= B` where neither `A` nor `B` are
195+
/// inference variables.
196196
verifys: RefCell<Vec<Verify<'tcx>>>,
197197

198-
// A "given" is a relationship that is known to hold. In particular,
199-
// we often know from closure fn signatures that a particular free
200-
// region must be a subregion of a region variable:
201-
//
202-
// foo.iter().filter(<'a> |x: &'a &'b T| ...)
203-
//
204-
// In situations like this, `'b` is in fact a region variable
205-
// introduced by the call to `iter()`, and `'a` is a bound region
206-
// on the closure (as indicated by the `<'a>` prefix). If we are
207-
// naive, we wind up inferring that `'b` must be `'static`,
208-
// because we require that it be greater than `'a` and we do not
209-
// know what `'a` is precisely.
210-
//
211-
// This hashmap is used to avoid that naive scenario. Basically we
212-
// record the fact that `'a <= 'b` is implied by the fn signature,
213-
// and then ignore the constraint when solving equations. This is
214-
// a bit of a hack but seems to work.
198+
/// A "given" is a relationship that is known to hold. In particular,
199+
/// we often know from closure fn signatures that a particular free
200+
/// region must be a subregion of a region variable:
201+
///
202+
/// foo.iter().filter(<'a> |x: &'a &'b T| ...)
203+
///
204+
/// In situations like this, `'b` is in fact a region variable
205+
/// introduced by the call to `iter()`, and `'a` is a bound region
206+
/// on the closure (as indicated by the `<'a>` prefix). If we are
207+
/// naive, we wind up inferring that `'b` must be `'static`,
208+
/// because we require that it be greater than `'a` and we do not
209+
/// know what `'a` is precisely.
210+
///
211+
/// This hashmap is used to avoid that naive scenario. Basically we
212+
/// record the fact that `'a <= 'b` is implied by the fn signature,
213+
/// and then ignore the constraint when solving equations. This is
214+
/// a bit of a hack but seems to work.
215215
givens: RefCell<FxHashSet<(Region<'tcx>, ty::RegionVid)>>,
216216

217217
lubs: RefCell<CombineMap<'tcx>>,
218218
glbs: RefCell<CombineMap<'tcx>>,
219219
skolemization_count: Cell<u32>,
220220
bound_count: Cell<u32>,
221221

222-
// The undo log records actions that might later be undone.
223-
//
224-
// Note: when the undo_log is empty, we are not actively
225-
// snapshotting. When the `start_snapshot()` method is called, we
226-
// push an OpenSnapshot entry onto the list to indicate that we
227-
// are now actively snapshotting. The reason for this is that
228-
// otherwise we end up adding entries for things like the lower
229-
// bound on a variable and so forth, which can never be rolled
230-
// back.
222+
/// The undo log records actions that might later be undone.
223+
///
224+
/// Note: when the undo_log is empty, we are not actively
225+
/// snapshotting. When the `start_snapshot()` method is called, we
226+
/// push an OpenSnapshot entry onto the list to indicate that we
227+
/// are now actively snapshotting. The reason for this is that
228+
/// otherwise we end up adding entries for things like the lower
229+
/// bound on a variable and so forth, which can never be rolled
230+
/// back.
231231
undo_log: RefCell<Vec<UndoLogEntry<'tcx>>>,
232+
232233
unification_table: RefCell<UnificationTable<ty::RegionVid>>,
233234

234-
// This contains the results of inference. It begins as an empty
235-
// option and only acquires a value after inference is complete.
235+
/// This contains the results of inference. It begins as an empty
236+
/// option and only acquires a value after inference is complete.
236237
values: RefCell<Option<Vec<VarValue<'tcx>>>>,
237238
}
238239

0 commit comments

Comments
 (0)