Skip to content

Commit 96b0446

Browse files
committed
Move PartialOrd impl out of rustc
Rustdoc's ordering requirements are probably not relevant to the rest of the compiler.
1 parent 85c0479 commit 96b0446

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

compiler/rustc_attr/src/builtin.rs

-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_session::parse::{feature_err, ParseSess};
99
use rustc_session::Session;
1010
use rustc_span::hygiene::Transparency;
1111
use rustc_span::{symbol::sym, symbol::Symbol, Span};
12-
use std::cmp;
1312
use std::num::NonZeroU32;
1413
use version_check::Version;
1514

@@ -163,19 +162,6 @@ pub enum StabilityLevel {
163162
Stable { since: Symbol },
164163
}
165164

166-
impl cmp::PartialOrd for StabilityLevel {
167-
// This only take into account stability, not any fields.
168-
// Therefore it is only `PartialOrd` and not `Ord`.
169-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
170-
match (self, other) {
171-
(Self::Unstable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Equal),
172-
(Self::Stable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Equal),
173-
(Self::Unstable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Less),
174-
(Self::Stable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Greater),
175-
}
176-
}
177-
}
178-
179165
impl StabilityLevel {
180166
pub fn is_unstable(&self) -> bool {
181167
matches!(self, StabilityLevel::Unstable { .. })

src/librustdoc/html/render/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1984,12 +1984,12 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
19841984
}
19851985
let s1 = i1.stability.as_ref().map(|s| s.level);
19861986
let s2 = i2.stability.as_ref().map(|s| s.level);
1987-
match (s1, s2) {
1988-
(Some(a), Some(b)) => match a.partial_cmp(&b) {
1989-
Some(Ordering::Equal) | None => {}
1990-
Some(other) => return other,
1991-
},
1992-
_ => {}
1987+
if let (Some(a), Some(b)) = (s1, s2) {
1988+
match (a.is_stable(), b.is_stable()) {
1989+
(true, true) | (false, false) => {}
1990+
(false, true) => return Ordering::Less,
1991+
(true, false) => return Ordering::Greater,
1992+
}
19931993
}
19941994
let lhs = i1.name.as_ref().map_or("", |s| &**s);
19951995
let rhs = i2.name.as_ref().map_or("", |s| &**s);

0 commit comments

Comments
 (0)