@@ -2115,185 +2115,101 @@ mod impls {
21152115 }
21162116 }
21172117
2118- // & pointers
2118+ // reference types
21192119
2120- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2121- #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2122- impl < A : PointeeSized , B : PointeeSized > const PartialEq < & B > for & A
2123- where
2124- A : [ const ] PartialEq < B > ,
2125- {
2126- #[ inline]
2127- fn eq ( & self , other : & & B ) -> bool {
2128- PartialEq :: eq ( * self , * other)
2129- }
2130- #[ inline]
2131- fn ne ( & self , other : & & B ) -> bool {
2132- PartialEq :: ne ( * self , * other)
2133- }
2134- }
2135- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2136- #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2137- impl < A : PointeeSized , B : PointeeSized > const PartialOrd < & B > for & A
2138- where
2139- A : [ const ] PartialOrd < B > ,
2140- {
2141- #[ inline]
2142- fn partial_cmp ( & self , other : & & B ) -> Option < Ordering > {
2143- PartialOrd :: partial_cmp ( * self , * other)
2144- }
2145- #[ inline]
2146- fn lt ( & self , other : & & B ) -> bool {
2147- PartialOrd :: lt ( * self , * other)
2148- }
2149- #[ inline]
2150- fn le ( & self , other : & & B ) -> bool {
2151- PartialOrd :: le ( * self , * other)
2152- }
2153- #[ inline]
2154- fn gt ( & self , other : & & B ) -> bool {
2155- PartialOrd :: gt ( * self , * other)
2156- }
2157- #[ inline]
2158- fn ge ( & self , other : & & B ) -> bool {
2159- PartialOrd :: ge ( * self , * other)
2160- }
2161- #[ inline]
2162- fn __chaining_lt ( & self , other : & & B ) -> ControlFlow < bool > {
2163- PartialOrd :: __chaining_lt ( * self , * other)
2164- }
2165- #[ inline]
2166- fn __chaining_le ( & self , other : & & B ) -> ControlFlow < bool > {
2167- PartialOrd :: __chaining_le ( * self , * other)
2168- }
2169- #[ inline]
2170- fn __chaining_gt ( & self , other : & & B ) -> ControlFlow < bool > {
2171- PartialOrd :: __chaining_gt ( * self , * other)
2172- }
2173- #[ inline]
2174- fn __chaining_ge ( & self , other : & & B ) -> ControlFlow < bool > {
2175- PartialOrd :: __chaining_ge ( * self , * other)
2176- }
2177- }
2178- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2179- #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2180- impl < A : PointeeSized > const Ord for & A
2181- where
2182- A : [ const ] Ord ,
2183- {
2184- #[ inline]
2185- fn cmp ( & self , other : & Self ) -> Ordering {
2186- Ord :: cmp ( * self , * other)
2187- }
2120+ macro_rules! impl_partial_eq {
2121+ ( <$A: ident, $B: ident> for $( ( $ref_A: ty, $ref_B: ty) ) * ) => ( $(
2122+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2123+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2124+ impl <$A, $B> const PartialEq <$ref_B> for $ref_A
2125+ where
2126+ $A: [ const ] PartialEq <$B> + PointeeSized ,
2127+ $B: PointeeSized ,
2128+ {
2129+ #[ inline]
2130+ fn eq( & self , other: & $ref_B) -> bool {
2131+ PartialEq :: eq( * self , * other)
2132+ }
2133+ // if <A as PartialEq<B>>::ne uses inline assembly or FFI, then
2134+ // this forwarding impl may be more efficient than the default impl
2135+ #[ inline]
2136+ fn ne( & self , other: & $ref_B) -> bool {
2137+ PartialEq :: ne( * self , * other)
2138+ }
2139+ }
2140+ ) * )
21882141 }
2189- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2190- #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2191- impl < A : PointeeSized > const Eq for & A where A : [ const ] Eq { }
21922142
2193- // & mut pointers
2143+ impl_partial_eq ! ( < A , B > for ( & A , & B ) ( & A , & mut B ) ( & mut A , & B ) ( & mut A , & mut B ) ) ;
21942144
2195- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2196- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2197- impl <A : PointeeSized , B : PointeeSized > const PartialEq < & mut B > for & mut A
2198- where
2199- A : [ const ] PartialEq < B > ,
2200- {
2201- #[ inline ]
2202- fn eq ( & self , other : & & mut B ) -> bool {
2203- PartialEq :: eq ( * self , * other )
2204- }
2205- #[ inline ]
2206- fn ne ( & self , other : & & mut B ) -> bool {
2207- PartialEq :: ne ( * self , * other )
2208- }
2209- }
2210- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2211- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2212- impl <A : PointeeSized , B : PointeeSized > const PartialOrd < & mut B > for & mut A
2213- where
2214- A : [ const ] PartialOrd < B > ,
2215- {
2216- #[ inline ]
2217- fn partial_cmp ( & self , other : & & mut B ) -> Option < Ordering > {
2218- PartialOrd :: partial_cmp ( * self , * other )
2219- }
2220- #[ inline ]
2221- fn lt ( & self , other : & & mut B ) -> bool {
2222- PartialOrd :: lt ( * self , * other )
2223- }
2224- #[ inline ]
2225- fn le ( & self , other : & & mut B ) -> bool {
2226- PartialOrd :: le ( * self , * other )
2227- }
2228- #[ inline ]
2229- fn gt ( & self , other : & & mut B ) -> bool {
2230- PartialOrd :: gt ( * self , * other )
2231- }
2232- #[ inline ]
2233- fn ge ( & self , other : & & mut B ) -> bool {
2234- PartialOrd :: ge ( * self , * other )
2235- }
2236- #[ inline ]
2237- fn __chaining_lt ( & self , other : & & mut B ) -> ControlFlow < bool > {
2238- PartialOrd :: __chaining_lt ( * self , * other )
2239- }
2240- #[ inline ]
2241- fn __chaining_le ( & self , other : & & mut B ) -> ControlFlow < bool > {
2242- PartialOrd :: __chaining_le ( * self , * other )
2243- }
2244- #[ inline ]
2245- fn __chaining_gt ( & self , other : & & mut B ) -> ControlFlow < bool > {
2246- PartialOrd :: __chaining_gt ( * self , * other )
2247- }
2248- #[ inline ]
2249- fn __chaining_ge ( & self , other : & & mut B ) -> ControlFlow < bool > {
2250- PartialOrd :: __chaining_ge ( * self , * other )
2251- }
2252- }
2253- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2254- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2255- impl <A : PointeeSized > const Ord for & mut A
2256- where
2257- A : [ const ] Ord ,
2258- {
2259- #[ inline ]
2260- fn cmp ( & self , other : & Self ) -> Ordering {
2261- Ord :: cmp ( * self , * other )
2262- }
2145+ macro_rules! impl_partial_ord {
2146+ ( <$A: ident, $B: ident> for $( ( $ref_A: ty, $ref_B: ty) ) * ) => ( $(
2147+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2148+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2149+ impl <$A, $B> const PartialOrd <$ref_B> for $ref_A
2150+ where
2151+ $A: [ const ] PartialOrd <$B> + PointeeSized ,
2152+ $B: PointeeSized ,
2153+ {
2154+ #[ inline]
2155+ fn partial_cmp( & self , other: & $ref_B) -> Option <Ordering > {
2156+ PartialOrd :: partial_cmp( * self , * other)
2157+ }
2158+ #[ inline]
2159+ fn lt( & self , other: & $ref_B) -> bool {
2160+ PartialOrd :: lt( * self , * other)
2161+ }
2162+ #[ inline]
2163+ fn le( & self , other: & $ref_B) -> bool {
2164+ PartialOrd :: le( * self , * other)
2165+ }
2166+ #[ inline]
2167+ fn gt( & self , other: & $ref_B) -> bool {
2168+ PartialOrd :: gt( * self , * other)
2169+ }
2170+ #[ inline]
2171+ fn ge( & self , other: & $ref_B) -> bool {
2172+ PartialOrd :: ge( * self , * other)
2173+ }
2174+ #[ inline]
2175+ fn __chaining_lt( & self , other: & $ref_B) -> ControlFlow <bool > {
2176+ PartialOrd :: __chaining_lt( * self , * other)
2177+ }
2178+ #[ inline]
2179+ fn __chaining_le( & self , other: & $ref_B) -> ControlFlow <bool > {
2180+ PartialOrd :: __chaining_le( * self , * other)
2181+ }
2182+ #[ inline]
2183+ fn __chaining_gt( & self , other: & $ref_B) -> ControlFlow <bool > {
2184+ PartialOrd :: __chaining_gt( * self , * other)
2185+ }
2186+ #[ inline]
2187+ fn __chaining_ge( & self , other: & $ref_B) -> ControlFlow <bool > {
2188+ PartialOrd :: __chaining_ge( * self , * other)
2189+ }
2190+ }
2191+ ) * )
22632192 }
2264- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2265- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2266- impl <A : PointeeSized > const Eq for & mut A where A : [ const ] Eq { }
22672193
2268- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2269- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2270- impl <A : PointeeSized , B : PointeeSized > const PartialEq < & mut B > for & A
2271- where
2272- A : [ const ] PartialEq < B > ,
2273- {
2274- #[ inline ]
2275- fn eq ( & self , other : & & mut B ) -> bool {
2276- PartialEq :: eq ( * self , * other )
2277- }
2278- #[ inline ]
2279- fn ne ( & self , other : & & mut B ) -> bool {
2280- PartialEq :: ne ( * self , * other )
2281- }
2282- }
2194+ impl_partial_ord ! ( <A , B > for ( & A , & B ) /*(&A, &mut B) (&mut A, &B)*/ ( & mut A , & mut B ) ) ;
22832195
2284- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
2285- #[ rustc_const_unstable ( feature = "const_cmp" , issue = "143800" ) ]
2286- impl <A : PointeeSized , B : PointeeSized > const PartialEq < & B > for & mut A
2287- where
2288- A : [ const ] PartialEq < B > ,
2289- {
2290- #[ inline ]
2291- fn eq ( & self , other : & & B ) -> bool {
2292- PartialEq :: eq ( * self , * other )
2293- }
2294- #[ inline ]
2295- fn ne ( & self , other : & & B ) -> bool {
2296- PartialEq :: ne ( * self , * other )
2297- }
2196+ macro_rules! impl_ord_eq {
2197+ ( <$A: ident> for $( $ref_A: ty) ,* ) => ( $(
2198+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2199+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2200+ impl <$A: [ const ] Ord + PointeeSized > const Ord for $ref_A
2201+ {
2202+ #[ inline]
2203+ fn cmp( & self , other: & Self ) -> Ordering {
2204+ Ord :: cmp( * self , * other)
2205+ }
2206+ }
2207+
2208+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2209+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
2210+ impl <$A: [ const ] Eq + PointeeSized > const Eq for $ref_A { }
2211+ ) * )
22982212 }
2213+
2214+ impl_ord_eq ! ( <A > for & A , & mut A ) ;
22992215}
0 commit comments