From 76780fa10e9e449bdd68d773041f85a64303bb02 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 6 Jan 2025 15:02:25 +0200 Subject: [PATCH] Support `no_rc`, `no_sync`, and `no_global_oom_handling` For now, apply `no_global_oom_handling` to all of library/alloc/src/bstr.rs . We can make it more fine-grained later. --- library/alloc/src/bstr.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/alloc/src/bstr.rs b/library/alloc/src/bstr.rs index a447ab38d17..f16a36b0f9b 100644 --- a/library/alloc/src/bstr.rs +++ b/library/alloc/src/bstr.rs @@ -1,5 +1,8 @@ //! The `ByteStr` and `ByteString` types and trait implementations. +// This could be more fine-grained. +#![cfg(not(no_global_oom_handling))] + use core::borrow::{Borrow, BorrowMut}; #[unstable(feature = "bstr", issue = "134915")] pub use core::bstr::ByteStr; @@ -17,8 +20,10 @@ use core::{fmt, hash}; use crate::borrow::{Cow, ToOwned}; #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100 use crate::boxed::Box; +#[cfg(not(no_rc))] use crate::rc::Rc; use crate::string::String; +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] use crate::sync::Arc; use crate::vec::Vec; @@ -649,6 +654,7 @@ impl From> for Box<[u8]> { } #[unstable(feature = "bstr", issue = "134915")] +#[cfg(not(no_rc))] impl From> for Rc { #[inline] fn from(s: Rc<[u8]>) -> Rc { @@ -658,6 +664,7 @@ impl From> for Rc { } #[unstable(feature = "bstr", issue = "134915")] +#[cfg(not(no_rc))] impl From> for Rc<[u8]> { #[inline] fn from(s: Rc) -> Rc<[u8]> { @@ -667,6 +674,7 @@ impl From> for Rc<[u8]> { } #[unstable(feature = "bstr", issue = "134915")] +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] impl From> for Arc { #[inline] fn from(s: Arc<[u8]>) -> Arc { @@ -676,6 +684,7 @@ impl From> for Arc { } #[unstable(feature = "bstr", issue = "134915")] +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] impl From> for Arc<[u8]> { #[inline] fn from(s: Arc) -> Arc<[u8]> {