Skip to content

Commit 068a6a2

Browse files
committed
remove occurences of skolemization
1 parent 21aaaac commit 068a6a2

File tree

5 files changed

+50
-53
lines changed

5 files changed

+50
-53
lines changed

src/librustc/infer/higher_ranked/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ match. This will ultimately require (as before) that `'a` <= `&x`
133133
must hold: but this does not hold. `self` and `x` are both distinct
134134
free regions. So the subtype check fails.
135135

136-
#### Checking for skolemization leaks
136+
#### Checking for placeholder leaks
137137

138138
You may be wondering about that mysterious last step in the algorithm.
139139
So far it has not been relevant. The purpose of that last step is to
@@ -175,7 +175,7 @@ region `x` and think that everything is happy. In fact, this behavior
175175
is *necessary*, it was key to the first example we walked through.
176176

177177
The difference between this example and the first one is that the variable
178-
`A` already existed at the point where the skolemization occurred. In
178+
`A` already existed at the point where the placeholders were added. In
179179
the first example, you had two functions:
180180

181181
for<'a> fn(&'a T) <: for<'b> fn(&'b T)
@@ -191,7 +191,7 @@ constraints that refer to placeholder names. Basically, consider a
191191
non-directed version of the constraint graph. Let `Tainted(x)` be the
192192
set of all things reachable from a placeholder variable `x`.
193193
`Tainted(x)` should not contain any regions that existed before the
194-
step at which the skolemization was performed. So this case here
194+
step at which the placeholders were created. So this case here
195195
would fail because `&x` was created alone, but is relatable to `&A`.
196196

197197
## Computing the LUB and GLB

src/librustc/infer/higher_ranked/mod.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -127,55 +127,55 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
127127
// Map each placeholder region to a vector of other regions that it
128128
// must be equated with. (Note that this vector may include other
129129
// placeholder regions from `placeholder_map`.)
130-
let skol_resolution_map: FxHashMap<_, _> =
130+
let placeholder_resolution_map: FxHashMap<_, _> =
131131
placeholder_map
132132
.iter()
133-
.map(|(&br, &skol)| {
133+
.map(|(&br, &placeholder)| {
134134
let tainted_regions =
135135
self.infcx.tainted_regions(snapshot,
136-
skol,
136+
placeholder,
137137
TaintDirections::incoming()); // [1]
138138

139139
// [1] this routine executes after the placeholder
140140
// regions have been *equated* with something
141141
// else, so examining the incoming edges ought to
142142
// be enough to collect all constraints
143143

144-
(skol, (br, tainted_regions))
144+
(placeholder, (br, tainted_regions))
145145
})
146146
.collect();
147147

148148
// For each placeholder region, pick a representative -- which can
149149
// be any region from the sets above, except for other members of
150150
// `placeholder_map`. There should always be a representative if things
151151
// are properly well-formed.
152-
let skol_representatives: FxHashMap<_, _> =
153-
skol_resolution_map
152+
let placeholder_representatives: FxHashMap<_, _> =
153+
placeholder_resolution_map
154154
.iter()
155-
.map(|(&skol, &(_, ref regions))| {
155+
.map(|(&placeholder, &(_, ref regions))| {
156156
let representative =
157157
regions.iter()
158-
.filter(|&&r| !skol_resolution_map.contains_key(r))
158+
.filter(|&&r| !placeholder_resolution_map.contains_key(r))
159159
.cloned()
160160
.next()
161161
.unwrap_or_else(|| {
162162
bug!("no representative region for `{:?}` in `{:?}`",
163-
skol, regions)
163+
placeholder, regions)
164164
});
165165

166-
(skol, representative)
166+
(placeholder, representative)
167167
})
168168
.collect();
169169

170-
// Equate all the members of each skolemization set with the
170+
// Equate all the members of each placeholder set with the
171171
// representative.
172-
for (skol, &(_br, ref regions)) in &skol_resolution_map {
173-
let representative = &skol_representatives[skol];
172+
for (placeholder, &(_br, ref regions)) in &placeholder_resolution_map {
173+
let representative = &placeholder_representatives[placeholder];
174174
debug!("higher_ranked_match: \
175-
skol={:?} representative={:?} regions={:?}",
176-
skol, representative, regions);
175+
placeholder={:?} representative={:?} regions={:?}",
176+
placeholder, representative, regions);
177177
for region in regions.iter()
178-
.filter(|&r| !skol_resolution_map.contains_key(r))
178+
.filter(|&r| !placeholder_resolution_map.contains_key(r))
179179
.filter(|&r| r != representative)
180180
{
181181
let origin = SubregionOrigin::Subtype(self.trace.clone());
@@ -192,7 +192,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
192192
fold_regions_in(
193193
self.tcx(),
194194
&a_value,
195-
|r, _| skol_representatives.get(&r).cloned().unwrap_or(r));
195+
|r, _| placeholder_representatives.get(&r).cloned().unwrap_or(r));
196196

197197
debug!("higher_ranked_match: value={:?}", a_value);
198198

@@ -582,7 +582,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
582582
/// the pop occurs as part of the rollback, so an explicit call is not
583583
/// needed (but is also permitted).
584584
///
585-
/// For more information about how skolemization for HRTBs works, see
585+
/// For more information about how placeholders and HRTBs work, see
586586
/// the [rustc guide].
587587
///
588588
/// [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/traits/hrtb.html
@@ -638,11 +638,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
638638
}
639639

640640
let new_vars = self.region_vars_confined_to_snapshot(snapshot);
641-
for (&skol_br, &skol) in placeholder_map {
641+
for (&placeholder_br, &placeholder) in placeholder_map {
642642
// The inputs to a placeholder variable can only
643643
// be itself or other new variables.
644644
let incoming_taints = self.tainted_regions(snapshot,
645-
skol,
645+
placeholder,
646646
TaintDirections::both());
647647
for &tainted_region in &incoming_taints {
648648
// Each placeholder should only be relatable to itself
@@ -654,21 +654,21 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
654654
}
655655
}
656656
_ => {
657-
if tainted_region == skol { continue; }
657+
if tainted_region == placeholder { continue; }
658658
}
659659
};
660660

661661
debug!("{:?} (which replaced {:?}) is tainted by {:?}",
662-
skol,
663-
skol_br,
662+
placeholder,
663+
placeholder_br,
664664
tainted_region);
665665

666666
return Err(if overly_polymorphic {
667667
debug!("Overly polymorphic!");
668-
TypeError::RegionsOverlyPolymorphic(skol_br, tainted_region)
668+
TypeError::RegionsOverlyPolymorphic(placeholder_br, tainted_region)
669669
} else {
670670
debug!("Not as polymorphic!");
671-
TypeError::RegionsInsufficientlyPolymorphic(skol_br, tainted_region)
671+
TypeError::RegionsInsufficientlyPolymorphic(placeholder_br, tainted_region)
672672
})
673673
}
674674
}
@@ -725,10 +725,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
725725
let inv_placeholder_map: FxHashMap<ty::Region<'tcx>, ty::BoundRegion> =
726726
placeholder_map
727727
.iter()
728-
.flat_map(|(&skol_br, &skol)| {
729-
self.tainted_regions(snapshot, skol, TaintDirections::both())
728+
.flat_map(|(&placeholder_br, &placeholder)| {
729+
self.tainted_regions(snapshot, placeholder, TaintDirections::both())
730730
.into_iter()
731-
.map(move |tainted_region| (tainted_region, skol_br))
731+
.map(move |tainted_region| (tainted_region, placeholder_br))
732732
})
733733
.collect();
734734

@@ -739,7 +739,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
739739
// references to regions from the `fold_regions` code below.
740740
let value = self.resolve_type_vars_if_possible(&value);
741741

742-
// Map any skolemization byproducts back to a late-bound
742+
// Map any placeholder byproducts back to a late-bound
743743
// region. Put that late-bound region at whatever the outermost
744744
// binder is that we encountered in `value`. The caller is
745745
// responsible for ensuring that (a) `value` contains at least one
@@ -798,10 +798,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
798798
snapshot: &CombinedSnapshot<'a, 'tcx>,
799799
) {
800800
debug!("pop_placeholders({:?})", placeholder_map);
801-
let skol_regions: FxHashSet<_> = placeholder_map.values().cloned().collect();
801+
let placeholder_regions: FxHashSet<_> = placeholder_map.values().cloned().collect();
802802
self.borrow_region_constraints()
803803
.pop_placeholders(
804-
&skol_regions,
804+
&placeholder_regions,
805805
&snapshot.region_constraints_snapshot,
806806
);
807807
self.universe.set(snapshot.universe);

src/librustc/traits/select.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
16581658
) {
16591659
debug!("assemble_candidates_for_projected_tys({:?})", obligation);
16601660

1661-
// before we go into the whole skolemization thing, just
1661+
// before we go into the whole placeholder thing, just
16621662
// quickly check if the self-type is a projection at all.
16631663
match obligation.predicate.skip_binder().trait_ref.self_ty().sty {
16641664
ty::Projection(_) | ty::Opaque(..) => {}
@@ -2230,9 +2230,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22302230
//
22312231
// Winnowing is the process of attempting to resolve ambiguity by
22322232
// probing further. During the winnowing process, we unify all
2233-
// type variables (ignoring skolemization) and then we also
2234-
// attempt to evaluate recursive bounds to see if they are
2235-
// satisfied.
2233+
// type variables and then we also attempt to evaluate recursive
2234+
// bounds to see if they are satisfied.
22362235

22372236
/// Returns true if `victim` should be dropped in favor of
22382237
/// `other`. Generally speaking we will drop duplicate

src/librustc/ty/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,18 +1479,17 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14791479
/// region `'a` is in a subuniverse U2 of U1, because we can name it
14801480
/// inside the fn type but not outside.
14811481
///
1482-
/// Universes are related to **skolemization** -- which is a way of
1483-
/// doing type- and trait-checking around these "forall" binders (also
1484-
/// called **universal quantification**). The idea is that when, in
1485-
/// the body of `bar`, we refer to `T` as a type, we aren't referring
1486-
/// to any type in particular, but rather a kind of "fresh" type that
1487-
/// is distinct from all other types we have actually declared. This
1488-
/// is called a **placeholder** type, and we use universes to talk
1489-
/// about this. In other words, a type name in universe 0 always
1490-
/// corresponds to some "ground" type that the user declared, but a
1491-
/// type name in a non-zero universe is a placeholder type -- an
1492-
/// idealized representative of "types in general" that we use for
1493-
/// checking generic functions.
1482+
/// Universes are used to do type- and trait-checking around these
1483+
/// "forall" binders (also called **universal quantification**). The
1484+
/// idea is that when, in the body of `bar`, we refer to `T` as a
1485+
/// type, we aren't referring to any type in particular, but rather a
1486+
/// kind of "fresh" type that is distinct from all other types we have
1487+
/// actually declared. This is called a **placeholder** type, and we
1488+
/// use universes to talk about this. In other words, a type name in
1489+
/// universe 0 always corresponds to some "ground" type that the user
1490+
/// declared, but a type name in a non-zero universe is a placeholder
1491+
/// type -- an idealized representative of "types in general" that we
1492+
/// use for checking generic functions.
14941493
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
14951494
pub struct UniverseIndex(u32);
14961495

src/librustc/ty/sty.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,8 @@ pub type Region<'tcx> = &'tcx RegionKind;
10771077
/// it must be ensured that bounds on the region can't be accidentally
10781078
/// assumed without being checked.
10791079
///
1080-
/// The process of doing that is called "skolemization". The bound regions
1081-
/// are replaced by placeholder markers, which don't satisfy any relation
1082-
/// not explicitly provided.
1080+
/// To do this, we replace the bound regions with placeholder markers,
1081+
/// which don't satisfy any relation not explicitly provided.
10831082
///
10841083
/// There are 2 kinds of placeholder regions in rustc: `ReFree` and
10851084
/// `RePlaceholder`. When checking an item's body, `ReFree` is supposed

0 commit comments

Comments
 (0)