diff options
| author | bors <bors@rust-lang.org> | 2022-03-10 12:32:01 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-10 12:32:01 +0000 | 
| commit | ba14a836c7038da21f5e102aacc7e6d5964f79a6 (patch) | |
| tree | 74faca104bf8154e790c595a8416c7b1e5b50869 /library/core/src | |
| parent | 282778aee26166754315815552bae454fc968960 (diff) | |
| parent | 6bbaca7d030b2c778a7a7b9762f3afb2a2408ff5 (diff) | |
| download | rust-ba14a836c7038da21f5e102aacc7e6d5964f79a6.tar.gz rust-ba14a836c7038da21f5e102aacc7e6d5964f79a6.zip | |
Auto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgr
Rollup of 5 pull requests
Successful merges:
 - #92150 (Improve suggestion when casting usize to (possibly) wide pointer)
 - #94635 (Merge `#[deprecated]` and `#[rustc_deprecated]`)
 - #94657 (Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`)
 - #94746 (diagnostics: use rustc_on_unimplemented to recommend `[].iter()`)
 - #94788 (Account for suggestions for complete removal of lines)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/array/mod.rs | 10 | ||||
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 5 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 3 | ||||
| -rw-r--r-- | library/core/src/num/mod.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ops/range.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ptr/const_ptr.rs | 5 | ||||
| -rw-r--r-- | library/core/src/ptr/mut_ptr.rs | 5 | ||||
| -rw-r--r-- | library/core/src/ptr/non_null.rs | 5 | ||||
| -rw-r--r-- | library/core/src/slice/index.rs | 83 | ||||
| -rw-r--r-- | library/core/src/slice/mod.rs | 20 | ||||
| -rw-r--r-- | library/core/src/str/mod.rs | 36 | ||||
| -rw-r--r-- | library/core/src/str/traits.rs | 30 | 
12 files changed, 153 insertions, 53 deletions
| diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index ee79021ed53..20dfbc6347c 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -276,9 +276,10 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] { } #[stable(feature = "index_trait_on_arrays", since = "1.50.0")] -impl<T, I, const N: usize> Index<I> for [T; N] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<T, I, const N: usize> const Index<I> for [T; N] where - [T]: Index<I>, + [T]: ~const Index<I>, { type Output = <[T] as Index<I>>::Output; @@ -289,9 +290,10 @@ where } #[stable(feature = "index_trait_on_arrays", since = "1.50.0")] -impl<T, I, const N: usize> IndexMut<I> for [T; N] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<T, I, const N: usize> const IndexMut<I> for [T; N] where - [T]: IndexMut<I>, + [T]: ~const IndexMut<I>, { #[inline] fn index_mut(&mut self, index: I) -> &mut Self::Output { diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index b38df1c2d02..c35d0784dd5 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -35,6 +35,11 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {} to have a bounded `RangeInclusive`: `0..=end`" ), on( + _Self = "[]", + label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`" + ), + on(_Self = "&[]", label = "`{Self}` is not an iterator; try calling `.iter()`"), + on( _Self = "&str", label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" ), diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ddd8ae0c02c..97add8f2c6a 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -149,6 +149,8 @@ #![feature(variant_count)] #![feature(const_array_from_ref)] #![feature(const_slice_from_ref)] +#![feature(const_slice_index)] +#![feature(const_is_char_boundary)] // // Language features: #![feature(abi_unadjusted)] @@ -167,6 +169,7 @@ #![feature(const_refs_to_cell)] #![feature(decl_macro)] #![feature(derive_default_enum)] +#![cfg_attr(not(bootstrap), feature(deprecated_suggestion))] #![feature(doc_cfg)] #![feature(doc_notable_trait)] #![feature(rustdoc_internals)] diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 72105888f94..07fd317e074 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -809,7 +809,7 @@ impl u8 { ascii::escape_default(self) } - pub(crate) fn is_utf8_char_boundary(self) -> bool { + pub(crate) const fn is_utf8_char_boundary(self) -> bool { // This is bit magic equivalent to: b < 128 || b >= 192 (self as i8) >= -0x40 } diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index 11367220678..5029e0560b8 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -446,7 +446,7 @@ impl RangeInclusive<usize> { /// Converts to an exclusive `Range` for `SliceIndex` implementations. /// The caller is responsible for dealing with `end == usize::MAX`. #[inline] - pub(crate) fn into_slice_range(self) -> Range<usize> { + pub(crate) const fn into_slice_range(self) -> Range<usize> { // If we're not exhausted, we want to simply slice `start..end + 1`. // If we are exhausted, then slicing with `end + 1..end + 1` gives us an // empty range that is still subject to bounds-checks for that endpoint. diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 485a5965f4c..ee544b4842e 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1032,10 +1032,11 @@ impl<T> *const [T] { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output + pub const unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. unsafe { index.get_unchecked(self) } diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 1412e836ebf..3374b48c88c 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1302,10 +1302,11 @@ impl<T> *mut [T] { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline(always)] - pub unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output + pub const unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. unsafe { index.get_unchecked_mut(self) } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 77b93e0c24c..c744ad5dd2d 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -630,10 +630,11 @@ impl<T> NonNull<[T]> { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut<I>(self, index: I) -> NonNull<I::Output> + pub const unsafe fn get_unchecked_mut<I>(self, index: I) -> NonNull<I::Output> where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. // As a consequence, the resulting pointer cannot be null. diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 0298bba8d32..7e6fbbe3538 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -1,12 +1,14 @@ //! Indexing implementations for `[T]`. +use crate::intrinsics::const_eval_select; use crate::ops; use crate::ptr; #[stable(feature = "rust1", since = "1.0.0")] -impl<T, I> ops::Index<I> for [T] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<T, I> const ops::Index<I> for [T] where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { type Output = I::Output; @@ -17,9 +19,10 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl<T, I> ops::IndexMut<I> for [T] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<T, I> const ops::IndexMut<I> for [T] where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { #[inline] fn index_mut(&mut self, index: I) -> &mut I::Output { @@ -31,31 +34,72 @@ where #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_start_index_len_fail(index: usize, len: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_start_index_len_fail(index: usize, len: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { + const_eval_select( + (index, len), + slice_start_index_len_fail_ct, + slice_start_index_len_fail_rt, + ) + } +} + +// FIXME const-hack +fn slice_start_index_len_fail_rt(index: usize, len: usize) -> ! { panic!("range start index {} out of range for slice of length {}", index, len); } +const fn slice_start_index_len_fail_ct(_: usize, _: usize) -> ! { + panic!("slice start index is out of range for slice"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_end_index_len_fail(index: usize, len: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_end_index_len_fail(index: usize, len: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { + const_eval_select((index, len), slice_end_index_len_fail_ct, slice_end_index_len_fail_rt) + } +} + +// FIXME const-hack +fn slice_end_index_len_fail_rt(index: usize, len: usize) -> ! { panic!("range end index {} out of range for slice of length {}", index, len); } +const fn slice_end_index_len_fail_ct(_: usize, _: usize) -> ! { + panic!("slice end index is out of range for slice"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_index_order_fail(index: usize, end: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_index_order_fail(index: usize, end: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { const_eval_select((index, end), slice_index_order_fail_ct, slice_index_order_fail_rt) } +} + +// FIXME const-hack +fn slice_index_order_fail_rt(index: usize, end: usize) -> ! { panic!("slice index starts at {} but ends at {}", index, end); } +const fn slice_index_order_fail_ct(_: usize, _: usize) -> ! { + panic!("slice index start is larger than end"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_start_index_overflow_fail() -> ! { +const fn slice_start_index_overflow_fail() -> ! { panic!("attempted to index slice from after maximum usize"); } @@ -63,7 +107,7 @@ fn slice_start_index_overflow_fail() -> ! { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_end_index_overflow_fail() -> ! { +const fn slice_end_index_overflow_fail() -> ! { panic!("attempted to index slice up to maximum usize"); } @@ -153,7 +197,8 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl<T> SliceIndex<[T]> for usize { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for usize { type Output = T; #[inline] @@ -197,7 +242,8 @@ unsafe impl<T> SliceIndex<[T]> for usize { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::Range<usize> { type Output = [T]; #[inline] @@ -261,7 +307,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::RangeTo<usize> { type Output = [T]; #[inline] @@ -298,7 +345,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::RangeFrom<usize> { type Output = [T]; #[inline] @@ -343,7 +391,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl<T> SliceIndex<[T]> for ops::RangeFull { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::RangeFull { type Output = [T]; #[inline] @@ -378,7 +427,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull { } #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::RangeInclusive<usize> { type Output = [T]; #[inline] @@ -421,7 +471,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> { } #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl<T> const SliceIndex<[T]> for ops::RangeToInclusive<usize> { type Output = [T]; #[inline] diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 9467c7f54ba..7311fe40e04 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -324,10 +324,11 @@ impl<T> [T] { /// assert_eq!(None, v.get(0..4)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get<I>(&self, index: I) -> Option<&I::Output> + pub const fn get<I>(&self, index: I) -> Option<&I::Output> where - I: SliceIndex<Self>, + I: ~const SliceIndex<Self>, { index.get(self) } @@ -348,10 +349,11 @@ impl<T> [T] { /// assert_eq!(x, &[0, 42, 2]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> + pub const fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> where - I: SliceIndex<Self>, + I: ~const SliceIndex<Self>, { index.get_mut(self) } @@ -379,10 +381,11 @@ impl<T> [T] { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output + pub const unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output where - I: SliceIndex<Self>, + I: ~const SliceIndex<Self>, { // SAFETY: the caller must uphold most of the safety requirements for `get_unchecked`; // the slice is dereferenceable because `self` is a safe reference. @@ -415,10 +418,11 @@ impl<T> [T] { /// assert_eq!(x, &[1, 13, 4]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output + pub const unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output where - I: SliceIndex<Self>, + I: ~const SliceIndex<Self>, { // SAFETY: the caller must uphold the safety requirements for `get_unchecked_mut`; // the slice is dereferenceable because `self` is a safe reference. diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 09709dc3cf6..f66bab999a9 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -79,7 +79,23 @@ use iter::{MatchesInternal, SplitNInternal}; #[inline(never)] #[cold] #[track_caller] -fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { +#[rustc_allow_const_fn_unstable(const_eval_select)] +const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { + // SAFETY: panics for both branches + unsafe { + crate::intrinsics::const_eval_select( + (s, begin, end), + slice_error_fail_ct, + slice_error_fail_rt, + ) + } +} + +const fn slice_error_fail_ct(_: &str, _: usize, _: usize) -> ! { + panic!("failed to slice string"); +} + +fn slice_error_fail_rt(s: &str, begin: usize, end: usize) -> ! { const MAX_DISPLAY_LENGTH: usize = 256; let trunc_len = s.floor_char_boundary(MAX_DISPLAY_LENGTH); let s_trunc = &s[..trunc_len]; @@ -189,8 +205,9 @@ impl str { /// ``` #[must_use] #[stable(feature = "is_char_boundary", since = "1.9.0")] + #[rustc_const_unstable(feature = "const_is_char_boundary", issue = "none")] #[inline] - pub fn is_char_boundary(&self, index: usize) -> bool { + pub const fn is_char_boundary(&self, index: usize) -> bool { // 0 is always ok. // Test for 0 explicitly so that it can optimize out the check // easily and skip reading string data for that case. @@ -418,8 +435,9 @@ impl str { /// assert!(v.get(..42).is_none()); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> { + pub const fn get<I: ~const SliceIndex<str>>(&self, i: I) -> Option<&I::Output> { i.get(self) } @@ -450,8 +468,9 @@ impl str { /// assert_eq!("HEllo", v); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> { + pub const fn get_mut<I: ~const SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> { i.get_mut(self) } @@ -482,8 +501,9 @@ impl str { /// } /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output { + pub const unsafe fn get_unchecked<I: ~const SliceIndex<str>>(&self, i: I) -> &I::Output { // SAFETY: the caller must uphold the safety contract for `get_unchecked`; // the slice is dereferenceable because `self` is a safe reference. // The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is. @@ -517,8 +537,12 @@ impl str { /// } /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut<I: SliceIndex<str>>(&mut self, i: I) -> &mut I::Output { + pub const unsafe fn get_unchecked_mut<I: ~const SliceIndex<str>>( + &mut self, + i: I, + ) -> &mut I::Output { // SAFETY: the caller must uphold the safety contract for `get_unchecked_mut`; // the slice is dereferenceable because `self` is a safe reference. // The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is. diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index 95267624748..8b6b4fa02f8 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -53,9 +53,10 @@ impl PartialOrd for str { } #[stable(feature = "rust1", since = "1.0.0")] -impl<I> ops::Index<I> for str +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<I> const ops::Index<I> for str where - I: SliceIndex<str>, + I: ~const SliceIndex<str>, { type Output = I::Output; @@ -66,9 +67,10 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl<I> ops::IndexMut<I> for str +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl<I> const ops::IndexMut<I> for str where - I: SliceIndex<str>, + I: ~const SliceIndex<str>, { #[inline] fn index_mut(&mut self, index: I) -> &mut I::Output { @@ -79,7 +81,7 @@ where #[inline(never)] #[cold] #[track_caller] -fn str_index_overflow_fail() -> ! { +const fn str_index_overflow_fail() -> ! { panic!("attempted to index str up to maximum usize"); } @@ -96,7 +98,8 @@ fn str_index_overflow_fail() -> ! { /// /// Equivalent to `&self[0 .. len]` or `&mut self[0 .. len]`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex<str> for ops::RangeFull { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::RangeFull { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -160,7 +163,8 @@ unsafe impl SliceIndex<str> for ops::RangeFull { /// // &s[3 .. 100]; /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex<str> for ops::Range<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::Range<usize> { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -247,7 +251,8 @@ unsafe impl SliceIndex<str> for ops::Range<usize> { /// Panics if `end` does not point to the starting byte offset of a /// character (as defined by `is_char_boundary`), or if `end > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex<str> for ops::RangeTo<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::RangeTo<usize> { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -317,7 +322,8 @@ unsafe impl SliceIndex<str> for ops::RangeTo<usize> { /// Panics if `begin` does not point to the starting byte offset of /// a character (as defined by `is_char_boundary`), or if `begin > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex<str> for ops::RangeFrom<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::RangeFrom<usize> { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -393,7 +399,8 @@ unsafe impl SliceIndex<str> for ops::RangeFrom<usize> { /// to the ending byte offset of a character (`end + 1` is either a starting /// byte offset or equal to `len`), if `begin > end`, or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex<str> for ops::RangeInclusive<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::RangeInclusive<usize> { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -444,7 +451,8 @@ unsafe impl SliceIndex<str> for ops::RangeInclusive<usize> { /// (`end + 1` is either a starting byte offset as defined by /// `is_char_boundary`, or equal to `len`), or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex<str> for ops::RangeToInclusive<usize> { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { | 
