Skip to content

Commit 500d6f6

Browse files
committed
Stabilize slice_first_last_chunk
This stabilizes all methods under `slice_first_last_chunk`. Additionally, it const stabilizes the non-mut functions and moves the `_mut` functions under `const_slice_first_last_chunk`. These are blocked on `const_mut_refs`. As part of this change, `slice_split_at_unchecked` was marked const-stable for internal use (but not fully stable).
1 parent 01337bf commit 500d6f6

File tree

3 files changed

+20
-36
lines changed

3 files changed

+20
-36
lines changed

compiler/rustc_serialize/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(min_specialization)]
1717
#![feature(never_type)]
1818
#![feature(ptr_sub_ptr)]
19-
#![feature(slice_first_last_chunk)]
2019
#![cfg_attr(test, feature(test))]
2120
#![allow(rustc::internal)]
2221
#![deny(rustc::untranslatable_diagnostic)]

library/core/src/slice/mod.rs

+20-34
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ impl<T> [T] {
327327
/// # Examples
328328
///
329329
/// ```
330-
/// #![feature(slice_first_last_chunk)]
331-
///
332330
/// let u = [10, 40, 30];
333331
/// assert_eq!(Some(&[10, 40]), u.first_chunk::<2>());
334332
///
@@ -338,9 +336,9 @@ impl<T> [T] {
338336
/// let w: &[i32] = &[];
339337
/// assert_eq!(Some(&[]), w.first_chunk::<0>());
340338
/// ```
341-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
342-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
343339
#[inline]
340+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
341+
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
344342
pub const fn first_chunk<const N: usize>(&self) -> Option<&[T; N]> {
345343
if self.len() < N {
346344
None
@@ -358,8 +356,6 @@ impl<T> [T] {
358356
/// # Examples
359357
///
360358
/// ```
361-
/// #![feature(slice_first_last_chunk)]
362-
///
363359
/// let x = &mut [0, 1, 2];
364360
///
365361
/// if let Some(first) = x.first_chunk_mut::<2>() {
@@ -370,9 +366,9 @@ impl<T> [T] {
370366
///
371367
/// assert_eq!(None, x.first_chunk_mut::<4>());
372368
/// ```
373-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
374-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
375369
#[inline]
370+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
371+
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
376372
pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
377373
if self.len() < N {
378374
None
@@ -391,8 +387,6 @@ impl<T> [T] {
391387
/// # Examples
392388
///
393389
/// ```
394-
/// #![feature(slice_first_last_chunk)]
395-
///
396390
/// let x = &[0, 1, 2];
397391
///
398392
/// if let Some((first, elements)) = x.split_first_chunk::<2>() {
@@ -402,9 +396,9 @@ impl<T> [T] {
402396
///
403397
/// assert_eq!(None, x.split_first_chunk::<4>());
404398
/// ```
405-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
406-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
407399
#[inline]
400+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
401+
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
408402
pub const fn split_first_chunk<const N: usize>(&self) -> Option<(&[T; N], &[T])> {
409403
if self.len() < N {
410404
None
@@ -426,8 +420,6 @@ impl<T> [T] {
426420
/// # Examples
427421
///
428422
/// ```
429-
/// #![feature(slice_first_last_chunk)]
430-
///
431423
/// let x = &mut [0, 1, 2];
432424
///
433425
/// if let Some((first, elements)) = x.split_first_chunk_mut::<2>() {
@@ -439,9 +431,9 @@ impl<T> [T] {
439431
///
440432
/// assert_eq!(None, x.split_first_chunk_mut::<4>());
441433
/// ```
442-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
443-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
444434
#[inline]
435+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
436+
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
445437
pub const fn split_first_chunk_mut<const N: usize>(
446438
&mut self,
447439
) -> Option<(&mut [T; N], &mut [T])> {
@@ -465,8 +457,6 @@ impl<T> [T] {
465457
/// # Examples
466458
///
467459
/// ```
468-
/// #![feature(slice_first_last_chunk)]
469-
///
470460
/// let x = &[0, 1, 2];
471461
///
472462
/// if let Some((elements, last)) = x.split_last_chunk::<2>() {
@@ -476,9 +466,9 @@ impl<T> [T] {
476466
///
477467
/// assert_eq!(None, x.split_last_chunk::<4>());
478468
/// ```
479-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
480-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
481469
#[inline]
470+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
471+
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
482472
pub const fn split_last_chunk<const N: usize>(&self) -> Option<(&[T], &[T; N])> {
483473
if self.len() < N {
484474
None
@@ -500,8 +490,6 @@ impl<T> [T] {
500490
/// # Examples
501491
///
502492
/// ```
503-
/// #![feature(slice_first_last_chunk)]
504-
///
505493
/// let x = &mut [0, 1, 2];
506494
///
507495
/// if let Some((elements, last)) = x.split_last_chunk_mut::<2>() {
@@ -513,9 +501,9 @@ impl<T> [T] {
513501
///
514502
/// assert_eq!(None, x.split_last_chunk_mut::<4>());
515503
/// ```
516-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
517-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
518504
#[inline]
505+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
506+
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
519507
pub const fn split_last_chunk_mut<const N: usize>(
520508
&mut self,
521509
) -> Option<(&mut [T], &mut [T; N])> {
@@ -539,8 +527,6 @@ impl<T> [T] {
539527
/// # Examples
540528
///
541529
/// ```
542-
/// #![feature(slice_first_last_chunk)]
543-
///
544530
/// let u = [10, 40, 30];
545531
/// assert_eq!(Some(&[40, 30]), u.last_chunk::<2>());
546532
///
@@ -550,9 +536,9 @@ impl<T> [T] {
550536
/// let w: &[i32] = &[];
551537
/// assert_eq!(Some(&[]), w.last_chunk::<0>());
552538
/// ```
553-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
554-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
555539
#[inline]
540+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
541+
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
556542
pub const fn last_chunk<const N: usize>(&self) -> Option<&[T; N]> {
557543
if self.len() < N {
558544
None
@@ -574,8 +560,6 @@ impl<T> [T] {
574560
/// # Examples
575561
///
576562
/// ```
577-
/// #![feature(slice_first_last_chunk)]
578-
///
579563
/// let x = &mut [0, 1, 2];
580564
///
581565
/// if let Some(last) = x.last_chunk_mut::<2>() {
@@ -586,9 +570,9 @@ impl<T> [T] {
586570
///
587571
/// assert_eq!(None, x.last_chunk_mut::<4>());
588572
/// ```
589-
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
590-
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
591573
#[inline]
574+
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
575+
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
592576
pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
593577
if self.len() < N {
594578
None
@@ -1885,7 +1869,6 @@ impl<T> [T] {
18851869
/// ```
18861870
#[stable(feature = "rust1", since = "1.0.0")]
18871871
#[rustc_const_stable(feature = "const_slice_split_at_not_mut", since = "1.71.0")]
1888-
#[rustc_allow_const_fn_unstable(slice_split_at_unchecked)]
18891872
#[inline]
18901873
#[track_caller]
18911874
#[must_use]
@@ -1972,7 +1955,10 @@ impl<T> [T] {
19721955
/// }
19731956
/// ```
19741957
#[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
1975-
#[rustc_const_unstable(feature = "slice_split_at_unchecked", issue = "76014")]
1958+
#[rustc_const_stable(
1959+
feature = "const_slice_split_at_unchecked",
1960+
since = "CURRENT_RUSTC_VERSION"
1961+
)]
19761962
#[inline]
19771963
#[must_use]
19781964
pub const unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#![feature(pattern)]
4747
#![feature(sort_internals)]
4848
#![feature(slice_take)]
49-
#![feature(slice_first_last_chunk)]
5049
#![feature(slice_from_ptr_range)]
5150
#![feature(slice_split_once)]
5251
#![feature(split_as_slice)]

0 commit comments

Comments
 (0)