Skip to content

Commit c610316

Browse files
committed
Auto merge of #51462 - Havvy:refactor-cmp, r=nikomatsakis
Refactor: Rename ExistentialPredicate::cmp to ExistentialPredicate::stable_cmp See #51276 (comment) for rationale. Because stable_cmp takes three arguments and Ord::cmp takes two, I am confident that there is no shadowing happening here. r? @nikomatsakis
2 parents 967c1f3 + b09bc88 commit c610316

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
@@ -718,7 +718,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
718718
.chain(existential_projections
719719
.map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
720720
.collect::<AccumulateVec<[_; 8]>>();
721-
v.sort_by(|a, b| a.cmp(tcx, b));
721+
v.sort_by(|a, b| a.stable_cmp(tcx, b));
722722
let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter()));
723723

724724

0 commit comments

Comments
 (0)