diff options
| author | Havvy <ryan.havvy@gmail.com> | 2018-06-09 15:09:07 -0700 |
|---|---|---|
| committer | Havvy <ryan.havvy@gmail.com> | 2018-06-09 15:09:10 -0700 |
| commit | b09bc88e9f9b659f903be1ee23227a04e683b234 (patch) | |
| tree | a92dc0d96a0e19dda1239f948cb5275874a92db1 | |
| parent | c131bdcaff68d35f96e954baac4340206779335f (diff) | |
| download | rust-b09bc88e9f9b659f903be1ee23227a04e683b234.tar.gz rust-b09bc88e9f9b659f903be1ee23227a04e683b234.zip | |
Refactor: Rename ExistentialPredicate::cmp to ExistentialPredicate::stable_cmp
See https://github.com/rust-lang/rust/pull/51276#discussion_r193549404 for rationale.
| -rw-r--r-- | src/librustc/ty/context.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/sty.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index e66ad242310..44e1b51714d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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) } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index f484fda2ae1..8afa96bf2df 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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, diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7ef510f4125..479fe2a20b1 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -714,7 +714,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())); |
