Skip to content

Commit 9bead2b

Browse files
committed
Make alloc::ffi compile with no_rc and no_sync
1 parent 53d60bb commit 9bead2b

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

library/alloc/src/ffi/c_str.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ use core::{fmt, mem, ops, ptr, slice};
99

1010
use crate::borrow::{Cow, ToOwned};
1111
use crate::boxed::Box;
12+
#[cfg(not(no_rc))]
1213
use crate::rc::Rc;
1314
use crate::string::String;
14-
#[cfg(target_has_atomic = "ptr")]
15+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
1516
use crate::sync::Arc;
1617
use crate::vec::Vec;
1718

@@ -898,7 +899,7 @@ impl<'a> From<&'a CString> for Cow<'a, CStr> {
898899
}
899900
}
900901

901-
#[cfg(target_has_atomic = "ptr")]
902+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
902903
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
903904
impl From<CString> for Arc<CStr> {
904905
/// Converts a [`CString`] into an <code>[Arc]<[CStr]></code> by moving the [`CString`]
@@ -910,7 +911,7 @@ impl From<CString> for Arc<CStr> {
910911
}
911912
}
912913

913-
#[cfg(target_has_atomic = "ptr")]
914+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
914915
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
915916
impl From<&CStr> for Arc<CStr> {
916917
/// Converts a `&CStr` into a `Arc<CStr>`,
@@ -922,7 +923,7 @@ impl From<&CStr> for Arc<CStr> {
922923
}
923924
}
924925

925-
#[cfg(target_has_atomic = "ptr")]
926+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
926927
#[stable(feature = "shared_from_mut_slice", since = "1.84.0")]
927928
impl From<&mut CStr> for Arc<CStr> {
928929
/// Converts a `&mut CStr` into a `Arc<CStr>`,
@@ -933,6 +934,7 @@ impl From<&mut CStr> for Arc<CStr> {
933934
}
934935
}
935936

937+
#[cfg(not(no_rc))]
936938
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
937939
impl From<CString> for Rc<CStr> {
938940
/// Converts a [`CString`] into an <code>[Rc]<[CStr]></code> by moving the [`CString`]
@@ -944,6 +946,7 @@ impl From<CString> for Rc<CStr> {
944946
}
945947
}
946948

949+
#[cfg(not(no_rc))]
947950
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
948951
impl From<&CStr> for Rc<CStr> {
949952
/// Converts a `&CStr` into a `Rc<CStr>`,
@@ -955,6 +958,7 @@ impl From<&CStr> for Rc<CStr> {
955958
}
956959
}
957960

961+
#[cfg(not(no_rc))]
958962
#[stable(feature = "shared_from_mut_slice", since = "1.84.0")]
959963
impl From<&mut CStr> for Rc<CStr> {
960964
/// Converts a `&mut CStr` into a `Rc<CStr>`,
@@ -965,6 +969,7 @@ impl From<&mut CStr> for Rc<CStr> {
965969
}
966970
}
967971

972+
#[cfg(not(no_rc))]
968973
#[cfg(not(no_global_oom_handling))]
969974
#[stable(feature = "more_rc_default_impls", since = "1.80.0")]
970975
impl Default for Rc<CStr> {

library/alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub mod boxed;
220220
#[unstable(feature = "bstr", issue = "134915")]
221221
pub mod bstr;
222222
pub mod collections;
223-
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
223+
#[cfg(not(no_global_oom_handling))]
224224
pub mod ffi;
225225
pub mod fmt;
226226
pub mod intrinsics;

0 commit comments

Comments
 (0)