Skip to content

Commit 083a253

Browse files
authored
Rollup merge of rust-lang#99277 - joshtriplett:stabilize-core-cstr-alloc-cstring, r=Mark-Simulacrum
Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends Stabilize the `core_c_str` and `alloc_c_string` feature gates. Change `std::ffi` to re-export these types rather than creating type aliases, since they now have matching stability.
2 parents 96474a7 + d6b7480 commit 083a253

File tree

8 files changed

+14
-34
lines changed

8 files changed

+14
-34
lines changed

library/alloc/src/ffi/c_str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ use crate::sync::Arc;
108108
/// and other memory errors.
109109
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)]
110110
#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")]
111-
#[unstable(feature = "alloc_c_string", issue = "94079")]
111+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
112112
pub struct CString {
113113
// Invariant 1: the slice ends with a zero byte and has a length of at least one.
114114
// Invariant 2: the slice contains only one zero byte.
@@ -132,7 +132,7 @@ pub struct CString {
132132
/// let _: NulError = CString::new(b"f\0oo".to_vec()).unwrap_err();
133133
/// ```
134134
#[derive(Clone, PartialEq, Eq, Debug)]
135-
#[unstable(feature = "alloc_c_string", issue = "94079")]
135+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
136136
pub struct NulError(usize, Vec<u8>);
137137

138138
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -157,7 +157,7 @@ enum FromBytesWithNulErrorKind {
157157
/// let _: FromVecWithNulError = CString::from_vec_with_nul(b"f\0oo".to_vec()).unwrap_err();
158158
/// ```
159159
#[derive(Clone, PartialEq, Eq, Debug)]
160-
#[unstable(feature = "alloc_c_string", issue = "94079")]
160+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
161161
pub struct FromVecWithNulError {
162162
error_kind: FromBytesWithNulErrorKind,
163163
bytes: Vec<u8>,
@@ -223,7 +223,7 @@ impl FromVecWithNulError {
223223
/// This `struct` is created by [`CString::into_string()`]. See
224224
/// its documentation for more.
225225
#[derive(Clone, PartialEq, Eq, Debug)]
226-
#[unstable(feature = "alloc_c_string", issue = "94079")]
226+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
227227
pub struct IntoStringError {
228228
inner: CString,
229229
error: Utf8Error,

library/alloc/src/ffi/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
//! [`String`]: crate::string::String
7979
//! [`CStr`]: core::ffi::CStr
8080
81-
#![unstable(feature = "alloc_ffi", issue = "94079")]
81+
#![stable(feature = "alloc_ffi", since = "1.64.0")]
8282

83-
#[unstable(feature = "alloc_c_string", issue = "94079")]
83+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8484
pub use self::c_str::FromVecWithNulError;
85-
#[unstable(feature = "alloc_c_string", issue = "94079")]
85+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8686
pub use self::c_str::{CString, IntoStringError, NulError};
8787

8888
mod c_str;

library/alloc/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
#![allow(explicit_outlives_requirements)]
8787
//
8888
// Library features:
89-
#![cfg_attr(not(no_global_oom_handling), feature(alloc_c_string))]
9089
#![feature(alloc_layout_extra)]
9190
#![feature(allocator_api)]
9291
#![feature(array_chunks)]
@@ -106,7 +105,6 @@
106105
#![feature(const_maybe_uninit_write)]
107106
#![feature(const_maybe_uninit_as_mut_ptr)]
108107
#![feature(const_refs_to_cell)]
109-
#![feature(core_c_str)]
110108
#![feature(core_intrinsics)]
111109
#![feature(const_eval_select)]
112110
#![feature(const_pin)]

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(const_nonnull_slice_from_raw_parts)]
1212
#![feature(const_ptr_write)]
1313
#![feature(const_try)]
14-
#![feature(core_c_str)]
1514
#![feature(core_intrinsics)]
1615
#![feature(drain_filter)]
1716
#![feature(exact_size_is_empty)]

library/core/src/ffi/c_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use crate::str;
7676
/// [str]: prim@str "str"
7777
#[derive(Hash)]
7878
#[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
79-
#[unstable(feature = "core_c_str", issue = "94079")]
79+
#[stable(feature = "core_c_str", since = "1.64.0")]
8080
#[rustc_has_incoherent_inherent_impls]
8181
// FIXME:
8282
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
@@ -108,7 +108,7 @@ pub struct CStr {
108108
/// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
109109
/// ```
110110
#[derive(Clone, PartialEq, Eq, Debug)]
111-
#[unstable(feature = "core_c_str", issue = "94079")]
111+
#[stable(feature = "core_c_str", since = "1.64.0")]
112112
pub struct FromBytesWithNulError {
113113
kind: FromBytesWithNulErrorKind,
114114
}

library/core/src/ffi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::marker::PhantomData;
1414
use crate::num::*;
1515
use crate::ops::{Deref, DerefMut};
1616

17-
#[unstable(feature = "core_c_str", issue = "94079")]
17+
#[stable(feature = "core_c_str", since = "1.64.0")]
1818
pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
1919

2020
mod c_str;

library/std/src/ffi/mod.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,10 @@
146146
147147
#![stable(feature = "rust1", since = "1.0.0")]
148148

149-
/// See [alloc::ffi::FromVecWithNulError].
150-
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
151-
pub type FromVecWithNulError = alloc::ffi::FromVecWithNulError;
152-
/// See [alloc::ffi::CString].
153-
#[stable(feature = "rust1", since = "1.0.0")]
154-
pub type CString = alloc::ffi::CString;
155-
/// See [alloc::ffi::IntoStringError].
156-
#[stable(feature = "rust1", since = "1.0.0")]
157-
pub type IntoStringError = alloc::ffi::IntoStringError;
158-
/// See [alloc::ffi::NulError].
159-
#[stable(feature = "rust1", since = "1.0.0")]
160-
pub type NulError = alloc::ffi::NulError;
161-
/// See [core::ffi::CStr].
162-
#[stable(feature = "rust1", since = "1.0.0")]
163-
pub type CStr = core::ffi::CStr;
164-
/// See [core::ffi::FromBytesWithNulError].
165-
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
166-
pub type FromBytesWithNulError = core::ffi::FromBytesWithNulError;
149+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
150+
pub use alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError};
151+
#[stable(feature = "core_c_str", since = "1.64.0")]
152+
pub use core::ffi::{CStr, FromBytesWithNulError};
167153

168154
#[stable(feature = "rust1", since = "1.0.0")]
169155
pub use self::os_str::{OsStr, OsString};

library/std/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@
264264
#![feature(atomic_mut_ptr)]
265265
#![feature(char_error_internals)]
266266
#![feature(char_internals)]
267-
#![feature(core_c_str)]
268267
#![feature(core_intrinsics)]
269268
#![feature(cstr_from_bytes_until_nul)]
270269
#![feature(cstr_internals)]
@@ -297,8 +296,6 @@
297296
//
298297
// Library features (alloc):
299298
#![feature(alloc_layout_extra)]
300-
#![feature(alloc_c_string)]
301-
#![feature(alloc_ffi)]
302299
#![feature(allocator_api)]
303300
#![feature(get_mut_unchecked)]
304301
#![feature(map_try_insert)]

0 commit comments

Comments
 (0)