Skip to content

Commit b015b28

Browse files
authored
Rollup merge of #73055 - lcnr:skol-no-more, r=matthewjasper
remove leftover mentions of `skol` and `int` from the compiler This PR mostly changes `skol` -> `placeholder` and all cases where `int` is used as a type to `i32`.
2 parents 5431ef6 + 180334c commit b015b28

File tree

18 files changed

+79
-155
lines changed

18 files changed

+79
-155
lines changed

src/librustc_infer/infer/higher_ranked/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
6363
/// placeholder region. This is the first step of checking subtyping
6464
/// when higher-ranked things are involved.
6565
///
66-
/// **Important:** you must call this function from within a snapshot.
67-
/// Moreover, before committing the snapshot, you must eventually call
68-
/// either `plug_leaks` or `pop_placeholders` to remove the placeholder
69-
/// regions. If you rollback the snapshot (or are using a probe), then
70-
/// the pop occurs as part of the rollback, so an explicit call is not
71-
/// needed (but is also permitted).
72-
///
73-
/// For more information about how placeholders and HRTBs work, see
66+
/// **Important:** You have to be careful to not leak these placeholders,
67+
/// for more information about how placeholders and HRTBs work, see
7468
/// the [rustc dev guide].
7569
///
7670
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html

src/librustc_infer/infer/region_constraints/leak_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> TaintSet<'tcx> {
128128
verifys[i].origin.span(),
129129
"we never add verifications while doing higher-ranked things",
130130
),
131-
&Purged | &AddCombination(..) | &AddVar(..) => {}
131+
&AddCombination(..) | &AddVar(..) => {}
132132
}
133133
}
134134
}

src/librustc_infer/infer/region_constraints/mod.rs

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,6 @@ pub(crate) enum UndoLog<'tcx> {
289289

290290
/// We added a GLB/LUB "combination variable".
291291
AddCombination(CombineMapType, TwoRegions<'tcx>),
292-
293-
/// During skolemization, we sometimes purge entries from the undo
294-
/// log in a kind of minisnapshot (unlike other snapshots, this
295-
/// purging actually takes place *on success*). In that case, we
296-
/// replace the corresponding entry with `Noop` so as to avoid the
297-
/// need to do a bunch of swapping. (We can't use `swap_remove` as
298-
/// the order of the vector is important.)
299-
Purged,
300292
}
301293

302294
#[derive(Copy, Clone, PartialEq)]
@@ -357,9 +349,6 @@ impl<'tcx> RegionConstraintStorage<'tcx> {
357349

358350
fn rollback_undo_entry(&mut self, undo_entry: UndoLog<'tcx>) {
359351
match undo_entry {
360-
Purged => {
361-
// nothing to do here
362-
}
363352
AddVar(vid) => {
364353
self.var_infos.pop().unwrap();
365354
assert_eq!(self.var_infos.len(), vid.index() as usize);
@@ -488,62 +477,6 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
488477
self.var_infos[vid].origin
489478
}
490479

491-
/// Removes all the edges to/from the placeholder regions that are
492-
/// in `skols`. This is used after a higher-ranked operation
493-
/// completes to remove all trace of the placeholder regions
494-
/// created in that time.
495-
pub fn pop_placeholders(&mut self, placeholders: &FxHashSet<ty::Region<'tcx>>) {
496-
debug!("pop_placeholders(placeholders={:?})", placeholders);
497-
498-
assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
499-
500-
let constraints_to_kill: Vec<usize> = self
501-
.undo_log
502-
.iter()
503-
.enumerate()
504-
.rev()
505-
.filter(|&(_, undo_entry)| match undo_entry {
506-
super::UndoLog::RegionConstraintCollector(undo_entry) => {
507-
kill_constraint(placeholders, undo_entry)
508-
}
509-
_ => false,
510-
})
511-
.map(|(index, _)| index)
512-
.collect();
513-
514-
for index in constraints_to_kill {
515-
let undo_entry = match &mut self.undo_log[index] {
516-
super::UndoLog::RegionConstraintCollector(undo_entry) => {
517-
mem::replace(undo_entry, Purged)
518-
}
519-
_ => unreachable!(),
520-
};
521-
self.rollback_undo_entry(undo_entry);
522-
}
523-
524-
return;
525-
526-
fn kill_constraint<'tcx>(
527-
placeholders: &FxHashSet<ty::Region<'tcx>>,
528-
undo_entry: &UndoLog<'tcx>,
529-
) -> bool {
530-
match undo_entry {
531-
&AddConstraint(Constraint::VarSubVar(..)) => false,
532-
&AddConstraint(Constraint::RegSubVar(a, _)) => placeholders.contains(&a),
533-
&AddConstraint(Constraint::VarSubReg(_, b)) => placeholders.contains(&b),
534-
&AddConstraint(Constraint::RegSubReg(a, b)) => {
535-
placeholders.contains(&a) || placeholders.contains(&b)
536-
}
537-
&AddGiven(..) => false,
538-
&AddVerify(_) => false,
539-
&AddCombination(_, ref two_regions) => {
540-
placeholders.contains(&two_regions.a) || placeholders.contains(&two_regions.b)
541-
}
542-
&AddVar(..) | &Purged => false,
543-
}
544-
}
545-
}
546-
547480
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
548481
// cannot add constraints once regions are resolved
549482
debug!("RegionConstraintCollector: add_constraint({:?})", constraint);

src/librustc_infer/infer/undo_log.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ impl<'tcx> InferCtxtUndoLogs<'tcx> {
198198
assert!(self.logs.len() >= snapshot.undo_len);
199199
assert!(self.num_open_snapshots > 0);
200200
}
201-
202-
pub(crate) fn iter(&self) -> std::slice::Iter<'_, UndoLog<'tcx>> {
203-
self.logs.iter()
204-
}
205201
}
206202

207203
impl<'tcx> std::ops::Index<usize> for InferCtxtUndoLogs<'tcx> {

src/librustc_infer/traits/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ crate use self::util::elaborate_predicates;
2929

3030
pub use rustc_middle::traits::*;
3131

32-
/// An `Obligation` represents some trait reference (e.g., `int: Eq`) for
32+
/// An `Obligation` represents some trait reference (e.g., `i32: Eq`) for
3333
/// which the "impl_source" must be found. The process of finding a "impl_source" is
3434
/// called "resolving" the `Obligation`. This process consists of
35-
/// either identifying an `impl` (e.g., `impl Eq for int`) that
35+
/// either identifying an `impl` (e.g., `impl Eq for i32`) that
3636
/// satisfies the obligation, or else finding a bound that is in
3737
/// scope. The eventual result is usually a `Selection` (defined below).
3838
#[derive(Clone, PartialEq, Eq, Hash)]

src/librustc_infer/traits/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ impl PredicateSet<'tcx> {
6363
fn insert(&mut self, pred: ty::Predicate<'tcx>) -> bool {
6464
// We have to be careful here because we want
6565
//
66-
// for<'a> Foo<&'a int>
66+
// for<'a> Foo<&'a i32>
6767
//
6868
// and
6969
//
70-
// for<'b> Foo<&'b int>
70+
// for<'b> Foo<&'b i32>
7171
//
7272
// to be considered equivalent. So normalize all late-bound
7373
// regions before we throw things into the underlying set.

src/librustc_middle/traits/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -393,23 +393,25 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
393393
/// ```
394394
/// impl<T:Clone> Clone<T> for Option<T> { ... } // Impl_1
395395
/// impl<T:Clone> Clone<T> for Box<T> { ... } // Impl_2
396-
/// impl Clone for int { ... } // Impl_3
396+
/// impl Clone for i32 { ... } // Impl_3
397397
///
398-
/// fn foo<T:Clone>(concrete: Option<Box<int>>,
399-
/// param: T,
400-
/// mixed: Option<T>) {
398+
/// fn foo<T: Clone>(concrete: Option<Box<i32>>, param: T, mixed: Option<T>) {
399+
/// // Case A: Vtable points at a specific impl. Only possible when
400+
/// // type is concretely known. If the impl itself has bounded
401+
/// // type parameters, Vtable will carry resolutions for those as well:
402+
/// concrete.clone(); // Vtable(Impl_1, [Vtable(Impl_2, [Vtable(Impl_3)])])
401403
///
402-
/// // Case A: ImplSource points at a specific impl. Only possible when
403-
/// // type is concretely known. If the impl itself has bounded
404-
/// // type parameters, ImplSource will carry resolutions for those as well:
405-
/// concrete.clone(); // ImplSource(Impl_1, [ImplSource(Impl_2, [ImplSource(Impl_3)])])
404+
/// // Case A: ImplSource points at a specific impl. Only possible when
405+
/// // type is concretely known. If the impl itself has bounded
406+
/// // type parameters, ImplSource will carry resolutions for those as well:
407+
/// concrete.clone(); // ImplSource(Impl_1, [ImplSource(Impl_2, [ImplSource(Impl_3)])])
406408
///
407-
/// // Case B: ImplSource must be provided by caller. This applies when
408-
/// // type is a type parameter.
409-
/// param.clone(); // ImplSourceParam
409+
/// // Case B: ImplSource must be provided by caller. This applies when
410+
/// // type is a type parameter.
411+
/// param.clone(); // ImplSourceParam
410412
///
411-
/// // Case C: A mix of cases A and B.
412-
/// mixed.clone(); // ImplSource(Impl_1, [ImplSourceParam])
413+
/// // Case C: A mix of cases A and B.
414+
/// mixed.clone(); // ImplSource(Impl_1, [ImplSourceParam])
413415
/// }
414416
/// ```
415417
///

src/librustc_middle/ty/subst.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,12 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
599599
///
600600
/// ```
601601
/// type Func<A> = fn(A);
602-
/// type MetaFunc = for<'a> fn(Func<&'a int>)
602+
/// type MetaFunc = for<'a> fn(Func<&'a i32>)
603603
/// ```
604604
///
605605
/// The type `MetaFunc`, when fully expanded, will be
606606
///
607-
/// for<'a> fn(fn(&'a int))
607+
/// for<'a> fn(fn(&'a i32))
608608
/// ^~ ^~ ^~~
609609
/// | | |
610610
/// | | DebruijnIndex of 2
@@ -613,26 +613,26 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
613613
/// Here the `'a` lifetime is bound in the outer function, but appears as an argument of the
614614
/// inner one. Therefore, that appearance will have a DebruijnIndex of 2, because we must skip
615615
/// over the inner binder (remember that we count De Bruijn indices from 1). However, in the
616-
/// definition of `MetaFunc`, the binder is not visible, so the type `&'a int` will have a
616+
/// definition of `MetaFunc`, the binder is not visible, so the type `&'a i32` will have a
617617
/// De Bruijn index of 1. It's only during the substitution that we can see we must increase the
618618
/// depth by 1 to account for the binder that we passed through.
619619
///
620620
/// As a second example, consider this twist:
621621
///
622622
/// ```
623623
/// type FuncTuple<A> = (A,fn(A));
624-
/// type MetaFuncTuple = for<'a> fn(FuncTuple<&'a int>)
624+
/// type MetaFuncTuple = for<'a> fn(FuncTuple<&'a i32>)
625625
/// ```
626626
///
627627
/// Here the final type will be:
628628
///
629-
/// for<'a> fn((&'a int, fn(&'a int)))
629+
/// for<'a> fn((&'a i32, fn(&'a i32)))
630630
/// ^~~ ^~~
631631
/// | |
632632
/// DebruijnIndex of 1 |
633633
/// DebruijnIndex of 2
634634
///
635-
/// As indicated in the diagram, here the same type `&'a int` is substituted once, but in the
635+
/// As indicated in the diagram, here the same type `&'a i32` is substituted once, but in the
636636
/// first case we do not increase the De Bruijn index and in the second case we do. The reason
637637
/// is that only in the second case have we passed through a fn binder.
638638
fn shift_vars_through_binders<T: TypeFoldable<'tcx>>(&self, val: T) -> T {

src/librustc_middle/ty/walk.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ impl<'tcx> TypeWalker<'tcx> {
2222
/// Skips the subtree corresponding to the last type
2323
/// returned by `next()`.
2424
///
25-
/// Example: Imagine you are walking `Foo<Bar<int>, usize>`.
25+
/// Example: Imagine you are walking `Foo<Bar<i32>, usize>`.
2626
///
2727
/// ```
2828
/// let mut iter: TypeWalker = ...;
2929
/// iter.next(); // yields Foo
30-
/// iter.next(); // yields Bar<int>
31-
/// iter.skip_current_subtree(); // skips int
30+
/// iter.next(); // yields Bar<i32>
31+
/// iter.skip_current_subtree(); // skips i32
3232
/// iter.next(); // yields usize
3333
/// ```
3434
pub fn skip_current_subtree(&mut self) {

src/librustc_trait_selection/traits/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
361361
// handle normalization within binders because
362362
// otherwise we wind up a need to normalize when doing
363363
// trait matching (since you can have a trait
364-
// obligation like `for<'a> T::B : Fn(&'a int)`), but
364+
// obligation like `for<'a> T::B: Fn(&'a i32)`), but
365365
// we can't normalize with bound regions in scope. So
366366
// far now we just ignore binders but only normalize
367367
// if all bound regions are gone (and then we still

0 commit comments

Comments
 (0)