a few updates

This commit is contained in:
Mark Mansi 2018-12-11 14:46:35 -06:00
parent 94b006e20d
commit 53ab47354e
1 changed files with 23 additions and 9 deletions

View File

@ -48,26 +48,40 @@ The MIR-based region analysis consists of two major functions:
## Universal regions ## Universal regions
The [`UnversalRegions`] type represents a collection of _unversal_ regions The [`UnversalRegions`] type represents a collection of _universal_ regions
corresponding to some MIR `DefId`. It is constructed in corresponding to some MIR `DefId`. It is constructed in
[`replace_regions_in_mir`] when we replace all regions with fresh inference [`replace_regions_in_mir`] when we replace all regions with fresh inference
variables. [`UniversalRegions`] contains indices for all the free regions in variables. [`UniversalRegions`] contains indices for all the free regions in
the given MIR along with any relationships that are _known_ to hold between the given MIR along with any relationships that are _known_ to hold between
them (e.g. implied bounds, where clauses, etc.). them (e.g. implied bounds, where clauses, etc.).
TODO: is there more to write here? For example, given the MIR for the following function:
```rust
fn foo<'a>(x: &'a u32) {
// ...
}
```
we would create a universal region for `'a` and one for `'static`. There may
also be some complications for handling closures, but we will ignore those for
the moment.
TODO: write about _how_ these regions are computed.
[`UniversalRegions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/universal_regions/struct.UniversalRegions.html [`UniversalRegions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/universal_regions/struct.UniversalRegions.html
## Region variables ## Region variables
The value of a region can be thought of as a **set** of points in the MIR where The value of a region can be thought of as a **set**. This set contains all
the region is valid; we call the domain of this set a `RegionElement`. In the points in the MIR where the region is valid along with any regions that are
code, the value for all regions is maintained in outlived by this region (e.g. if `'a: 'b`, then `end('b)` is in the set for
[the `rustc_mir::borrow_check::nll::region_infer` module][ri]. For `'a`); we call the domain of this set a `RegionElement`. In the code, the value
each region we maintain a set storing what elements are present in its for all regions is maintained in [the
value (to make this efficient, we give each kind of element an index, `rustc_mir::borrow_check::nll::region_infer` module][ri]. For each region we
the `RegionElementIndex`, and use sparse bitsets). maintain a set storing what elements are present in its value (to make this
efficient, we give each kind of element an index, the `RegionElementIndex`, and
use sparse bitsets).
[ri]: https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/nll/region_infer/ [ri]: https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/nll/region_infer/