Skip to content

Commit c4840db

Browse files
committed
skol -> placeholder
1 parent 033013c commit c4840db

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

src/librustc_infer/infer/region_constraints/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub(crate) enum UndoLog<'tcx> {
290290
/// We added a GLB/LUB "combination variable".
291291
AddCombination(CombineMapType, TwoRegions<'tcx>),
292292

293-
/// During skolemization, we sometimes purge entries from the undo
293+
/// During freshening, we sometimes purge entries from the undo
294294
/// log in a kind of minisnapshot (unlike other snapshots, this
295295
/// purging actually takes place *on success*). In that case, we
296296
/// replace the corresponding entry with `Noop` so as to avoid the
@@ -489,7 +489,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
489489
}
490490

491491
/// Removes all the edges to/from the placeholder regions that are
492-
/// in `skols`. This is used after a higher-ranked operation
492+
/// in `placeholders`. This is used after a higher-ranked operation
493493
/// completes to remove all trace of the placeholder regions
494494
/// created in that time.
495495
pub fn pop_placeholders(&mut self, placeholders: &FxHashSet<ty::Region<'tcx>>) {

src/librustc_trait_selection/traits/select/mod.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,38 +1754,37 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17541754
) -> Vec<PredicateObligation<'tcx>> {
17551755
// Because the types were potentially derived from
17561756
// higher-ranked obligations they may reference late-bound
1757-
// regions. For example, `for<'a> Foo<&'a int> : Copy` would
1758-
// yield a type like `for<'a> &'a int`. In general, we
1757+
// regions. For example, `for<'a> Foo<&'a i32> : Copy` would
1758+
// yield a type like `for<'a> &'a i32`. In general, we
17591759
// maintain the invariant that we never manipulate bound
17601760
// regions, so we have to process these bound regions somehow.
17611761
//
17621762
// The strategy is to:
17631763
//
17641764
// 1. Instantiate those regions to placeholder regions (e.g.,
1765-
// `for<'a> &'a int` becomes `&0 int`.
1766-
// 2. Produce something like `&'0 int : Copy`
1767-
// 3. Re-bind the regions back to `for<'a> &'a int : Copy`
1765+
// `for<'a> &'a int` becomes `&0 i32`.
1766+
// 2. Produce something like `&'0 i32 : Copy`
1767+
// 3. Re-bind the regions back to `for<'a> &'a i32 : Copy`
17681768

17691769
types
1770-
.skip_binder()
1770+
.skip_binder() // binder moved -\
17711771
.iter()
17721772
.flat_map(|ty| {
1773-
// binder moved -\
17741773
let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/
17751774

17761775
self.infcx.commit_unconditionally(|_| {
1777-
let (skol_ty, _) = self.infcx.replace_bound_vars_with_placeholders(&ty);
1776+
let (placeholder_ty, _) = self.infcx.replace_bound_vars_with_placeholders(&ty);
17781777
let Normalized { value: normalized_ty, mut obligations } =
17791778
ensure_sufficient_stack(|| {
17801779
project::normalize_with_depth(
17811780
self,
17821781
param_env,
17831782
cause.clone(),
17841783
recursion_depth,
1785-
&skol_ty,
1784+
&placeholder_ty,
17861785
)
17871786
});
1788-
let skol_obligation = predicate_for_trait_def(
1787+
let placeholder_obligation = predicate_for_trait_def(
17891788
self.tcx(),
17901789
param_env,
17911790
cause.clone(),
@@ -1794,7 +1793,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17941793
normalized_ty,
17951794
&[],
17961795
);
1797-
obligations.push(skol_obligation);
1796+
obligations.push(placeholder_obligation);
17981797
obligations
17991798
})
18001799
})
@@ -1844,9 +1843,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18441843
return Err(());
18451844
}
18461845

1847-
let (skol_obligation, placeholder_map) =
1846+
let (placeholder_obligation, placeholder_map) =
18481847
self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate);
1849-
let skol_obligation_trait_ref = skol_obligation.trait_ref;
1848+
let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
18501849

18511850
let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span, impl_def_id);
18521851

@@ -1865,14 +1864,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18651864

18661865
debug!(
18671866
"match_impl(impl_def_id={:?}, obligation={:?}, \
1868-
impl_trait_ref={:?}, skol_obligation_trait_ref={:?})",
1869-
impl_def_id, obligation, impl_trait_ref, skol_obligation_trait_ref
1867+
impl_trait_ref={:?}, placeholder_obligation_trait_ref={:?})",
1868+
impl_def_id, obligation, impl_trait_ref, placeholder_obligation_trait_ref
18701869
);
18711870

18721871
let InferOk { obligations, .. } = self
18731872
.infcx
18741873
.at(&obligation.cause, obligation.param_env)
1875-
.eq(skol_obligation_trait_ref, impl_trait_ref)
1874+
.eq(placeholder_obligation_trait_ref, impl_trait_ref)
18761875
.map_err(|e| debug!("match_impl: failed eq_trait_refs due to `{}`", e))?;
18771876
nested_obligations.extend(obligations);
18781877

src/librustc_trait_selection/traits/specialize/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
130130

131131
// We determine whether there's a subset relationship by:
132132
//
133-
// - skolemizing impl1,
133+
// - replacing bound vars with placeholders in impl1,
134134
// - assuming the where clauses for impl1,
135135
// - instantiating impl2 with fresh inference variables,
136136
// - unifying,

src/librustc_typeck/check/compare_method.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ fn compare_predicate_entailment<'tcx>(
9191

9292
// This code is best explained by example. Consider a trait:
9393
//
94-
// trait Trait<'t,T> {
95-
// fn method<'a,M>(t: &'t T, m: &'a M) -> Self;
94+
// trait Trait<'t, T> {
95+
// fn method<'a, M>(t: &'t T, m: &'a M) -> Self;
9696
// }
9797
//
9898
// And an impl:
9999
//
100100
// impl<'i, 'j, U> Trait<'j, &'i U> for Foo {
101-
// fn method<'b,N>(t: &'j &'i U, m: &'b N) -> Foo;
101+
// fn method<'b, N>(t: &'j &'i U, m: &'b N) -> Foo;
102102
// }
103103
//
104104
// We wish to decide if those two method types are compatible.
@@ -116,9 +116,9 @@ fn compare_predicate_entailment<'tcx>(
116116
// regions (Note: but only early-bound regions, i.e., those
117117
// declared on the impl or used in type parameter bounds).
118118
//
119-
// impl_to_skol_substs = {'i => 'i0, U => U0, N => N0 }
119+
// impl_to_placeholder_substs = {'i => 'i0, U => U0, N => N0 }
120120
//
121-
// Now we can apply skol_substs to the type of the impl method
121+
// Now we can apply placeholder_substs to the type of the impl method
122122
// to yield a new function type in terms of our fresh, placeholder
123123
// types:
124124
//
@@ -127,11 +127,11 @@ fn compare_predicate_entailment<'tcx>(
127127
// We now want to extract and substitute the type of the *trait*
128128
// method and compare it. To do so, we must create a compound
129129
// substitution by combining trait_to_impl_substs and
130-
// impl_to_skol_substs, and also adding a mapping for the method
130+
// impl_to_placeholder_substs, and also adding a mapping for the method
131131
// type parameters. We extend the mapping to also include
132132
// the method parameters.
133133
//
134-
// trait_to_skol_substs = { T => &'i0 U0, Self => Foo, M => N0 }
134+
// trait_to_placeholder_substs = { T => &'i0 U0, Self => Foo, M => N0 }
135135
//
136136
// Applying this to the trait method type yields:
137137
//
@@ -145,20 +145,20 @@ fn compare_predicate_entailment<'tcx>(
145145
// satisfied by the implementation's method.
146146
//
147147
// We do this by creating a parameter environment which contains a
148-
// substitution corresponding to impl_to_skol_substs. We then build
149-
// trait_to_skol_substs and use it to convert the predicates contained
148+
// substitution corresponding to impl_to_placeholder_substs. We then build
149+
// trait_to_placeholder_substs and use it to convert the predicates contained
150150
// in the trait_m.generics to the placeholder form.
151151
//
152152
// Finally we register each of these predicates as an obligation in
153153
// a fresh FulfillmentCtxt, and invoke select_all_or_error.
154154

155155
// Create mapping from impl to placeholder.
156-
let impl_to_skol_substs = InternalSubsts::identity_for_item(tcx, impl_m.def_id);
156+
let impl_to_placeholder_substs = InternalSubsts::identity_for_item(tcx, impl_m.def_id);
157157

158158
// Create mapping from trait to placeholder.
159-
let trait_to_skol_substs =
160-
impl_to_skol_substs.rebase_onto(tcx, impl_m.container.id(), trait_to_impl_substs);
161-
debug!("compare_impl_method: trait_to_skol_substs={:?}", trait_to_skol_substs);
159+
let trait_to_placeholder_substs =
160+
impl_to_placeholder_substs.rebase_onto(tcx, impl_m.container.id(), trait_to_impl_substs);
161+
debug!("compare_impl_method: trait_to_placeholder_substs={:?}", trait_to_placeholder_substs);
162162

163163
let impl_m_generics = tcx.generics_of(impl_m.def_id);
164164
let trait_m_generics = tcx.generics_of(trait_m.def_id);
@@ -194,7 +194,7 @@ fn compare_predicate_entailment<'tcx>(
194194
// if all constraints hold.
195195
hybrid_preds
196196
.predicates
197-
.extend(trait_m_predicates.instantiate_own(tcx, trait_to_skol_substs).predicates);
197+
.extend(trait_m_predicates.instantiate_own(tcx, trait_to_placeholder_substs).predicates);
198198

199199
// Construct trait parameter environment and then shift it into the placeholder viewpoint.
200200
// The key step here is to update the caller_bounds's predicates to be
@@ -220,7 +220,7 @@ fn compare_predicate_entailment<'tcx>(
220220

221221
let mut selcx = traits::SelectionContext::new(&infcx);
222222

223-
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_skol_substs);
223+
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
224224
let (impl_m_own_bounds, _) = infcx.replace_bound_vars_with_fresh_vars(
225225
impl_m_span,
226226
infer::HigherRankedType,
@@ -261,7 +261,7 @@ fn compare_predicate_entailment<'tcx>(
261261
debug!("compare_impl_method: impl_fty={:?}", impl_fty);
262262

263263
let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, &tcx.fn_sig(trait_m.def_id));
264-
let trait_sig = trait_sig.subst(tcx, trait_to_skol_substs);
264+
let trait_sig = trait_sig.subst(tcx, trait_to_placeholder_substs);
265265
let trait_sig =
266266
inh.normalize_associated_types_in(impl_m_span, impl_m_hir_id, param_env, &trait_sig);
267267
let trait_fty = tcx.mk_fn_ptr(ty::Binder::bind(trait_sig));

0 commit comments

Comments
 (0)