diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-08-08 14:36:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-08 14:36:40 -0400 |
| commit | e5f32effa9e3384c1f511e472a3cd407696e23c5 (patch) | |
| tree | 6722281074a2dad51a73db6a60041ed200105ad7 | |
| parent | ffe336d07b73d391563775220a913b01e1d17d1f (diff) | |
| download | rust-e5f32effa9e3384c1f511e472a3cd407696e23c5.tar.gz rust-e5f32effa9e3384c1f511e472a3cd407696e23c5.zip | |
add comment
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/region_infer/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index c6f3efc4038..0798a45b3be 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -645,6 +645,30 @@ impl<'tcx> RegionInferenceContext<'tcx> { } } + /// Invoked when we have some type-test (e.g., `T: 'X`) that we cannot + /// prove to be satisfied. If this is a closure, we will attempt to + /// "promote" this type-test into our `ClosureRegionRequirements` and + /// hence pass it up the creator. To do this, we have to phrase the + /// type-test in terms of external free regions, as local free + /// regions are not nameable by the closure's creator. + /// + /// Promotion works as follows: we first check that the type `T` + /// contains only regions that the creator knows about. If this is + /// true, then -- as a consequence -- we know that all regions in + /// the type `T` are free regions that outlive the closure body. If + /// false, then promotion fails. + /// + /// Once we've promoted T, we have to "promote" `'X` to some region + /// that is "external" to the closure. Generally speaking, a region + /// may be the union of some points in the closure body as well as + /// various free lifetimes. We can ignore the points in the closure + /// body: if the type T can be expressed in terms of external regions, + /// we know it outlives the points in the closure body. That + /// just leaves the free regions. + /// + /// The idea then is to lower the `T: 'X` constraint into multiple + /// bounds -- e.g., if `'X` is the union of two free lifetimes, + /// `'1` and `'2`, then we would create `T: '1` and `T: '2`. fn try_promote_type_test<'gcx>( &self, infcx: &InferCtxt<'_, 'gcx, 'tcx>, |
