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:
parent
85c0479e17
commit
96b0446b53
|
@ -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 { .. })
|
||||
|
|
|
@ -1984,12 +1984,12 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
|
|||
}
|
||||
let s1 = i1.stability.as_ref().map(|s| s.level);
|
||||
let s2 = i2.stability.as_ref().map(|s| s.level);
|
||||
match (s1, s2) {
|
||||
(Some(a), Some(b)) => match a.partial_cmp(&b) {
|
||||
Some(Ordering::Equal) | None => {}
|
||||
Some(other) => return other,
|
||||
},
|
||||
_ => {}
|
||||
if let (Some(a), Some(b)) = (s1, s2) {
|
||||
match (a.is_stable(), b.is_stable()) {
|
||||
(true, true) | (false, false) => {}
|
||||
(false, true) => return Ordering::Less,
|
||||
(true, false) => return Ordering::Greater,
|
||||
}
|
||||
}
|
||||
let lhs = i1.name.as_ref().map_or("", |s| &**s);
|
||||
let rhs = i2.name.as_ref().map_or("", |s| &**s);
|
||||
|
|
Loading…
Reference in New Issue