Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) · model-checking/verify-rust-std@bcdc8e8 (original) (raw)
`@@ -263,8 +263,6 @@ impl CStr {
`
263
263
```` /// ```
`264`
`264`
`///
`
`265`
`265`
```` /// ```
266
``
`-
/// #![feature(const_cstr_from_ptr)]
`
267
``
`-
///
`
268
266
`/// use std::ffi::{c_char, CStr};
`
269
267
`///
`
270
268
`/// const HELLO_PTR: *const c_char = {
`
`@@ -280,7 +278,7 @@ impl CStr {
`
280
278
`#[inline] // inline is necessary for codegen to see strlen.
`
281
279
`#[must_use]
`
282
280
`#[stable(feature = "rust1", since = "1.0.0")]
`
283
``
`-
#[rustc_const_unstable(feature = "const_cstr_from_ptr", issue = "113219")]
`
``
281
`+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
`
284
282
`pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
`
285
283
`// SAFETY: The caller has provided a pointer that points to a valid C
`
286
284
`` // string with a NUL terminator less than isize::MAX
from ptr
.
``
`@@ -542,7 +540,7 @@ impl CStr {
`
542
540
`#[must_use]
`
543
541
`#[doc(alias("len", "strlen"))]
`
544
542
`#[stable(feature = "cstr_count_bytes", since = "1.79.0")]
`
545
``
`-
#[rustc_const_unstable(feature = "const_cstr_from_ptr", issue = "113219")]
`
``
543
`+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
`
546
544
`pub const fn count_bytes(&self) -> usize {
`
547
545
`self.inner.len() - 1
`
548
546
`}
`
`@@ -742,6 +740,8 @@ impl AsRef for CStr {
`
742
740
`/// The pointer must point to a valid buffer that contains a NUL terminator. The NUL must be
`
743
741
`` /// located within isize::MAX
from ptr
.
``
744
742
`#[inline]
`
``
743
`+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
`
``
744
`+
#[rustc_allow_const_fn_unstable(const_eval_select)]
`
745
745
`const unsafe fn const_strlen(ptr: *const c_char) -> usize {
`
746
746
`const fn strlen_ct(s: *const c_char) -> usize {
`
747
747
`let mut len = 0;
`