|
3 | 3 | use super::{from_raw_parts, memchr}; |
4 | 4 | use crate::ascii; |
5 | 5 | use crate::cmp::{self, BytewiseEq, Ordering}; |
6 | | -use crate::convert::Infallible; |
7 | 6 | use crate::intrinsics::compare_bytes; |
8 | 7 | use crate::marker::Destruct; |
9 | 8 | use crate::mem::SizedTypeProperties; |
@@ -182,20 +181,12 @@ type AlwaysBreak<B> = ControlFlow<B, crate::convert::Infallible>; |
182 | 181 | #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
183 | 182 | impl<A: [const] PartialOrd> const SlicePartialOrd for A { |
184 | 183 | default fn partial_compare(left: &[A], right: &[A]) -> Option<Ordering> { |
185 | | - // FIXME(const-hack): revert this to a const closure once possible |
186 | | - #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
187 | | - const fn elem_chain<A: [const] PartialOrd>(a: &A, b: &A) -> ControlFlow<Option<Ordering>> { |
188 | | - match PartialOrd::partial_cmp(a, b) { |
189 | | - Some(Ordering::Equal) => ControlFlow::Continue(()), |
190 | | - non_eq => ControlFlow::Break(non_eq), |
191 | | - } |
192 | | - } |
| 184 | + let elem_chain = const |a, b| match PartialOrd::partial_cmp(a, b) { |
| 185 | + Some(Ordering::Equal) => ControlFlow::Continue(()), |
| 186 | + non_eq => ControlFlow::Break(non_eq), |
| 187 | + }; |
193 | 188 |
|
194 | | - // FIXME(const-hack): revert this to a const closure once possible |
195 | | - #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
196 | | - const fn len_chain(a: &usize, b: &usize) -> ControlFlow<Option<Ordering>, Infallible> { |
197 | | - ControlFlow::Break(usize::partial_cmp(a, b)) |
198 | | - } |
| 189 | + let len_chain = const |a: &_, b: &_| ControlFlow::Break(usize::partial_cmp(a, b)); |
199 | 190 |
|
200 | 191 | let AlwaysBreak::Break(b) = chaining_impl(left, right, elem_chain, len_chain); |
201 | 192 | b |
@@ -293,20 +284,12 @@ const trait SliceOrd: Sized { |
293 | 284 | #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
294 | 285 | impl<A: [const] Ord> const SliceOrd for A { |
295 | 286 | default fn compare(left: &[Self], right: &[Self]) -> Ordering { |
296 | | - // FIXME(const-hack): revert this to a const closure once possible |
297 | | - #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
298 | | - const fn elem_chain<A: [const] Ord>(a: &A, b: &A) -> ControlFlow<Ordering> { |
299 | | - match Ord::cmp(a, b) { |
300 | | - Ordering::Equal => ControlFlow::Continue(()), |
301 | | - non_eq => ControlFlow::Break(non_eq), |
302 | | - } |
303 | | - } |
| 287 | + let elem_chain = const |a, b| match Ord::cmp(a, b) { |
| 288 | + Ordering::Equal => ControlFlow::Continue(()), |
| 289 | + non_eq => ControlFlow::Break(non_eq), |
| 290 | + }; |
304 | 291 |
|
305 | | - // FIXME(const-hack): revert this to a const closure once possible |
306 | | - #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
307 | | - const fn len_chain(a: &usize, b: &usize) -> ControlFlow<Ordering, Infallible> { |
308 | | - ControlFlow::Break(usize::cmp(a, b)) |
309 | | - } |
| 292 | + let len_chain = const |a: &_, b: &_| ControlFlow::Break(usize::cmp(a, b)); |
310 | 293 |
|
311 | 294 | let AlwaysBreak::Break(b) = chaining_impl(left, right, elem_chain, len_chain); |
312 | 295 | b |
|
0 commit comments