Skip to content

Commit 50ea503

Browse files
committed
Stabilize const_vec_string_slice
This feature was approved for stabilization in #129041 (comment) so this change stabilizes it.
1 parent 79b43df commit 50ea503

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
@@ -1043,7 +1043,8 @@ impl String {
10431043
#[inline]
10441044
#[must_use = "`self` will be dropped if the result is not used"]
10451045
#[stable(feature = "rust1", since = "1.0.0")]
1046-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1046+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
1047+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
10471048
pub const fn into_bytes(self) -> Vec<u8> {
10481049
self.vec
10491050
}
@@ -1061,7 +1062,7 @@ impl String {
10611062
#[must_use]
10621063
#[stable(feature = "string_as_str", since = "1.7.0")]
10631064
#[rustc_diagnostic_item = "string_as_str"]
1064-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1065+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
10651066
pub const fn as_str(&self) -> &str {
10661067
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
10671068
// at construction.
@@ -1084,7 +1085,7 @@ impl String {
10841085
#[must_use]
10851086
#[stable(feature = "string_as_str", since = "1.7.0")]
10861087
#[rustc_diagnostic_item = "string_as_mut_str"]
1087-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1088+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
10881089
pub const fn as_mut_str(&mut self) -> &mut str {
10891090
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
10901091
// at construction.
@@ -1158,7 +1159,7 @@ impl String {
11581159
#[inline]
11591160
#[must_use]
11601161
#[stable(feature = "rust1", since = "1.0.0")]
1161-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1162+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
11621163
pub const fn capacity(&self) -> usize {
11631164
self.vec.capacity()
11641165
}
@@ -1424,7 +1425,7 @@ impl String {
14241425
#[inline]
14251426
#[must_use]
14261427
#[stable(feature = "rust1", since = "1.0.0")]
1427-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1428+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
14281429
pub const fn as_bytes(&self) -> &[u8] {
14291430
self.vec.as_slice()
14301431
}
@@ -1778,7 +1779,7 @@ impl String {
17781779
/// ```
17791780
#[inline]
17801781
#[stable(feature = "rust1", since = "1.0.0")]
1781-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1782+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
17821783
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
17831784
&mut self.vec
17841785
}
@@ -1800,7 +1801,7 @@ impl String {
18001801
#[inline]
18011802
#[must_use]
18021803
#[stable(feature = "rust1", since = "1.0.0")]
1803-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1804+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
18041805
#[rustc_confusables("length", "size")]
18051806
pub const fn len(&self) -> usize {
18061807
self.vec.len()
@@ -1820,7 +1821,7 @@ impl String {
18201821
#[inline]
18211822
#[must_use]
18221823
#[stable(feature = "rust1", since = "1.0.0")]
1823-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1824+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
18241825
pub const fn is_empty(&self) -> bool {
18251826
self.len() == 0
18261827
}

library/alloc/src/vec/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ impl<T, A: Allocator> Vec<T, A> {
12541254
/// ```
12551255
#[inline]
12561256
#[stable(feature = "rust1", since = "1.0.0")]
1257-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1257+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
12581258
pub const fn capacity(&self) -> usize {
12591259
self.buf.capacity()
12601260
}
@@ -1569,7 +1569,7 @@ impl<T, A: Allocator> Vec<T, A> {
15691569
#[inline]
15701570
#[stable(feature = "vec_as_slice", since = "1.7.0")]
15711571
#[rustc_diagnostic_item = "vec_as_slice"]
1572-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1572+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
15731573
pub const fn as_slice(&self) -> &[T] {
15741574
// SAFETY: `slice::from_raw_parts` requires pointee is a contiguous, aligned buffer of size
15751575
// `len` containing properly-initialized `T`s. Data must not be mutated for the returned
@@ -1601,7 +1601,7 @@ impl<T, A: Allocator> Vec<T, A> {
16011601
#[inline]
16021602
#[stable(feature = "vec_as_slice", since = "1.7.0")]
16031603
#[rustc_diagnostic_item = "vec_as_mut_slice"]
1604-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1604+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
16051605
pub const fn as_mut_slice(&mut self) -> &mut [T] {
16061606
// SAFETY: `slice::from_raw_parts_mut` requires pointee is a contiguous, aligned buffer of
16071607
// size `len` containing properly-initialized `T`s. Data must not be accessed through any
@@ -1673,7 +1673,7 @@ impl<T, A: Allocator> Vec<T, A> {
16731673
/// [`as_ptr`]: Vec::as_ptr
16741674
/// [`as_non_null`]: Vec::as_non_null
16751675
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1676-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1676+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
16771677
#[rustc_never_returns_null_ptr]
16781678
#[rustc_as_ptr]
16791679
#[inline]
@@ -1736,7 +1736,7 @@ impl<T, A: Allocator> Vec<T, A> {
17361736
/// [`as_ptr`]: Vec::as_ptr
17371737
/// [`as_non_null`]: Vec::as_non_null
17381738
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1739-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
1739+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
17401740
#[rustc_never_returns_null_ptr]
17411741
#[rustc_as_ptr]
17421742
#[inline]
@@ -2687,7 +2687,7 @@ impl<T, A: Allocator> Vec<T, A> {
26872687
/// ```
26882688
#[inline]
26892689
#[stable(feature = "rust1", since = "1.0.0")]
2690-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
2690+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
26912691
#[rustc_confusables("length", "size")]
26922692
pub const fn len(&self) -> usize {
26932693
let len = self.len;
@@ -2713,7 +2713,7 @@ impl<T, A: Allocator> Vec<T, A> {
27132713
/// ```
27142714
#[stable(feature = "rust1", since = "1.0.0")]
27152715
#[rustc_diagnostic_item = "vec_is_empty"]
2716-
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
2716+
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
27172717
pub const fn is_empty(&self) -> bool {
27182718
self.len() == 0
27192719
}

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)