Skip to content

Commit d62164c

Browse files
committed
Stabilize const_vec_string_slice
This feature was approved for stabilization in #129041 (comment) so this change stabilizes it.
1 parent 28b83ee commit d62164c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

library/alloc/src/string.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,8 @@ impl String {
10591059
#[inline]
10601060
#[must_use = "`self` will be dropped if the result is not used"]
10611061
#[stable(feature = "rust1", since = "1.0.0")]
1062-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1062+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
1063+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
10631064
pub const fn into_bytes(self) -> Vec<u8> {
10641065
self.vec
10651066
}
@@ -1077,7 +1078,7 @@ impl String {
10771078
#[must_use]
10781079
#[stable(feature = "string_as_str", since = "1.7.0")]
10791080
#[cfg_attr(not(test), rustc_diagnostic_item = "string_as_str")]
1080-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1081+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
10811082
pub const fn as_str(&self) -> &str {
10821083
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
10831084
// at construction.
@@ -1100,7 +1101,7 @@ impl String {
11001101
#[must_use]
11011102
#[stable(feature = "string_as_str", since = "1.7.0")]
11021103
#[cfg_attr(not(test), rustc_diagnostic_item = "string_as_mut_str")]
1103-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1104+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
11041105
pub const fn as_mut_str(&mut self) -> &mut str {
11051106
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
11061107
// at construction.
@@ -1175,7 +1176,7 @@ impl String {
11751176
#[inline]
11761177
#[must_use]
11771178
#[stable(feature = "rust1", since = "1.0.0")]
1178-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1179+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
11791180
pub const fn capacity(&self) -> usize {
11801181
self.vec.capacity()
11811182
}
@@ -1441,7 +1442,7 @@ impl String {
14411442
#[inline]
14421443
#[must_use]
14431444
#[stable(feature = "rust1", since = "1.0.0")]
1444-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1445+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
14451446
pub const fn as_bytes(&self) -> &[u8] {
14461447
self.vec.as_slice()
14471448
}
@@ -1795,7 +1796,7 @@ impl String {
17951796
/// ```
17961797
#[inline]
17971798
#[stable(feature = "rust1", since = "1.0.0")]
1798-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1799+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
17991800
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
18001801
&mut self.vec
18011802
}
@@ -1817,7 +1818,7 @@ impl String {
18171818
#[inline]
18181819
#[must_use]
18191820
#[stable(feature = "rust1", since = "1.0.0")]
1820-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1821+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
18211822
#[rustc_confusables("length", "size")]
18221823
pub const fn len(&self) -> usize {
18231824
self.vec.len()
@@ -1837,7 +1838,7 @@ impl String {
18371838
#[inline]
18381839
#[must_use]
18391840
#[stable(feature = "rust1", since = "1.0.0")]
1840-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1841+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
18411842
pub const fn is_empty(&self) -> bool {
18421843
self.len() == 0
18431844
}

library/alloc/src/vec/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ impl<T, A: Allocator> Vec<T, A> {
12421242
/// ```
12431243
#[inline]
12441244
#[stable(feature = "rust1", since = "1.0.0")]
1245-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1245+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
12461246
pub const fn capacity(&self) -> usize {
12471247
self.buf.capacity()
12481248
}
@@ -1557,7 +1557,7 @@ impl<T, A: Allocator> Vec<T, A> {
15571557
#[inline]
15581558
#[stable(feature = "vec_as_slice", since = "1.7.0")]
15591559
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_slice")]
1560-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1560+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
15611561
pub const fn as_slice(&self) -> &[T] {
15621562
// SAFETY: `slice::from_raw_parts` requires pointee is a contiguous, aligned buffer of size
15631563
// `len` containing properly-initialized `T`s. Data must not be mutated for the returned
@@ -1589,7 +1589,7 @@ impl<T, A: Allocator> Vec<T, A> {
15891589
#[inline]
15901590
#[stable(feature = "vec_as_slice", since = "1.7.0")]
15911591
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_mut_slice")]
1592-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1592+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
15931593
pub const fn as_mut_slice(&mut self) -> &mut [T] {
15941594
// SAFETY: `slice::from_raw_parts_mut` requires pointee is a contiguous, aligned buffer of
15951595
// size `len` containing properly-initialized `T`s. Data must not be accessed through any
@@ -1661,7 +1661,7 @@ impl<T, A: Allocator> Vec<T, A> {
16611661
/// [`as_ptr`]: Vec::as_ptr
16621662
/// [`as_non_null`]: Vec::as_non_null
16631663
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1664-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1664+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
16651665
#[rustc_never_returns_null_ptr]
16661666
#[rustc_as_ptr]
16671667
#[inline]
@@ -1724,7 +1724,7 @@ impl<T, A: Allocator> Vec<T, A> {
17241724
/// [`as_ptr`]: Vec::as_ptr
17251725
/// [`as_non_null`]: Vec::as_non_null
17261726
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1727-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1727+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
17281728
#[rustc_never_returns_null_ptr]
17291729
#[rustc_as_ptr]
17301730
#[inline]
@@ -2675,7 +2675,7 @@ impl<T, A: Allocator> Vec<T, A> {
26752675
/// ```
26762676
#[inline]
26772677
#[stable(feature = "rust1", since = "1.0.0")]
2678-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
2678+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
26792679
#[rustc_confusables("length", "size")]
26802680
pub const fn len(&self) -> usize {
26812681
let len = self.len;
@@ -2701,7 +2701,7 @@ impl<T, A: Allocator> Vec<T, A> {
27012701
/// ```
27022702
#[stable(feature = "rust1", since = "1.0.0")]
27032703
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_is_empty")]
2704-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
2704+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
27052705
pub const fn is_empty(&self) -> bool {
27062706
self.len() == 0
27072707
}

tests/ui/consts/issue-94675.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(const_trait_impl, const_vec_string_slice)]
1+
#![feature(const_trait_impl)]
22

33
struct Foo<'a> {
44
bar: &'a mut Vec<usize>,

0 commit comments

Comments
 (0)