Skip to content

Commit 7d12e5f

Browse files
committed
add note to ExistentialPRedicate::stable_cmp
1 parent c8dba64 commit 7d12e5f

File tree

1 file changed

+7
-0
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+7
-0
lines changed

compiler/rustc_middle/src/ty/sty.rs

+7
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,13 @@ impl<'tcx> ExistentialPredicate<'tcx> {
674674
/// made to the tree. In particular, this ordering is preserved across incremental compilations.
675675
pub fn stable_cmp(&self, tcx: TyCtxt<'tcx>, other: &Self) -> Ordering {
676676
use self::ExistentialPredicate::*;
677+
// Note that we only call this method after checking that the
678+
// given predicates represent a valid trait object.
679+
//
680+
// This means that we have at most one `ExistentialPredicate::Trait`
681+
// and at most one `ExistentialPredicate::Projection` for each associated item.
682+
// We therefore do not have to worry about the ordering for cases which
683+
// are not well formed.
677684
match (*self, *other) {
678685
(Trait(_), Trait(_)) => Ordering::Equal,
679686
(Projection(ref a), Projection(ref b)) => {

0 commit comments

Comments
 (0)