mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #137319 - Kixunil:stabilize-const-vec-string-slice, r=dtolnay
Stabilize `const_vec_string_slice` This feature was approved for stabilization in https://github.com/rust-lang/rust/issues/129041#issuecomment-2508940661 so this change stabilizes it.
This commit is contained in:
@@ -1043,7 +1043,8 @@ pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String {
|
||||
#[inline]
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
|
||||
pub const fn into_bytes(self) -> Vec<u8> {
|
||||
self.vec
|
||||
}
|
||||
@@ -1061,7 +1062,7 @@ pub const fn into_bytes(self) -> Vec<u8> {
|
||||
#[must_use]
|
||||
#[stable(feature = "string_as_str", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "string_as_str"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_str(&self) -> &str {
|
||||
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
|
||||
// at construction.
|
||||
@@ -1084,7 +1085,7 @@ pub const fn as_str(&self) -> &str {
|
||||
#[must_use]
|
||||
#[stable(feature = "string_as_str", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "string_as_mut_str"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_mut_str(&mut self) -> &mut str {
|
||||
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
|
||||
// at construction.
|
||||
@@ -1158,7 +1159,7 @@ pub fn extend_from_within<R>(&mut self, src: R)
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.vec.capacity()
|
||||
}
|
||||
@@ -1424,7 +1425,7 @@ pub fn push(&mut self, ch: char) {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_bytes(&self) -> &[u8] {
|
||||
self.vec.as_slice()
|
||||
}
|
||||
@@ -1778,7 +1779,7 @@ pub fn insert_str(&mut self, idx: usize, string: &str) {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
|
||||
&mut self.vec
|
||||
}
|
||||
@@ -1800,7 +1801,7 @@ pub fn insert_str(&mut self, idx: usize, string: &str) {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_confusables("length", "size")]
|
||||
pub const fn len(&self) -> usize {
|
||||
self.vec.len()
|
||||
@@ -1820,7 +1821,7 @@ pub const fn len(&self) -> usize {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
@@ -1254,7 +1254,7 @@ pub fn into_parts_with_alloc(self) -> (NonNull<T>, usize, usize, A) {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.buf.capacity()
|
||||
}
|
||||
@@ -1569,7 +1569,7 @@ pub fn truncate(&mut self, len: usize) {
|
||||
#[inline]
|
||||
#[stable(feature = "vec_as_slice", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "vec_as_slice"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_slice(&self) -> &[T] {
|
||||
// SAFETY: `slice::from_raw_parts` requires pointee is a contiguous, aligned buffer of size
|
||||
// `len` containing properly-initialized `T`s. Data must not be mutated for the returned
|
||||
@@ -1601,7 +1601,7 @@ pub const fn as_slice(&self) -> &[T] {
|
||||
#[inline]
|
||||
#[stable(feature = "vec_as_slice", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "vec_as_mut_slice"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
// SAFETY: `slice::from_raw_parts_mut` requires pointee is a contiguous, aligned buffer of
|
||||
// size `len` containing properly-initialized `T`s. Data must not be accessed through any
|
||||
@@ -1673,7 +1673,7 @@ pub const fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
/// [`as_ptr`]: Vec::as_ptr
|
||||
/// [`as_non_null`]: Vec::as_non_null
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_never_returns_null_ptr]
|
||||
#[rustc_as_ptr]
|
||||
#[inline]
|
||||
@@ -1736,7 +1736,7 @@ pub const fn as_ptr(&self) -> *const T {
|
||||
/// [`as_ptr`]: Vec::as_ptr
|
||||
/// [`as_non_null`]: Vec::as_non_null
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_never_returns_null_ptr]
|
||||
#[rustc_as_ptr]
|
||||
#[inline]
|
||||
@@ -2687,7 +2687,7 @@ pub fn clear(&mut self) {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_confusables("length", "size")]
|
||||
pub const fn len(&self) -> usize {
|
||||
let len = self.len;
|
||||
@@ -2713,7 +2713,7 @@ pub const fn len(&self) -> usize {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "vec_is_empty"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(const_trait_impl, const_vec_string_slice)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct Foo<'a> {
|
||||
bar: &'a mut Vec<usize>,
|
||||
|
||||
Reference in New Issue
Block a user