@@ -48,26 +48,40 @@ The MIR-based region analysis consists of two major functions:
48
48
49
49
## Universal regions
50
50
51
- The [ ` UnversalRegions ` ] type represents a collection of _ unversal _ regions
51
+ The [ ` UnversalRegions ` ] type represents a collection of _ universal _ regions
52
52
corresponding to some MIR ` DefId ` . It is constructed in
53
53
[ ` replace_regions_in_mir ` ] when we replace all regions with fresh inference
54
54
variables. [ ` UniversalRegions ` ] contains indices for all the free regions in
55
55
the given MIR along with any relationships that are _ known_ to hold between
56
56
them (e.g. implied bounds, where clauses, etc.).
57
57
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.
59
71
60
72
[ `UniversalRegions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/universal_regions/struct.UniversalRegions.html
61
73
62
74
## Region variables
63
75
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).
71
85
72
86
[ ri ] : https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/nll/region_infer/
73
87
0 commit comments