@@ -114,24 +114,26 @@ pub struct InferCtxtInner<'tcx> {
114
114
float_unification_storage : ut:: UnificationTableStorage < ty:: FloatVid > ,
115
115
116
116
/// Tracks the set of region variables and the constraints between them.
117
+ ///
117
118
/// This is initially `Some(_)` but when
118
119
/// `resolve_regions_and_report_errors` is invoked, this gets set to `None`
119
120
/// -- further attempts to perform unification, etc., may fail if new
120
121
/// region constraints would've been added.
121
122
region_constraint_storage : Option < RegionConstraintStorage < ' tcx > > ,
122
123
123
- /// A set of constraints that regionck must validate. Each
124
- /// constraint has the form `T:'a`, meaning "some type `T` must
124
+ /// A set of constraints that regionck must validate.
125
+ ///
126
+ /// Each constraint has the form `T:'a`, meaning "some type `T` must
125
127
/// outlive the lifetime 'a". These constraints derive from
126
128
/// instantiated type parameters. So if you had a struct defined
127
- /// like
129
+ /// like the following:
128
130
/// ```ignore (illustrative)
129
- /// struct Foo<T:'static> { ... }
131
+ /// struct Foo<T: 'static> { ... }
130
132
/// ```
131
- /// then in some expression `let x = Foo { ... }` it will
133
+ /// In some expression `let x = Foo { ... }`, it will
132
134
/// instantiate the type parameter `T` with a fresh type `$0`. At
133
135
/// the same time, it will record a region obligation of
134
- /// `$0:'static`. This will get checked later by regionck. (We
136
+ /// `$0: 'static`. This will get checked later by regionck. (We
135
137
/// can't generally check these things right away because we have
136
138
/// to wait until types are resolved.)
137
139
///
@@ -268,7 +270,7 @@ pub struct InferCtxt<'tcx> {
268
270
/// Caches the results of trait evaluation.
269
271
pub evaluation_cache : select:: EvaluationCache < ' tcx > ,
270
272
271
- /// the set of predicates on which errors have been reported, to
273
+ /// The set of predicates on which errors have been reported, to
272
274
/// avoid reporting the same error twice.
273
275
pub reported_trait_errors : RefCell < FxIndexMap < Span , Vec < ty:: Predicate < ' tcx > > > > ,
274
276
@@ -291,7 +293,7 @@ pub struct InferCtxt<'tcx> {
291
293
tainted_by_errors : Cell < Option < ErrorGuaranteed > > ,
292
294
293
295
/// Track how many errors were reported when this infcx is created.
294
- /// If the number of errors increases, that's also a sign (line
296
+ /// If the number of errors increases, that's also a sign (like
295
297
/// `tainted_by_errors`) to avoid reporting certain kinds of errors.
296
298
// FIXME(matthewjasper) Merge into `tainted_by_errors`
297
299
err_count_on_creation : usize ,
@@ -313,7 +315,7 @@ pub struct InferCtxt<'tcx> {
313
315
/// During coherence we have to assume that other crates may add
314
316
/// additional impls which we currently don't know about.
315
317
///
316
- /// To deal with this evaluation should be conservative
318
+ /// To deal with this evaluation, we should be conservative
317
319
/// and consider the possibility of impls from outside this crate.
318
320
/// This comes up primarily when resolving ambiguity. Imagine
319
321
/// there is some trait reference `$0: Bar` where `$0` is an
@@ -323,7 +325,7 @@ pub struct InferCtxt<'tcx> {
323
325
/// bound to some type that in a downstream crate that implements
324
326
/// `Bar`.
325
327
///
326
- /// Outside of coherence we set this to false because we are only
328
+ /// Outside of coherence, we set this to false because we are only
327
329
/// interested in types that the user could actually have written.
328
330
/// In other words, we consider `$0: Bar` to be unimplemented if
329
331
/// there is no type that the user could *actually name* that
@@ -373,7 +375,7 @@ pub enum SubregionOrigin<'tcx> {
373
375
Subtype ( Box < TypeTrace < ' tcx > > ) ,
374
376
375
377
/// When casting `&'a T` to an `&'b Trait` object,
376
- /// relating `'a` to `'b`
378
+ /// relating `'a` to `'b`.
377
379
RelateObjectBound ( Span ) ,
378
380
379
381
/// Some type parameter was instantiated with the given type,
@@ -384,7 +386,7 @@ pub enum SubregionOrigin<'tcx> {
384
386
/// that must outlive some other region.
385
387
RelateRegionParamBound ( Span ) ,
386
388
387
- /// Creating a pointer `b` to contents of another reference
389
+ /// Creating a pointer `b` to contents of another reference.
388
390
Reborrow ( Span ) ,
389
391
390
392
/// (&'a &'b T) where a >= b
@@ -398,7 +400,7 @@ pub enum SubregionOrigin<'tcx> {
398
400
trait_item_def_id : DefId ,
399
401
} ,
400
402
401
- /// Checking that the bounds of a trait's associated type hold for a given impl
403
+ /// Checking that the bounds of a trait's associated type hold for a given impl.
402
404
CheckAssociatedTypeBounds {
403
405
parent : Box < SubregionOrigin < ' tcx > > ,
404
406
impl_item_def_id : LocalDefId ,
@@ -435,32 +437,33 @@ pub enum LateBoundRegionConversionTime {
435
437
AssocTypeProjection ( DefId ) ,
436
438
}
437
439
438
- /// Reasons to create a region inference variable
440
+ /// Reasons to create a region inference variable.
439
441
///
440
- /// See `error_reporting` module for more details
442
+ /// See `error_reporting` module for more details.
441
443
#[ derive( Copy , Clone , Debug ) ]
442
444
pub enum RegionVariableOrigin {
443
- /// Region variables created for ill-categorized reasons,
444
- /// mostly indicates places in need of refactoring
445
+ /// Region variables created for ill-categorized reasons.
446
+ ///
447
+ /// They mostly indicate places in need of refactoring.
445
448
MiscVariable ( Span ) ,
446
449
447
- /// Regions created by a `&P` or `[...]` pattern
450
+ /// Regions created by a `&P` or `[...]` pattern.
448
451
PatternRegion ( Span ) ,
449
452
450
- /// Regions created by `&` operator
453
+ /// Regions created by `&` operator.
454
+ ///
451
455
AddrOfRegion ( Span ) ,
452
-
453
- /// Regions created as part of an autoref of a method receiver
456
+ /// Regions created as part of an autoref of a method receiver.
454
457
Autoref ( Span ) ,
455
458
456
- /// Regions created as part of an automatic coercion
459
+ /// Regions created as part of an automatic coercion.
457
460
Coercion ( Span ) ,
458
461
459
- /// Region variables created as the values for early-bound regions
462
+ /// Region variables created as the values for early-bound regions.
460
463
EarlyBoundRegion ( Span , Symbol ) ,
461
464
462
465
/// Region variables created for bound regions
463
- /// in a function or method that is called
466
+ /// in a function or method that is called.
464
467
LateBoundRegion ( Span , ty:: BoundRegionKind , LateBoundRegionConversionTime ) ,
465
468
466
469
UpvarRegion ( ty:: UpvarId , Span ) ,
@@ -534,7 +537,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
534
537
}
535
538
}
536
539
537
- /// Used to configure inference contexts before their creation
540
+ /// Used to configure inference contexts before their creation.
538
541
pub struct InferCtxtBuilder < ' tcx > {
539
542
tcx : TyCtxt < ' tcx > ,
540
543
defining_use_anchor : DefiningAnchor ,
@@ -835,9 +838,9 @@ impl<'tcx> InferCtxt<'tcx> {
835
838
836
839
/// Scan the constraints produced since `snapshot` began and returns:
837
840
///
838
- /// - `None` -- if none of them involve "region outlives" constraints
839
- /// - `Some(true)` -- if there are `'a: 'b` constraints where `'a` or `'b` is a placeholder
840
- /// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders
841
+ /// - `None` -- if none of them involves "region outlives" constraints.
842
+ /// - `Some(true)` -- if there are `'a: 'b` constraints where `'a` or `'b` is a placeholder.
843
+ /// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders.
841
844
pub fn region_constraints_added_in_snapshot (
842
845
& self ,
843
846
snapshot : & CombinedSnapshot < ' tcx > ,
@@ -1770,7 +1773,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1770
1773
}
1771
1774
}
1772
1775
1773
- /// Helper for ` ty_or_const_infer_var_changed` (see comment on that), currently
1776
+ /// Helper for [InferCtxt:: ty_or_const_infer_var_changed] (see comment on that), currently
1774
1777
/// used only for `traits::fulfill`'s list of `stalled_on` inference variables.
1775
1778
#[ derive( Copy , Clone , Debug ) ]
1776
1779
pub enum TyOrConstInferVar < ' tcx > {
0 commit comments