forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#57652 - mark-i-m:remove-old, r=nikomatsakis
Update/remove some old readmes r? @nikomatsakis cc rust-lang#48478 There are a bunch of READMEs with content that I would like to see a final decision made on: - https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query - https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph - https://github.com/rust-lang/rust/blob/master/src/librustc/infer/region_constraints - https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked - https://github.com/rust-lang/rust/tree/master/src/librustc/infer/lexical_region_resolve - https://github.com/rust-lang/rust/blob/master/src/librustc_borrowck/borrowck It's not clear how useful or obsolete any of these are. I would really appreciate if the appropriate domain experts for each of these could respond with one of (a) delete it, (b) wait for system to be remove, or (c) move it to rustc-guide. @nikomatsakis do you know who to ping for any of these (sorry, I suspect many of them are you)?
- Loading branch information
Showing
7 changed files
with
93 additions
and
864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,3 @@ | ||
# Region constraint collection | ||
|
||
> WARNING: This README is obsolete and will be removed soon! For | ||
> more info on how the current borrowck works, see the [rustc guide]. | ||
For info on how the current borrowck works, see the [rustc guide]. | ||
|
||
[rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html | ||
|
||
## Terminology | ||
|
||
Note that we use the terms region and lifetime interchangeably. | ||
|
||
## Introduction | ||
|
||
As described in the rustc guide [chapter on type inference][ti], and unlike | ||
normal type inference, which is similar in spirit to H-M and thus | ||
works progressively, the region type inference works by accumulating | ||
constraints over the course of a function. Finally, at the end of | ||
processing a function, we process and solve the constraints all at | ||
once. | ||
|
||
[ti]: https://rust-lang.github.io/rustc-guide/type-inference.html | ||
|
||
The constraints are always of one of three possible forms: | ||
|
||
- `ConstrainVarSubVar(Ri, Rj)` states that region variable Ri must be | ||
a subregion of Rj | ||
- `ConstrainRegSubVar(R, Ri)` states that the concrete region R (which | ||
must not be a variable) must be a subregion of the variable Ri | ||
- `ConstrainVarSubReg(Ri, R)` states the variable Ri should be less | ||
than the concrete region R. This is kind of deprecated and ought to | ||
be replaced with a verify (they essentially play the same role). | ||
|
||
In addition to constraints, we also gather up a set of "verifys" | ||
(what, you don't think Verify is a noun? Get used to it my | ||
friend!). These represent relations that must hold but which don't | ||
influence inference proper. These take the form of: | ||
|
||
- `VerifyRegSubReg(Ri, Rj)` indicates that Ri <= Rj must hold, | ||
where Rj is not an inference variable (and Ri may or may not contain | ||
one). This doesn't influence inference because we will already have | ||
inferred Ri to be as small as possible, so then we just test whether | ||
that result was less than Rj or not. | ||
- `VerifyGenericBound(R, Vb)` is a more complex expression which tests | ||
that the region R must satisfy the bound `Vb`. The bounds themselves | ||
may have structure like "must outlive one of the following regions" | ||
or "must outlive ALL of the following regions. These bounds arise | ||
from constraints like `T: 'a` -- if we know that `T: 'b` and `T: 'c` | ||
(say, from where clauses), then we can conclude that `T: 'a` if `'b: | ||
'a` *or* `'c: 'a`. | ||
|
||
## Building up the constraints | ||
|
||
Variables and constraints are created using the following methods: | ||
|
||
- `new_region_var()` creates a new, unconstrained region variable; | ||
- `make_subregion(Ri, Rj)` states that Ri is a subregion of Rj | ||
- `lub_regions(Ri, Rj) -> Rk` returns a region Rk which is | ||
the smallest region that is greater than both Ri and Rj | ||
- `glb_regions(Ri, Rj) -> Rk` returns a region Rk which is | ||
the greatest region that is smaller than both Ri and Rj | ||
|
||
The actual region resolution algorithm is not entirely | ||
obvious, though it is also not overly complex. | ||
|
||
## Snapshotting | ||
|
||
It is also permitted to try (and rollback) changes to the graph. This | ||
is done by invoking `start_snapshot()`, which returns a value. Then | ||
later you can call `rollback_to()` which undoes the work. | ||
Alternatively, you can call `commit()` which ends all snapshots. | ||
Snapshots can be recursive---so you can start a snapshot when another | ||
is in progress, but only the root snapshot can "commit". | ||
|
||
## Skolemization | ||
|
||
For a discussion on skolemization and higher-ranked subtyping, please | ||
see the module `middle::infer::higher_ranked::doc`. |
Oops, something went wrong.