@@ -35,31 +35,31 @@ use std::u32;
35
35
36
36
mod graphviz;
37
37
38
- // A constraint that influences the inference process.
38
+ /// A constraint that influences the inference process.
39
39
#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
40
40
pub enum Constraint < ' tcx > {
41
- // One region variable is subregion of another
41
+ /// One region variable is subregion of another
42
42
ConstrainVarSubVar ( RegionVid , RegionVid ) ,
43
43
44
- // Concrete region is subregion of region variable
44
+ /// Concrete region is subregion of region variable
45
45
ConstrainRegSubVar ( Region < ' tcx > , RegionVid ) ,
46
46
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.
50
50
ConstrainVarSubReg ( RegionVid , Region < ' tcx > ) ,
51
51
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.
55
55
ConstrainRegSubReg ( Region < ' tcx > , Region < ' tcx > ) ,
56
56
}
57
57
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).
63
63
#[ derive( Debug ) ]
64
64
pub struct Verify < ' tcx > {
65
65
kind : GenericKind < ' tcx > ,
@@ -74,29 +74,29 @@ pub enum GenericKind<'tcx> {
74
74
Projection ( ty:: ProjectionTy < ' tcx > ) ,
75
75
}
76
76
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:
80
80
#[ derive( Debug ) ]
81
81
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.
87
87
AnyRegion ( Vec < Region < ' tcx > > ) ,
88
88
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.
94
94
AllRegions ( Vec < Region < ' tcx > > ) ,
95
95
96
- // B = exists {B} --> 'min must meet some bound b in {B}
96
+ /// B = exists {B} --> 'min must meet some bound b in {B}
97
97
AnyBound ( Vec < VerifyBound < ' tcx > > ) ,
98
98
99
- // B = forall {B} --> 'min must meet all bounds b in {B}
99
+ /// B = forall {B} --> 'min must meet all bounds b in {B}
100
100
AllBounds ( Vec < VerifyBound < ' tcx > > ) ,
101
101
}
102
102
@@ -183,56 +183,57 @@ pub struct RegionVarBindings<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
183
183
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
184
184
var_origins : RefCell < Vec < RegionVariableOrigin > > ,
185
185
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.
189
189
constraints : RefCell < FxHashMap < Constraint < ' tcx > , SubregionOrigin < ' tcx > > > ,
190
190
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.
196
196
verifys : RefCell < Vec < Verify < ' tcx > > > ,
197
197
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.
215
215
givens : RefCell < FxHashSet < ( Region < ' tcx > , ty:: RegionVid ) > > ,
216
216
217
217
lubs : RefCell < CombineMap < ' tcx > > ,
218
218
glbs : RefCell < CombineMap < ' tcx > > ,
219
219
skolemization_count : Cell < u32 > ,
220
220
bound_count : Cell < u32 > ,
221
221
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.
231
231
undo_log : RefCell < Vec < UndoLogEntry < ' tcx > > > ,
232
+
232
233
unification_table : RefCell < UnificationTable < ty:: RegionVid > > ,
233
234
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.
236
237
values : RefCell < Option < Vec < VarValue < ' tcx > > > > ,
237
238
}
238
239
0 commit comments