Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 86e8ede

Browse files
committedJul 31, 2024·
liballoc/{String,Vec}: fixup const attributes, some old fn names
1 parent f1a74be commit 86e8ede

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed
 

‎library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
#![feature(const_pin)]
118118
#![feature(const_refs_to_cell)]
119119
#![feature(const_size_of_val)]
120+
#![feature(const_vec_string_slice)]
120121
#![feature(core_intrinsics)]
121122
#![feature(deprecated_suggestion)]
122123
#![feature(deref_pure_trait)]

‎library/alloc/src/string.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ impl String {
10061006
#[inline]
10071007
#[must_use = "`self` will be dropped if the result is not used"]
10081008
#[stable(feature = "rust1", since = "1.0.0")]
1009-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1009+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
10101010
pub const fn into_bytes(self) -> Vec<u8> {
10111011
self.vec
10121012
}
@@ -1023,9 +1023,9 @@ impl String {
10231023
#[inline]
10241024
#[must_use]
10251025
#[stable(feature = "string_as_str", since = "1.7.0")]
1026-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1026+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
10271027
pub const fn as_str(&self) -> &str {
1028-
unsafe { str::from_utf8_unchecked(self.vec.as_slice_const()) }
1028+
unsafe { str::from_utf8_unchecked(self.vec.as_slice()) }
10291029
}
10301030

10311031
/// Converts a `String` into a mutable string slice.
@@ -1114,7 +1114,7 @@ impl String {
11141114
#[inline]
11151115
#[must_use]
11161116
#[stable(feature = "rust1", since = "1.0.0")]
1117-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1117+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
11181118
pub const fn capacity(&self) -> usize {
11191119
self.vec.capacity()
11201120
}
@@ -1378,9 +1378,9 @@ impl String {
13781378
#[inline]
13791379
#[must_use]
13801380
#[stable(feature = "rust1", since = "1.0.0")]
1381-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1381+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
13821382
pub const fn as_bytes(&self) -> &[u8] {
1383-
&self.vec
1383+
self.vec.as_slice()
13841384
}
13851385

13861386
/// Shortens this `String` to the specified length.
@@ -1752,7 +1752,7 @@ impl String {
17521752
#[inline]
17531753
#[must_use]
17541754
#[stable(feature = "rust1", since = "1.0.0")]
1755-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1755+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
17561756
#[rustc_confusables("length", "size")]
17571757
pub const fn len(&self) -> usize {
17581758
self.vec.len()
@@ -1772,7 +1772,7 @@ impl String {
17721772
#[inline]
17731773
#[must_use]
17741774
#[stable(feature = "rust1", since = "1.0.0")]
1775-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1775+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
17761776
pub const fn is_empty(&self) -> bool {
17771777
self.len() == 0
17781778
}

‎library/alloc/src/vec/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<T, A: Allocator> Vec<T, A> {
944944
/// ```
945945
#[inline]
946946
#[stable(feature = "rust1", since = "1.0.0")]
947-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
947+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
948948
pub const fn capacity(&self) -> usize {
949949
self.buf.capacity()
950950
}
@@ -1252,9 +1252,9 @@ impl<T, A: Allocator> Vec<T, A> {
12521252
/// ```
12531253
#[inline]
12541254
#[stable(feature = "vec_as_slice", since = "1.7.0")]
1255-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1255+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
12561256
pub const fn as_slice(&self) -> &[T] {
1257-
unsafe { slice::from_raw_parts(self.as_ptr_const(), self.len) }
1257+
unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
12581258
}
12591259

12601260
/// Extracts a mutable slice of the entire vector.
@@ -1326,7 +1326,7 @@ impl<T, A: Allocator> Vec<T, A> {
13261326
/// [`as_mut_ptr`]: Vec::as_mut_ptr
13271327
/// [`as_ptr`]: Vec::as_ptr
13281328
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1329-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1329+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
13301330
#[rustc_never_returns_null_ptr]
13311331
#[inline]
13321332
pub const fn as_ptr(&self) -> *const T {
@@ -2263,7 +2263,7 @@ impl<T, A: Allocator> Vec<T, A> {
22632263
/// ```
22642264
#[inline]
22652265
#[stable(feature = "rust1", since = "1.0.0")]
2266-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
2266+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
22672267
#[rustc_confusables("length", "size")]
22682268
pub const fn len(&self) -> usize {
22692269
self.len
@@ -2281,7 +2281,7 @@ impl<T, A: Allocator> Vec<T, A> {
22812281
/// assert!(!v.is_empty());
22822282
/// ```
22832283
#[stable(feature = "rust1", since = "1.0.0")]
2284-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
2284+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
22852285
pub const fn is_empty(&self) -> bool {
22862286
self.len() == 0
22872287
}

0 commit comments

Comments
 (0)
Please sign in to comment.