@@ -5,7 +5,7 @@ bounds*. An example of such a bound is `for<'a> MyTrait<&'a isize>`.
5
5
Let's walk through how selection on higher-ranked trait references
6
6
works.
7
7
8
- ## Basic matching and skolemization leaks
8
+ ## Basic matching and placeholder leaks
9
9
10
10
Suppose we have a trait ` Foo ` :
11
11
@@ -36,20 +36,20 @@ to the subtyping for higher-ranked types (which is described [here][hrsubtype]
36
36
and also in a [ paper by SPJ] . If you wish to understand higher-ranked
37
37
subtyping, we recommend you read the paper). There are a few parts:
38
38
39
- ** TODO** : We should define _ skolemize _ .
39
+ ** TODO** : We should define _ placeholder _ .
40
40
41
41
1 . _ Skolemize_ the obligation.
42
- 2 . Match the impl against the skolemized obligation.
43
- 3 . Check for _ skolemization leaks_ .
42
+ 2 . Match the impl against the placeholder obligation.
43
+ 3 . Check for _ placeholder leaks_ .
44
44
45
45
[ hrsubtype ] : https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked/README.md
46
46
[ paper by SPJ ] : http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/
47
47
48
48
So let's work through our example.
49
49
50
50
1 . The first thing we would do is to
51
- skolemize the obligation, yielding ` AnyInt : Foo<&'0 isize> ` (here ` '0 `
52
- represents skolemized region #0 ). Note that we now have no quantifiers;
51
+ placeholder the obligation, yielding ` AnyInt : Foo<&'0 isize> ` (here ` '0 `
52
+ represents placeholder region #0 ). Note that we now have no quantifiers;
53
53
in terms of the compiler type, this changes from a ` ty::PolyTraitRef `
54
54
to a ` TraitRef ` . We would then create the ` TraitRef ` from the impl,
55
55
using fresh variables for it's bound regions (and thus getting
@@ -59,10 +59,10 @@ using fresh variables for it's bound regions (and thus getting
59
59
we relate the two trait refs, yielding a graph with the constraint
60
60
that ` '0 == '$a ` .
61
61
62
- 3 . Finally, we check for skolemization "leaks" – a
63
- leak is basically any attempt to relate a skolemized region to another
64
- skolemized region, or to any region that pre-existed the impl match.
65
- The leak check is done by searching from the skolemized region to find
62
+ 3 . Finally, we check for placeholder "leaks" – a
63
+ leak is basically any attempt to relate a placeholder region to another
64
+ placeholder region, or to any region that pre-existed the impl match.
65
+ The leak check is done by searching from the placeholder region to find
66
66
the set of regions that it is related to in any way. This is called
67
67
the "taint" set. To pass the check, that set must consist * solely* of
68
68
itself and region variables from the impl. If the taint set includes
@@ -78,7 +78,7 @@ impl Foo<&'static isize> for StaticInt;
78
78
79
79
We want the obligation ` StaticInt : for<'a> Foo<&'a isize> ` to be
80
80
considered unsatisfied. The check begins just as before. ` 'a ` is
81
- skolemized to ` '0 ` and the impl trait reference is instantiated to
81
+ placeholder to ` '0 ` and the impl trait reference is instantiated to
82
82
` Foo<&'static isize> ` . When we relate those two, we get a constraint
83
83
like ` 'static == '0 ` . This means that the taint set for ` '0 ` is `{'0,
84
84
'static}`, which fails the leak check.
@@ -111,16 +111,16 @@ Now let's say we have a obligation `Baz: for<'a> Foo<&'a isize>` and we match
111
111
this impl. What obligation is generated as a result? We want to get
112
112
` Baz: for<'a> Bar<&'a isize> ` , but how does that happen?
113
113
114
- After the matching, we are in a position where we have a skolemized
114
+ After the matching, we are in a position where we have a placeholder
115
115
substitution like ` X => &'0 isize ` . If we apply this substitution to the
116
116
impl obligations, we get ` F : Bar<&'0 isize> ` . Obviously this is not
117
- directly usable because the skolemized region ` '0 ` cannot leak out of
117
+ directly usable because the placeholder region ` '0 ` cannot leak out of
118
118
our computation.
119
119
120
120
What we do is to create an inverse mapping from the taint set of ` '0 `
121
121
back to the original bound region (` 'a ` , here) that ` '0 ` resulted
122
122
from. (This is done in ` higher_ranked::plug_leaks ` ). We know that the
123
- leak check passed, so this taint set consists solely of the skolemized
123
+ leak check passed, so this taint set consists solely of the placeholder
124
124
region itself plus various intermediate region variables. We then walk
125
125
the trait-reference and convert every region in that taint set back to
126
126
a late-bound region, so in this case we'd wind up with
0 commit comments