Skip to content

Commit 9ccc52b

Browse files
committed
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.
1 parent f035281 commit 9ccc52b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/alloc/src/bstr.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! The `ByteStr` and `ByteString` types and trait implementations.
22
3+
// This could be more fine-grained.
4+
#![cfg(not(no_global_oom_handling))]
5+
36
use core::borrow::{Borrow, BorrowMut};
47
#[unstable(feature = "bstr", issue = "134915")]
58
pub use core::bstr::ByteStr;
@@ -17,8 +20,10 @@ use core::{fmt, hash};
1720
use crate::borrow::{Cow, ToOwned};
1821
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
1922
use crate::boxed::Box;
23+
#[cfg(not(no_rc))]
2024
use crate::rc::Rc;
2125
use crate::string::String;
26+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
2227
use crate::sync::Arc;
2328
use crate::vec::Vec;
2429

@@ -664,6 +669,7 @@ impl From<Box<ByteStr>> for Box<[u8]> {
664669
}
665670

666671
#[unstable(feature = "bstr", issue = "134915")]
672+
#[cfg(not(no_rc))]
667673
impl From<Rc<[u8]>> for Rc<ByteStr> {
668674
#[inline]
669675
fn from(s: Rc<[u8]>) -> Rc<ByteStr> {
@@ -673,6 +679,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> {
673679
}
674680

675681
#[unstable(feature = "bstr", issue = "134915")]
682+
#[cfg(not(no_rc))]
676683
impl From<Rc<ByteStr>> for Rc<[u8]> {
677684
#[inline]
678685
fn from(s: Rc<ByteStr>) -> Rc<[u8]> {
@@ -682,6 +689,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> {
682689
}
683690

684691
#[unstable(feature = "bstr", issue = "134915")]
692+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
685693
impl From<Arc<[u8]>> for Arc<ByteStr> {
686694
#[inline]
687695
fn from(s: Arc<[u8]>) -> Arc<ByteStr> {
@@ -691,6 +699,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> {
691699
}
692700

693701
#[unstable(feature = "bstr", issue = "134915")]
702+
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
694703
impl From<Arc<ByteStr>> for Arc<[u8]> {
695704
#[inline]
696705
fn from(s: Arc<ByteStr>) -> Arc<[u8]> {

0 commit comments

Comments
 (0)