Skip to content

Commit

Permalink
Fix targets not supporting target_has_atomic = "ptr"
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Apr 14, 2022
1 parent 7f3cc2f commit afa2e6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::boxed::Box;
use crate::rc::Rc;
use crate::slice::hack::into_vec;
use crate::string::String;
use crate::sync::Arc;
use crate::vec::Vec;
use core::borrow::Borrow;
use core::ffi::{c_char, CStr};
Expand All @@ -19,6 +18,9 @@ use core::slice;
use core::slice::memchr;
use core::str::{self, Utf8Error};

#[cfg(target_has_atomic = "ptr")]
use crate::sync::Arc;

/// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
/// middle.
///
Expand Down Expand Up @@ -859,6 +861,7 @@ impl<'a> From<&'a CString> for Cow<'a, CStr> {
}
}

#[cfg(target_has_atomic = "ptr")]
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<CString> for Arc<CStr> {
/// Converts a [`CString`] into an <code>[Arc]<[CStr]></code> by moving the [`CString`]
Expand All @@ -870,6 +873,7 @@ impl From<CString> for Arc<CStr> {
}
}

#[cfg(target_has_atomic = "ptr")]
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<&CStr> for Arc<CStr> {
/// Converts a `&CStr` into a `Arc<CStr>`,
Expand Down

0 comments on commit afa2e6f

Please sign in to comment.