@@ -24,20 +24,19 @@ The MIR-based region analysis consists of two major functions:
24
24
- [ ` compute_regions ` ] , invoked second: this is given as argument the
25
25
results of move analysis. It has the job of computing values for all
26
26
the inference variables that ` replace_regions_in_mir ` introduced.
27
- - To do that, it first runs the [ MIR type checker] . This
28
- is basically a normal type-checker but specialized to MIR, which
29
- is much simpler than full Rust, of course. Running the MIR type
30
- checker will however create ** outlives constraints** between
31
- region variables (e.g., that one variable must outlive another
32
- one) to reflect the subtyping relationships that arise.
33
- - It also adds ** liveness constraints** that arise from where variables
34
- are used.
35
- - After this, we create a [ ` RegionInferenceContext ` ] with the constraints we
36
- have computed and the inference variables we introduced and use the
37
- [ ` solve ` ] method to infer values for all region inference varaibles.
27
+ - To do that, it first runs the [ MIR type checker] . This is
28
+ basically a normal type-checker but specialized to MIR, which is
29
+ much simpler than full Rust, of course. Running the MIR type
30
+ checker will however create various [ constraints] [ cp ] between region
31
+ variables, indicating their potential values and relationships to
32
+ one another.
33
+ - After this, we perform [ constraint propagation] [ cp ] by creating a
34
+ [ ` RegionInferenceContext ` ] and invoking its [ ` solve ` ]
35
+ method.
38
36
- The [ NLL RFC] also includes fairly thorough (and hopefully readable)
39
37
coverage.
40
38
39
+ [ cp ] : ./region_inference/constraint_propagation.html
41
40
[ fvb ] : ../appendix/background.html#free-vs-bound
42
41
[ `replace_regions_in_mir` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/fn.replace_regions_in_mir.html
43
42
[ `compute_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/fn.compute_regions.html
@@ -105,8 +104,10 @@ The kinds of region elements are as follows:
105
104
106
105
## Constraints
107
106
108
- Before we can infer the value of regions, we need to collect constraints on the
109
- regions. There are two primary types of constraints.
107
+ Before we can infer the value of regions, we need to collect
108
+ constraints on the regions. The full set of constraints is described
109
+ in [ the section on constraint propagation] [ cp ] , but the two most
110
+ common sorts of constraints are:
110
111
111
112
1 . Outlives constraints. These are constraints that one region outlives another
112
113
(e.g. ` 'a: 'b ` ). Outlives constraints are generated by the [ MIR type
0 commit comments