Skip to content

Commit 3697b4d

Browse files
committed
Export cstr! at correct path.
1 parent 0ab6a86 commit 3697b4d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Diff for: library/core/src/ffi/c_str.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl fmt::Debug for CStr {
184184
/// ```
185185
/// #![feature(cstr_macro)]
186186
///
187-
/// use core::ffi::CStr;
187+
/// use core::ffi::{cstr, CStr};
188188
///
189189
/// const HELLO: &CStr = cstr!("Hello, world!");
190190
/// assert_eq!(HELLO.to_bytes_with_nul(), b"Hello, world!\0");
@@ -196,16 +196,17 @@ impl fmt::Debug for CStr {
196196
/// ```compile_fail
197197
/// #![feature(const_cstr_from_bytes)]
198198
///
199-
/// use core::ffi::CStr;
199+
/// use core::ffi::{cstr, CStr};
200200
///
201201
/// const HELLO: &CStr = cstr!("Hello, world!\0"); // compile fail!
202202
/// ```
203-
#[macro_export]
203+
#[macro_export(local_inner_macros)]
204204
#[unstable(feature = "cstr_macro", issue = "101607")]
205205
#[rustc_diagnostic_item = "core_cstr_macro"]
206-
macro_rules! cstr {
206+
#[doc(hidden)]
207+
macro_rules! __cstr_macro_impl {
207208
() => {
208-
cstr!("")
209+
__cstr_macro_impl!("")
209210
};
210211
($s:literal) => {{
211212
const BYTES: &[u8] = $crate::ffi::__cstr_macro_impl_as_bytes($s);
@@ -216,6 +217,9 @@ macro_rules! cstr {
216217
CSTR
217218
}};
218219
}
220+
#[unstable(feature = "cstr_macro", issue = "101607")]
221+
#[doc(inline)]
222+
pub use __cstr_macro_impl as cstr;
219223

220224
#[unstable(feature = "cstr_macro", issue = "101607")]
221225
#[doc(hidden)]

Diff for: library/core/src/ffi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod c_str;
2323
#[doc(hidden)]
2424
pub use self::c_str::{
2525
__cstr_macro_impl_as_bytes, __cstr_macro_impl_from_bytes_with_nul,
26-
__cstr_macro_impl_to_bytes_with_nul,
26+
__cstr_macro_impl_to_bytes_with_nul, cstr,
2727
};
2828

2929
macro_rules! type_alias_no_nz {

Diff for: library/std/src/ffi/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ pub use core::ffi::{
160160
c_ulong, c_ulonglong, c_ushort,
161161
};
162162

163+
#[unstable(feature = "cstr_macro", issue = "101607")]
164+
pub use core::ffi::cstr;
165+
163166
#[stable(feature = "core_c_void", since = "1.30.0")]
164167
pub use core::ffi::c_void;
165168

Diff for: library/std/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,6 @@ pub use core::{
616616
module_path, option_env, stringify, trace_macros,
617617
};
618618

619-
#[unstable(feature = "cstr_macro", issue = "101607")]
620-
pub use core::cstr;
621-
622619
#[unstable(
623620
feature = "concat_bytes",
624621
issue = "87555",

0 commit comments

Comments
 (0)