extract regions
This commit is contained in:
parent
623c6246e9
commit
e53f21a45b
|
|
@ -218,29 +218,33 @@ algorithms.
|
||||||
[`region_constraints`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/region_constraints/index.html
|
[`region_constraints`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/region_constraints/index.html
|
||||||
[`opportunistic_resolve_var`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/region_constraints/struct.RegionConstraintCollector.html#method.opportunistic_resolve_var
|
[`opportunistic_resolve_var`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/region_constraints/struct.RegionConstraintCollector.html#method.opportunistic_resolve_var
|
||||||
|
|
||||||
## Extracting region constraints
|
## Solving region constraints
|
||||||
|
|
||||||
Ultimately, region constraints are only solved at the very end of
|
Region constraints are only solved at the very end of
|
||||||
type-checking, once all other constraints are known. There are two
|
typechecking, once all other constraints are known and
|
||||||
|
all other obligations have been proven. There are two
|
||||||
ways to solve region constraints right now: lexical and
|
ways to solve region constraints right now: lexical and
|
||||||
non-lexical. Eventually there will only be one.
|
non-lexical. Eventually there will only be one.
|
||||||
|
|
||||||
|
An exception here is the leak-check which is used during trait solving
|
||||||
|
and relies on region constraints containing higher-ranked regions. Region
|
||||||
|
constraints in the root universe (i.e. not arising from a `for<'a>`) must
|
||||||
|
not influence the trait system, as these regions are all erased during
|
||||||
|
codegen.
|
||||||
|
|
||||||
To solve **lexical** region constraints, you invoke
|
To solve **lexical** region constraints, you invoke
|
||||||
[`resolve_regions_and_report_errors`]. This "closes" the region
|
[`resolve_regions_and_report_errors`]. This "closes" the region
|
||||||
constraint process and invokes the [`lexical_region_resolve`] code. Once
|
constraint process and invokes the [`lexical_region_resolve`] code. Once
|
||||||
this is done, any further attempt to equate or create a subtyping
|
this is done, any further attempt to equate or create a subtyping
|
||||||
relationship will yield an ICE.
|
relationship will yield an ICE.
|
||||||
|
|
||||||
Non-lexical region constraints are not handled within the inference
|
The NLL solver (actually, the MIR type-checker) invokes does things slightly
|
||||||
context. Instead, the NLL solver (actually, the MIR type-checker)
|
differently. It uses canonical queries for trait solving which use
|
||||||
invokes [`take_and_reset_region_constraints`] periodically. This
|
[`take_and_reset_region_constraints`] at the end. This extracts all of the
|
||||||
extracts all of the outlives constraints from the region solver, but
|
outlives constraints added during the canonical query. This is required
|
||||||
leaves the set of variables intact. This is used to get *just* the
|
as the NLL solver must not only know *what* regions outlive each other,
|
||||||
region constraints that resulted from some particular point in the
|
but also *where*. Finally, the NLL solver invokes [`take_region_var_origins`],
|
||||||
program, since the NLL solver needs to know not just *what* regions
|
providing all region variables to the solver.
|
||||||
were subregions, but also *where*. Finally, the NLL solver invokes
|
|
||||||
[`take_region_var_origins`], which "closes" the region constraint
|
|
||||||
process in the same way as normal solving.
|
|
||||||
|
|
||||||
[`resolve_regions_and_report_errors`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.resolve_regions_and_report_errors
|
[`resolve_regions_and_report_errors`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.resolve_regions_and_report_errors
|
||||||
[`lexical_region_resolve`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/lexical_region_resolve/index.html
|
[`lexical_region_resolve`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/lexical_region_resolve/index.html
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue