Skip to content

Commit a07a6de

Browse files
csmoemark-i-m
authored andcommitted
clean up skolemiza in borrow_ck
1 parent 8759055 commit a07a6de

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/borrow_check/region_inference.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ The kinds of region elements are as follows:
7878
etc) control-flow graph.
7979
- Similarly, there is an element denoted `end('static)` corresponding
8080
to the remainder of program execution after this function returns.
81-
- There is an element `!1` for each skolemized region `!1`. This
81+
- There is an element `!1` for each placeholder region `!1`. This
8282
corresponds (intuitively) to some unknown set of other elements –
83-
for details on skolemization, see the section
84-
[skolemization and universes](#skol).
83+
for details on placeholder, see the section
84+
[placeholder and universes](#placeholder).
8585

8686
## Causal tracking
8787

8888
*to be written* – describe how we can extend the values of a variable
8989
with causal tracking etc
9090

91-
<a name="skol"></a>
91+
<a name="placeholder"></a>
9292

93-
## Skolemization and universes
93+
## Placeholders and universes
9494

9595
(This section describes ongoing work that hasn't landed yet.)
9696

@@ -117,7 +117,7 @@ for its argument, and `bar` wants to be given a function that that
117117
accepts **any** reference (so it can call it with something on its
118118
stack, for example). But *how* do we reject it and *why*?
119119

120-
### Subtyping and skolemization
120+
### Subtyping and Placeholder
121121

122122
When we type-check `main`, and in particular the call `bar(foo)`, we
123123
are going to wind up with a subtyping relationship like this one:
@@ -129,10 +129,10 @@ the type of `foo` the type `bar` expects
129129
```
130130

131131
We handle this sort of subtyping by taking the variables that are
132-
bound in the supertype and **skolemizing** them: this means that we
132+
bound in the supertype and **placeholder** them: this means that we
133133
replace them with
134134
[universally quantified](../appendix/background.html#quantified)
135-
representatives, written like `!1`. We call these regions "skolemized
135+
representatives, written like `!1`. We call these regions "placeholder
136136
regions" – they represent, basically, "some unknown region".
137137

138138
Once we've done that replacement, we have the following relation:
@@ -163,7 +163,7 @@ should yield up an error (eventually).
163163

164164
### What is a universe
165165

166-
In the previous section, we introduced the idea of a skolemized
166+
In the previous section, we introduced the idea of a placeholder
167167
region, and we denoted it `!1`. We call this number `1` the **universe
168168
index**. The idea of a "universe" is that it is a set of names that
169169
are in scope within some type or at some point. Universes are formed
@@ -198,7 +198,7 @@ fn bar<'a, T>(t: &'a T) {
198198
```
199199

200200
Here, the name `'b` is not part of the root universe. Instead, when we
201-
"enter" into this `for<'b>` (e.g., by skolemizing it), we will create
201+
"enter" into this `for<'b>` (e.g., by placeholder it), we will create
202202
a child universe of the root, let's call it U1:
203203

204204
```text
@@ -274,25 +274,25 @@ Here, the only way for the two foralls to interact would be through X,
274274
but neither Y nor Z are in scope when X is declared, so its value
275275
cannot reference either of them.
276276

277-
### Universes and skolemized region elements
277+
### Universes and placeholder region elements
278278

279279
But where does that error come from? The way it happens is like this.
280280
When we are constructing the region inference context, we can tell
281-
from the type inference context how many skolemized variables exist
281+
from the type inference context how many placeholder variables exist
282282
(the `InferCtxt` has an internal counter). For each of those, we
283283
create a corresponding universal region variable `!n` and a "region
284-
element" `skol(n)`. This corresponds to "some unknown set of other
285-
elements". The value of `!n` is `{skol(n)}`.
284+
element" `placeholder(n)`. This corresponds to "some unknown set of other
285+
elements". The value of `!n` is `{placeholder(n)}`.
286286

287287
At the same time, we also give each existential variable a
288288
**universe** (also taken from the `InferCtxt`). This universe
289-
determines which skolemized elements may appear in its value: For
290-
example, a variable in universe U3 may name `skol(1)`, `skol(2)`, and
291-
`skol(3)`, but not `skol(4)`. Note that the universe of an inference
289+
determines which placeholder elements may appear in its value: For
290+
example, a variable in universe U3 may name `placeholder(1)`, `placeholder(2)`, and
291+
`placeholder(3)`, but not `placeholder(4)`. Note that the universe of an inference
292292
variable controls what region elements **can** appear in its value; it
293293
does not say region elements **will** appear.
294294

295-
### Skolemization and outlives constraints
295+
### Placeholders and outlives constraints
296296

297297
In the region inference engine, outlives constraints have the form:
298298

@@ -313,44 +313,44 @@ are present in `value(V2)` and we add those nodes to `value(V1)`. If
313313
we reach a return point, we add in any `end(X)` elements. That part
314314
remains unchanged.
315315

316-
But then *after that* we want to iterate over the skolemized `skol(x)`
316+
But then *after that* we want to iterate over the placeholder `placeholder(x)`
317317
elements in V2 (each of those must be visible to `U(V2)`, but we
318318
should be able to just assume that is true, we don't have to check
319319
it). We have to ensure that `value(V1)` outlives each of those
320-
skolemized elements.
320+
placeholder elements.
321321

322322
Now there are two ways that could happen. First, if `U(V1)` can see
323-
the universe `x` (i.e., `x <= U(V1)`), then we can just add `skol(x)`
323+
the universe `x` (i.e., `x <= U(V1)`), then we can just add `placeholder(x)`
324324
to `value(V1)` and be done. But if not, then we have to approximate:
325-
we may not know what set of elements `skol(x)` represents, but we
325+
we may not know what set of elements `placeholder(x)` represents, but we
326326
should be able to compute some sort of **upper bound** B for it –
327-
some region B that outlives `skol(x)`. For now, we'll just use
327+
some region B that outlives `placeholder(x)`. For now, we'll just use
328328
`'static` for that (since it outlives everything) – in the future, we
329329
can sometimes be smarter here (and in fact we have code for doing this
330330
already in other contexts). Moreover, since `'static` is in the root
331331
universe U0, we know that all variables can see it – so basically if
332-
we find that `value(V2)` contains `skol(x)` for some universe `x`
332+
we find that `value(V2)` contains `placeholder(x)` for some universe `x`
333333
that `V1` can't see, then we force `V1` to `'static`.
334334

335335
### Extending the "universal regions" check
336336

337337
After all constraints have been propagated, the NLL region inference
338338
has one final check, where it goes over the values that wound up being
339339
computed for each universal region and checks that they did not get
340-
'too large'. In our case, we will go through each skolemized region
341-
and check that it contains *only* the `skol(u)` element it is known to
340+
'too large'. In our case, we will go through each placeholder region
341+
and check that it contains *only* the `placeholder(u)` element it is known to
342342
outlive. (Later, we might be able to know that there are relationships
343-
between two skolemized regions and take those into account, as we do
343+
between two placeholder regions and take those into account, as we do
344344
for universal regions from the fn signature.)
345345

346346
Put another way, the "universal regions" check can be considered to be
347347
checking constraints like:
348348

349349
```text
350-
{skol(1)}: V1
350+
{placeholder(1)}: V1
351351
```
352352

353-
where `{skol(1)}` is like a constant set, and V1 is the variable we
353+
where `{placeholder(1)}` is like a constant set, and V1 is the variable we
354354
made to represent the `!1` region.
355355

356356
## Back to our example
@@ -365,7 +365,7 @@ fn(&'static u32) <: fn(&'!1 u32) @ P // this point P is not imp't here
365365
The region inference engine will create a region element domain like this:
366366

367367
```text
368-
{ CFG; end('static); skol(1) }
368+
{ CFG; end('static); placeholder(1) }
369369
--- ------------ ------- from the universe `!1`
370370
| 'static is always in scope
371371
all points in the CFG; not especially relevant here
@@ -377,7 +377,7 @@ will have initial values like so:
377377

378378
```text
379379
Vs = { CFG; end('static) } // it is in U0, so can't name anything else
380-
V1 = { skol(1) }
380+
V1 = { placeholder(1) }
381381
```
382382

383383
From the subtyping constraint above, we would have an outlives constraint like
@@ -390,7 +390,7 @@ To process this, we would grow the value of V1 to include all of Vs:
390390

391391
```text
392392
Vs = { CFG; end('static) }
393-
V1 = { CFG; end('static), skol(1) }
393+
V1 = { CFG; end('static), placeholder(1) }
394394
```
395395

396396
At that point, constraint propagation is complete, because all the
@@ -411,7 +411,7 @@ for<'a> fn(&'a u32, &'a u32)
411411
for<'b, 'c> fn(&'b u32, &'c u32)
412412
```
413413

414-
Here we would skolemize the supertype, as before, yielding:
414+
Here we would placeholer the supertype, as before, yielding:
415415

416416
```text
417417
for<'a> fn(&'a u32, &'a u32)
@@ -476,7 +476,7 @@ an error. That's good: the problem is that we've gone from a fn that promises
476476
to return one of its two arguments, to a fn that is promising to return the
477477
first one. That is unsound. Let's see how it plays out.
478478

479-
First, we skolemize the supertype:
479+
First, we placeholder the supertype:
480480

481481
```text
482482
for<'a> fn(&'a u32, &'a u32) -> &'a u32
@@ -512,26 +512,26 @@ V3: V1
512512
Those variables will have these initial values:
513513

514514
```text
515-
V1 in U1 = {skol(1)}
516-
V2 in U2 = {skol(2)}
515+
V1 in U1 = {placeholder(1)}
516+
V2 in U2 = {placeholder(2)}
517517
V3 in U2 = {}
518518
```
519519

520-
Now because of the `V3: V1` constraint, we have to add `skol(1)` into `V3` (and
520+
Now because of the `V3: V1` constraint, we have to add `placeholder(1)` into `V3` (and
521521
indeed it is visible from `V3`), so we get:
522522

523523
```text
524-
V3 in U2 = {skol(1)}
524+
V3 in U2 = {placeholder(1)}
525525
```
526526

527527
then we have this constraint `V2: V3`, so we wind up having to enlarge
528-
`V2` to include `skol(1)` (which it can also see):
528+
`V2` to include `placeholder(1)` (which it can also see):
529529

530530
```text
531-
V2 in U2 = {skol(1), skol(2)}
531+
V2 in U2 = {placeholder(1), placeholder(2)}
532532
```
533533

534534
Now constraint propagation is done, but when we check the outlives
535-
relationships, we find that `V2` includes this new element `skol(1)`,
535+
relationships, we find that `V2` includes this new element `placeholder(1)`,
536536
so we report an error.
537537

0 commit comments

Comments
 (0)