1
1
# Region inference (NLL)
2
2
3
- The MIR-based region checking code is located in
4
- [ the ` rustc_mir::borrow_check::nll ` module] [ nll ] . (NLL, of course,
5
- stands for "non-lexical lifetimes", a term that will hopefully be
6
- deprecated once they become the standard kind of lifetime.)
3
+ The MIR-based region checking code is located in [ the ` rustc_mir::borrow_check `
4
+ module] [ nll ] .
7
5
8
- [ nll ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ index.html
6
+ [ nll ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/index.html
9
7
10
8
The MIR-based region analysis consists of two major functions:
11
9
@@ -36,12 +34,12 @@ The MIR-based region analysis consists of two major functions:
36
34
- The [ NLL RFC] also includes fairly thorough (and hopefully readable)
37
35
coverage.
38
36
39
- [ cp ] : ./region_inference/constraint_propagation.html
40
- [ fvb ] : ../appendix/background.html #free-vs-bound
37
+ [ cp ] : ./region_inference/constraint_propagation.md
38
+ [ fvb ] : ../appendix/background.md #free-vs-bound
41
39
[ `replace_regions_in_mir` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/fn.replace_regions_in_mir.html
42
40
[ `compute_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/fn.compute_regions.html
43
- [ `RegionInferenceContext` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html
44
- [ `solve` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#method.solve
41
+ [ `RegionInferenceContext` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html
42
+ [ `solve` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#method.solve
45
43
[ NLL RFC ] : https://rust-lang.github.io/rfcs/2094-nll.html
46
44
[ MIR type checker ] : ./type_check.md
47
45
@@ -68,7 +66,7 @@ the moment.
68
66
69
67
TODO: write about _ how_ these regions are computed.
70
68
71
- [ `UniversalRegions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ universal_regions/struct.UniversalRegions.html
69
+ [ `UniversalRegions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/universal_regions/struct.UniversalRegions.html
72
70
73
71
<a name =" region-variables " ></a >
74
72
@@ -84,7 +82,7 @@ maintain a set storing what elements are present in its value (to make this
84
82
efficient, we give each kind of element an index, the ` RegionElementIndex ` , and
85
83
use sparse bitsets).
86
84
87
- [ ri ] : https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/nll/ region_infer/
85
+ [ ri ] : https://github.com/rust-lang/rust/tree/master/src/librustc_mir/borrow_check/region_infer/
88
86
89
87
The kinds of region elements are as follows:
90
88
@@ -115,7 +113,7 @@ common sorts of constraints are:
115
113
2 . Liveness constraints. Each region needs to be live at points where it can be
116
114
used. These constraints are collected by [ ` generate_constraints ` ] .
117
115
118
- [ `generate_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ constraint_generation/fn.generate_constraints.html
116
+ [ `generate_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/constraint_generation/fn.generate_constraints.html
119
117
120
118
## Inference Overview
121
119
@@ -219,12 +217,12 @@ Here are some of the fields of the struct:
219
217
- [ ` closure_bounds_mapping ` ] : used for propagating region constraints from
220
218
closures back out to the creator of the closure.
221
219
222
- [ `constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.constraints
223
- [ `liveness_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.liveness_constraints
224
- [ `universal_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.universal_regions
225
- [ `universal_region_relations` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.universal_region_relations
226
- [ `type_tests` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.type_tests
227
- [ `closure_bounds_mapping` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#structfield.closure_bounds_mapping
220
+ [ `constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.constraints
221
+ [ `liveness_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.liveness_constraints
222
+ [ `universal_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.universal_regions
223
+ [ `universal_region_relations` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.universal_region_relations
224
+ [ `type_tests` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.type_tests
225
+ [ `closure_bounds_mapping` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#structfield.closure_bounds_mapping
228
226
229
227
TODO: should we discuss any of the others fields? What about the SCCs?
230
228
@@ -233,6 +231,6 @@ inference. This is done by calling the [`solve`] method on the context. This
233
231
is where we call [ ` propagate_constraints ` ] and then check the resulting type
234
232
tests and universal regions, as discussed above.
235
233
236
- [ `propagate_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#method.propagate_constraints
237
- [ `check_type_tests` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#method.check_type_tests
238
- [ `check_universal_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/nll/ region_infer/struct.RegionInferenceContext.html#method.check_universal_regions
234
+ [ `propagate_constraints` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#method.propagate_constraints
235
+ [ `check_type_tests` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#method.check_type_tests
236
+ [ `check_universal_regions` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/borrow_check/region_infer/struct.RegionInferenceContext.html#method.check_universal_regions
0 commit comments