Skip to content

Commit bcdc8e8

Browse files
committed
Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes)
1 parent 5569ece commit bcdc8e8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/ffi/c_str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ impl CStr {
263263
/// ```
264264
///
265265
/// ```
266-
/// #![feature(const_cstr_from_ptr)]
267-
///
268266
/// use std::ffi::{c_char, CStr};
269267
///
270268
/// const HELLO_PTR: *const c_char = {
@@ -280,7 +278,7 @@ impl CStr {
280278
#[inline] // inline is necessary for codegen to see strlen.
281279
#[must_use]
282280
#[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")]
284282
pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
285283
// SAFETY: The caller has provided a pointer that points to a valid C
286284
// string with a NUL terminator less than `isize::MAX` from `ptr`.
@@ -542,7 +540,7 @@ impl CStr {
542540
#[must_use]
543541
#[doc(alias("len", "strlen"))]
544542
#[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")]
546544
pub const fn count_bytes(&self) -> usize {
547545
self.inner.len() - 1
548546
}
@@ -742,6 +740,8 @@ impl AsRef<CStr> for CStr {
742740
/// The pointer must point to a valid buffer that contains a NUL terminator. The NUL must be
743741
/// located within `isize::MAX` from `ptr`.
744742
#[inline]
743+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
744+
#[rustc_allow_const_fn_unstable(const_eval_select)]
745745
const unsafe fn const_strlen(ptr: *const c_char) -> usize {
746746
const fn strlen_ct(s: *const c_char) -> usize {
747747
let mut len = 0;

0 commit comments

Comments
 (0)