Skip to content

Commit a962b26

Browse files
committed
liballoc/{String,Vec}: fixup const attributes, some old fn names
1 parent b077aa4 commit a962b26

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ impl<T, A: Allocator> Vec<T, A> {
946946
/// ```
947947
#[inline]
948948
#[stable(feature = "rust1", since = "1.0.0")]
949-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
949+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
950950
pub const fn capacity(&self) -> usize {
951951
self.buf.capacity()
952952
}
@@ -1254,9 +1254,9 @@ impl<T, A: Allocator> Vec<T, A> {
12541254
/// ```
12551255
#[inline]
12561256
#[stable(feature = "vec_as_slice", since = "1.7.0")]
1257-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1257+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
12581258
pub const fn as_slice(&self) -> &[T] {
1259-
unsafe { slice::from_raw_parts(self.as_ptr_const(), self.len) }
1259+
unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
12601260
}
12611261

12621262
/// Extracts a mutable slice of the entire vector.
@@ -1328,7 +1328,7 @@ impl<T, A: Allocator> Vec<T, A> {
13281328
/// [`as_mut_ptr`]: Vec::as_mut_ptr
13291329
/// [`as_ptr`]: Vec::as_ptr
13301330
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
1331-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
1331+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
13321332
#[rustc_never_returns_null_ptr]
13331333
#[inline]
13341334
pub const fn as_ptr(&self) -> *const T {
@@ -2265,7 +2265,7 @@ impl<T, A: Allocator> Vec<T, A> {
22652265
/// ```
22662266
#[inline]
22672267
#[stable(feature = "rust1", since = "1.0.0")]
2268-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
2268+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
22692269
#[rustc_confusables("length", "size")]
22702270
pub const fn len(&self) -> usize {
22712271
self.len
@@ -2283,7 +2283,7 @@ impl<T, A: Allocator> Vec<T, A> {
22832283
/// assert!(!v.is_empty());
22842284
/// ```
22852285
#[stable(feature = "rust1", since = "1.0.0")]
2286-
#[rustc_const_unstable(feature = "const_vec_string_slice")]
2286+
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "none")]
22872287
pub const fn is_empty(&self) -> bool {
22882288
self.len() == 0
22892289
}

0 commit comments

Comments
 (0)