1
Fork 0

Move PartialOrd impl out of rustc

Rustdoc's ordering requirements are probably not relevant to the rest of
the compiler.
This commit is contained in:
Joshua Nelson 2020-10-11 11:11:33 -04:00
parent 85c0479e17
commit 96b0446b53
2 changed files with 6 additions and 20 deletions

View file

@ -9,7 +9,6 @@ use rustc_session::parse::{feature_err, ParseSess};
use rustc_session::Session;
use rustc_span::hygiene::Transparency;
use rustc_span::{symbol::sym, symbol::Symbol, Span};
use std::cmp;
use std::num::NonZeroU32;
use version_check::Version;
@ -163,19 +162,6 @@ pub enum StabilityLevel {
Stable { since: Symbol },
}
impl cmp::PartialOrd for StabilityLevel {
// This only take into account stability, not any fields.
// Therefore it is only `PartialOrd` and not `Ord`.
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
match (self, other) {
(Self::Unstable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Equal),
(Self::Stable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Equal),
(Self::Unstable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Less),
(Self::Stable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Greater),
}
}
}
impl StabilityLevel {
pub fn is_unstable(&self) -> bool {
matches!(self, StabilityLevel::Unstable { .. })