Skip to content

Commit 7f3cc2f

Browse files
committed
library: Use type aliases to make CStr(ing) in libcore/liballoc unstable
1 parent 5bee741 commit 7f3cc2f

File tree

8 files changed

+28
-13
lines changed

8 files changed

+28
-13
lines changed

library/alloc/src/ffi/c_str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ use core::str::{self, Utf8Error};
106106
/// and other memory errors.
107107
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)]
108108
#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")]
109-
#[stable(feature = "rust1", since = "1.0.0")]
109+
#[unstable(feature = "alloc_c_string", issue = "94079")]
110110
pub struct CString {
111111
// Invariant 1: the slice ends with a zero byte and has a length of at least one.
112112
// Invariant 2: the slice contains only one zero byte.
@@ -130,7 +130,7 @@ pub struct CString {
130130
/// let _: NulError = CString::new(b"f\0oo".to_vec()).unwrap_err();
131131
/// ```
132132
#[derive(Clone, PartialEq, Eq, Debug)]
133-
#[stable(feature = "rust1", since = "1.0.0")]
133+
#[unstable(feature = "alloc_c_string", issue = "94079")]
134134
pub struct NulError(usize, Vec<u8>);
135135

136136
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -155,7 +155,7 @@ enum FromBytesWithNulErrorKind {
155155
/// let _: FromVecWithNulError = CString::from_vec_with_nul(b"f\0oo".to_vec()).unwrap_err();
156156
/// ```
157157
#[derive(Clone, PartialEq, Eq, Debug)]
158-
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
158+
#[unstable(feature = "alloc_c_string", issue = "94079")]
159159
pub struct FromVecWithNulError {
160160
error_kind: FromBytesWithNulErrorKind,
161161
bytes: Vec<u8>,
@@ -221,7 +221,7 @@ impl FromVecWithNulError {
221221
/// This `struct` is created by [`CString::into_string()`]. See
222222
/// its documentation for more.
223223
#[derive(Clone, PartialEq, Eq, Debug)]
224-
#[stable(feature = "cstring_into", since = "1.7.0")]
224+
#[unstable(feature = "alloc_c_string", issue = "94079")]
225225
pub struct IntoStringError {
226226
inner: CString,
227227
error: Utf8Error,

library/alloc/src/ffi/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
#[cfg(bootstrap)]
8484
#[unstable(feature = "cstr_internals", issue = "none")]
8585
pub use self::c_str::CStrExt;
86-
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
86+
#[unstable(feature = "alloc_c_string", issue = "94079")]
8787
pub use self::c_str::FromVecWithNulError;
88-
#[stable(feature = "rust1", since = "1.0.0")]
88+
#[unstable(feature = "alloc_c_string", issue = "94079")]
8989
pub use self::c_str::{CString, IntoStringError, NulError};
9090

9191
mod c_str;

library/alloc/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#![allow(explicit_outlives_requirements)]
8787
//
8888
// Library features:
89+
#![cfg_attr(not(no_global_oom_handling), feature(alloc_c_string))]
8990
#![feature(alloc_layout_extra)]
9091
#![feature(allocator_api)]
9192
#![feature(array_chunks)]
@@ -105,6 +106,7 @@
105106
#![feature(const_maybe_uninit_write)]
106107
#![feature(const_maybe_uninit_as_mut_ptr)]
107108
#![feature(const_refs_to_cell)]
109+
#![feature(core_c_str)]
108110
#![feature(core_intrinsics)]
109111
#![feature(core_ffi_c)]
110112
#![feature(const_eval_select)]

library/alloc/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(const_nonnull_slice_from_raw_parts)]
1313
#![feature(const_ptr_write)]
1414
#![feature(const_try)]
15+
#![feature(core_c_str)]
1516
#![feature(core_ffi_c)]
1617
#![feature(core_intrinsics)]
1718
#![feature(drain_filter)]

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-
#[stable(feature = "rust1", since = "1.0.0")]
79+
#[unstable(feature = "core_c_str", issue = "94079")]
8080
#[cfg_attr(not(bootstrap), lang = "CStr")]
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-
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
111+
#[unstable(feature = "core_c_str", issue = "94079")]
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-
#[stable(feature = "rust1", since = "1.0.0")]
17+
#[unstable(feature = "core_c_str", issue = "94079")]
1818
pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
1919

2020
mod c_str;

library/std/src/ffi/mod.rs

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

149+
/// See [alloc::ffi::FromVecWithNulError].
149150
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
150-
pub use alloc::ffi::FromVecWithNulError;
151+
pub type FromVecWithNulError = alloc::ffi::FromVecWithNulError;
152+
/// See [alloc::ffi::CString].
151153
#[stable(feature = "rust1", since = "1.0.0")]
152-
pub use alloc::ffi::{CString, IntoStringError, NulError};
154+
pub type CString = alloc::ffi::CString;
155+
/// See [alloc::ffi::IntoStringError].
153156
#[stable(feature = "rust1", since = "1.0.0")]
154-
pub use core::ffi::CStr;
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].
155165
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
156-
pub use core::ffi::FromBytesWithNulError;
166+
pub type FromBytesWithNulError = core::ffi::FromBytesWithNulError;
157167

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

library/std/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
#![feature(atomic_mut_ptr)]
261261
#![feature(char_error_internals)]
262262
#![feature(char_internals)]
263+
#![feature(core_c_str)]
263264
#![feature(core_intrinsics)]
264265
#![feature(cstr_from_bytes_until_nul)]
265266
#![feature(cstr_internals)]
@@ -288,6 +289,7 @@
288289
//
289290
// Library features (alloc):
290291
#![feature(alloc_layout_extra)]
292+
#![feature(alloc_c_string)]
291293
#![feature(allocator_api)]
292294
#![feature(get_mut_unchecked)]
293295
#![feature(map_try_insert)]

0 commit comments

Comments
 (0)