@@ -987,8 +987,9 @@ impl<T> [T] {
987
987
/// assert!(v == [3, 2, 1]);
988
988
/// ```
989
989
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
990
+ #[ rustc_const_unstable( feature = "const_slice_reverse" , issue = "135120" ) ]
990
991
#[ inline]
991
- pub fn reverse ( & mut self ) {
992
+ pub const fn reverse ( & mut self ) {
992
993
let half_len = self . len ( ) / 2 ;
993
994
let Range { start, end } = self . as_mut_ptr_range ( ) ;
994
995
@@ -1011,15 +1012,16 @@ impl<T> [T] {
1011
1012
revswap ( front_half, back_half, half_len) ;
1012
1013
1013
1014
#[ inline]
1014
- fn revswap < T > ( a : & mut [ T ] , b : & mut [ T ] , n : usize ) {
1015
+ const fn revswap < T > ( a : & mut [ T ] , b : & mut [ T ] , n : usize ) {
1015
1016
debug_assert ! ( a. len( ) == n) ;
1016
1017
debug_assert ! ( b. len( ) == n) ;
1017
1018
1018
1019
// Because this function is first compiled in isolation,
1019
1020
// this check tells LLVM that the indexing below is
1020
1021
// in-bounds. Then after inlining -- once the actual
1021
1022
// lengths of the slices are known -- it's removed.
1022
- let ( a, b) = ( & mut a[ ..n] , & mut b[ ..n] ) ;
1023
+ let ( a, _) = a. split_at_mut ( n) ;
1024
+ let ( b, _) = b. split_at_mut ( n) ;
1023
1025
1024
1026
let mut i = 0 ;
1025
1027
while i < n {
0 commit comments