@@ -48,26 +48,40 @@ The MIR-based region analysis consists of two major functions:
4848
4949## Universal regions
5050
51- The [ ` UnversalRegions ` ] type represents a collection of _ unversal _ regions
51+ The [ ` UnversalRegions ` ] type represents a collection of _ universal _ regions
5252corresponding to some MIR ` DefId ` . It is constructed in
5353[ ` replace_regions_in_mir ` ] when we replace all regions with fresh inference
5454variables. [ ` UniversalRegions ` ] contains indices for all the free regions in
5555the given MIR along with any relationships that are _ known_ to hold between
5656them (e.g. implied bounds, where clauses, etc.).
5757
58- TODO: is there more to write here?
58+ For example, given the MIR for the following function:
59+
60+ ``` rust
61+ fn foo <'a >(x : & 'a u32 ) {
62+ // ...
63+ }
64+ ```
65+
66+ we would create a universal region for ` 'a ` and one for ` 'static ` . There may
67+ also be some complications for handling closures, but we will ignore those for
68+ the moment.
69+
70+ TODO: write about _ how_ these regions are computed.
5971
6072[ `UniversalRegions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/universal_regions/struct.UniversalRegions.html
6173
6274## Region variables
6375
64- The value of a region can be thought of as a ** set** of points in the MIR where
65- the region is valid; we call the domain of this set a ` RegionElement ` . In the
66- code, the value for all regions is maintained in
67- [ the ` rustc_mir::borrow_check::nll::region_infer ` module] [ ri ] . For
68- each region we maintain a set storing what elements are present in its
69- value (to make this efficient, we give each kind of element an index,
70- the ` RegionElementIndex ` , and use sparse bitsets).
76+ The value of a region can be thought of as a ** set** . This set contains all
77+ points in the MIR where the region is valid along with any regions that are
78+ outlived by this region (e.g. if ` 'a: 'b ` , then ` end('b) ` is in the set for
79+ ` 'a ` ); we call the domain of this set a ` RegionElement ` . In the code, the value
80+ for all regions is maintained in [ the
81+ ` rustc_mir::borrow_check::nll::region_infer ` module] [ ri ] . For each region we
82+ maintain a set storing what elements are present in its value (to make this
83+ efficient, we give each kind of element an index, the ` RegionElementIndex ` , and
84+ use sparse bitsets).
7185
7286[ ri ] : https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/nll/region_infer/
7387
0 commit comments