@@ -1810,9 +1810,9 @@ mod impls {
18101810 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18111811 impl PartialEq for $t {
18121812 #[ inline]
1813- fn eq( & self , other: & $t ) -> bool { ( * self ) == ( * other) }
1813+ fn eq( & self , other: & Self ) -> bool { * self == * other }
18141814 #[ inline]
1815- fn ne( & self , other: & $t ) -> bool { ( * self ) != ( * other) }
1815+ fn ne( & self , other: & Self ) -> bool { * self != * other }
18161816 }
18171817 ) * )
18181818 }
@@ -1842,8 +1842,18 @@ mod impls {
18421842
18431843 eq_impl ! { ( ) bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
18441844
1845- macro_rules! chaining_methods_impl {
1846- ( $t: ty) => {
1845+ #[ rustfmt:: skip]
1846+ macro_rules! partial_ord_methods_primitive_impl {
1847+ ( ) => {
1848+ #[ inline( always) ]
1849+ fn lt( & self , other: & Self ) -> bool { * self < * other }
1850+ #[ inline( always) ]
1851+ fn le( & self , other: & Self ) -> bool { * self <= * other }
1852+ #[ inline( always) ]
1853+ fn gt( & self , other: & Self ) -> bool { * self > * other }
1854+ #[ inline( always) ]
1855+ fn ge( & self , other: & Self ) -> bool { * self >= * other }
1856+
18471857 // These implementations are the same for `Ord` or `PartialOrd` types
18481858 // because if either is NAN the `==` test will fail so we end up in
18491859 // the `Break` case and the comparison will correctly return `false`.
@@ -1876,24 +1886,16 @@ mod impls {
18761886 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18771887 impl PartialOrd for $t {
18781888 #[ inline]
1879- fn partial_cmp( & self , other: & $t ) -> Option <Ordering > {
1889+ fn partial_cmp( & self , other: & Self ) -> Option <Ordering > {
18801890 match ( * self <= * other, * self >= * other) {
18811891 ( false , false ) => None ,
18821892 ( false , true ) => Some ( Greater ) ,
18831893 ( true , false ) => Some ( Less ) ,
18841894 ( true , true ) => Some ( Equal ) ,
18851895 }
18861896 }
1887- #[ inline( always) ]
1888- fn lt( & self , other: & $t) -> bool { ( * self ) < ( * other) }
1889- #[ inline( always) ]
1890- fn le( & self , other: & $t) -> bool { ( * self ) <= ( * other) }
1891- #[ inline( always) ]
1892- fn ge( & self , other: & $t) -> bool { ( * self ) >= ( * other) }
1893- #[ inline( always) ]
1894- fn gt( & self , other: & $t) -> bool { ( * self ) > ( * other) }
1895-
1896- chaining_methods_impl!( $t) ;
1897+
1898+ partial_ord_methods_primitive_impl!( ) ;
18971899 }
18981900 ) * )
18991901 }
@@ -1912,6 +1914,8 @@ mod impls {
19121914 fn partial_cmp ( & self , other : & bool ) -> Option < Ordering > {
19131915 Some ( self . cmp ( other) )
19141916 }
1917+
1918+ partial_ord_methods_primitive_impl ! ( ) ;
19151919 }
19161920
19171921 partial_ord_impl ! { f16 f32 f64 f128 }
@@ -1921,25 +1925,17 @@ mod impls {
19211925 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
19221926 impl PartialOrd for $t {
19231927 #[ inline]
1924- fn partial_cmp( & self , other: & $t ) -> Option <Ordering > {
1928+ fn partial_cmp( & self , other: & Self ) -> Option <Ordering > {
19251929 Some ( crate :: intrinsics:: three_way_compare( * self , * other) )
19261930 }
1927- #[ inline( always) ]
1928- fn lt( & self , other: & $t) -> bool { ( * self ) < ( * other) }
1929- #[ inline( always) ]
1930- fn le( & self , other: & $t) -> bool { ( * self ) <= ( * other) }
1931- #[ inline( always) ]
1932- fn ge( & self , other: & $t) -> bool { ( * self ) >= ( * other) }
1933- #[ inline( always) ]
1934- fn gt( & self , other: & $t) -> bool { ( * self ) > ( * other) }
1935-
1936- chaining_methods_impl!( $t) ;
1931+
1932+ partial_ord_methods_primitive_impl!( ) ;
19371933 }
19381934
19391935 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
19401936 impl Ord for $t {
19411937 #[ inline]
1942- fn cmp( & self , other: & $t ) -> Ordering {
1938+ fn cmp( & self , other: & Self ) -> Ordering {
19431939 crate :: intrinsics:: three_way_compare( * self , * other)
19441940 }
19451941 }
0 commit comments