about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2020-10-11 11:11:33 -0400
committerJoshua Nelson <jyn514@gmail.com>2020-10-11 11:11:33 -0400
commit96b0446b538a160c83ade3d9e5e9d2203868492d (patch)
tree06cdeec32ee1c4ea98b6e44090d3b930346b2269
parent85c0479e179639180c13c5fe6a6789e6538ea891 (diff)
downloadrust-96b0446b538a160c83ade3d9e5e9d2203868492d.tar.gz
rust-96b0446b538a160c83ade3d9e5e9d2203868492d.zip
Move `PartialOrd` impl out of rustc
Rustdoc's ordering requirements are probably not relevant to the rest of
the compiler.
-rw-r--r--compiler/rustc_attr/src/builtin.rs14
-rw-r--r--src/librustdoc/html/render/mod.rs12
2 files changed, 6 insertions, 20 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index 5268d3f0ab0..9c309345000 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -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 { .. })
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 36db5557b52..f81ea0f6d46 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -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);