Auto merge of #51462 - Havvy:refactor-cmp, r=nikomatsakis
Refactor: Rename ExistentialPredicate::cmp to ExistentialPredicate::stable_cmp See https://github.com/rust-lang/rust/pull/51276#discussion_r193549404 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
This commit is contained in:
commit
c6103160dd
@ -2514,7 +2514,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
|
||||
-> &'tcx Slice<ExistentialPredicate<'tcx>> {
|
||||
assert!(!eps.is_empty());
|
||||
assert!(eps.windows(2).all(|w| w[0].cmp(self, &w[1]) != Ordering::Greater));
|
||||
assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater));
|
||||
self._intern_existential_predicates(eps)
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,9 @@ pub enum ExistentialPredicate<'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> ExistentialPredicate<'tcx> {
|
||||
pub fn cmp(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, other: &Self) -> Ordering {
|
||||
/// Compares via an ordering that will not change if modules are reordered or other changes are
|
||||
/// made to the tree. In particular, this ordering is preserved across incremental compilations.
|
||||
pub fn stable_cmp(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, other: &Self) -> Ordering {
|
||||
use self::ExistentialPredicate::*;
|
||||
match (*self, *other) {
|
||||
(Trait(_), Trait(_)) => Ordering::Equal,
|
||||
|
@ -718,7 +718,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
.chain(existential_projections
|
||||
.map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
|
||||
.collect::<AccumulateVec<[_; 8]>>();
|
||||
v.sort_by(|a, b| a.cmp(tcx, b));
|
||||
v.sort_by(|a, b| a.stable_cmp(tcx, b));
|
||||
let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter()));
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user