Skip to content

Commit a8da757

Browse files
committed
Hack in a fix for the Span hash_stable regression
1 parent 2f7cea4 commit a8da757

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

compiler/rustc_span/src/lib.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,30 @@ macro_rules! impl_pos {
18861886
$(#[$attr])*
18871887
$vis struct $ident($inner_vis $inner_ty);
18881888

1889+
impl ::std::cmp::Ord for $ident {
1890+
#[inline(always)]
1891+
fn cmp(&self, other: &Self) -> ::std::cmp::Ordering {
1892+
self.0.cmp(&other.0)
1893+
}
1894+
}
1895+
1896+
impl ::std::cmp::PartialOrd for $ident {
1897+
#[inline(always)]
1898+
fn partial_cmp(&self, other: &Self) -> Option<::std::cmp::Ordering> {
1899+
self.0.partial_cmp(&other.0)
1900+
}
1901+
1902+
#[inline(always)]
1903+
fn lt(&self, other: &Self) -> bool {
1904+
self.0.lt(&other.0)
1905+
}
1906+
1907+
#[inline(always)]
1908+
fn le(&self, other: &Self) -> bool {
1909+
self.0.le(&other.0)
1910+
}
1911+
}
1912+
18891913
impl Pos for $ident {
18901914
#[inline(always)]
18911915
fn from_usize(n: usize) -> $ident {
@@ -1933,15 +1957,15 @@ impl_pos! {
19331957
/// A byte offset.
19341958
///
19351959
/// Keep this small (currently 32-bits), as AST contains a lot of them.
1936-
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
1960+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
19371961
pub struct BytePos(pub u32);
19381962

19391963
/// A character offset.
19401964
///
19411965
/// Because of multibyte UTF-8 characters, a byte offset
19421966
/// is not equivalent to a character offset. The [`SourceMap`] will convert [`BytePos`]
19431967
/// values to `CharPos` values as necessary.
1944-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
1968+
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
19451969
pub struct CharPos(pub usize);
19461970
}
19471971

0 commit comments

Comments
 (0)