Skip to content

Commit 5b2291f

Browse files
committed
Make alloc::ffi compile with no_rc and no_sync
1 parent 3fc3732 commit 5b2291f

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

@@ -894,7 +895,7 @@ impl<'a> From<&'a CString> for Cow<'a, CStr> {
894895
}
895896
}
896897

897-
#[cfg(target_has_atomic = "ptr")]
898+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
898899
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
899900
impl From<CString> for Arc<CStr> {
900901
/// Converts a [`CString`] into an <code>[Arc]<[CStr]></code> by moving the [`CString`]
@@ -906,7 +907,7 @@ impl From<CString> for Arc<CStr> {
906907
}
907908
}
908909

909-
#[cfg(target_has_atomic = "ptr")]
910+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
910911
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
911912
impl From<&CStr> for Arc<CStr> {
912913
/// Converts a `&CStr` into a `Arc<CStr>`,
@@ -918,7 +919,7 @@ impl From<&CStr> for Arc<CStr> {
918919
}
919920
}
920921

921-
#[cfg(target_has_atomic = "ptr")]
922+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
922923
#[stable(feature = "shared_from_mut_slice", since = "1.84.0")]
923924
impl From<&mut CStr> for Arc<CStr> {
924925
/// Converts a `&mut CStr` into a `Arc<CStr>`,
@@ -929,6 +930,7 @@ impl From<&mut CStr> for Arc<CStr> {
929930
}
930931
}
931932

933+
#[cfg(not(no_rc))]
932934
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
933935
impl From<CString> for Rc<CStr> {
934936
/// Converts a [`CString`] into an <code>[Rc]<[CStr]></code> by moving the [`CString`]
@@ -940,6 +942,7 @@ impl From<CString> for Rc<CStr> {
940942
}
941943
}
942944

945+
#[cfg(not(no_rc))]
943946
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
944947
impl From<&CStr> for Rc<CStr> {
945948
/// Converts a `&CStr` into a `Rc<CStr>`,
@@ -951,6 +954,7 @@ impl From<&CStr> for Rc<CStr> {
951954
}
952955
}
953956

957+
#[cfg(not(no_rc))]
954958
#[stable(feature = "shared_from_mut_slice", since = "1.84.0")]
955959
impl From<&mut CStr> for Rc<CStr> {
956960
/// Converts a `&mut CStr` into a `Rc<CStr>`,
@@ -961,6 +965,7 @@ impl From<&mut CStr> for Rc<CStr> {
961965
}
962966
}
963967

968+
#[cfg(not(no_rc))]
964969
#[cfg(not(no_global_oom_handling))]
965970
#[stable(feature = "more_rc_default_impls", since = "1.80.0")]
966971
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)