Skip to content

Commit b09bc88

Browse files
committed
Refactor: Rename ExistentialPredicate::cmp to ExistentialPredicate::stable_cmp
See #51276 (comment) for rationale.
1 parent c131bdc commit b09bc88

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25142514
pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
25152515
-> &'tcx Slice<ExistentialPredicate<'tcx>> {
25162516
assert!(!eps.is_empty());
2517-
assert!(eps.windows(2).all(|w| w[0].cmp(self, &w[1]) != Ordering::Greater));
2517+
assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater));
25182518
self._intern_existential_predicates(eps)
25192519
}
25202520

src/librustc/ty/sty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ pub enum ExistentialPredicate<'tcx> {
496496
}
497497

498498
impl<'a, 'gcx, 'tcx> ExistentialPredicate<'tcx> {
499-
pub fn cmp(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, other: &Self) -> Ordering {
499+
/// Compares via an ordering that will not change if modules are reordered or other changes are
500+
/// made to the tree. In particular, this ordering is preserved across incremental compilations.
501+
pub fn stable_cmp(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, other: &Self) -> Ordering {
500502
use self::ExistentialPredicate::*;
501503
match (*self, *other) {
502504
(Trait(_), Trait(_)) => Ordering::Equal,

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
714714
.chain(existential_projections
715715
.map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
716716
.collect::<AccumulateVec<[_; 8]>>();
717-
v.sort_by(|a, b| a.cmp(tcx, b));
717+
v.sort_by(|a, b| a.stable_cmp(tcx, b));
718718
let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter()));
719719

720720

0 commit comments

Comments
 (0)