Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ mod raw_vec;
/// Implementations of reference-counted pointers.
#[cfg(not(no_rc))]
mod rcs {
mod common;

pub mod rc;

#[cfg(all(not(no_sync), target_has_atomic = "ptr"))]
Expand Down
8 changes: 7 additions & 1 deletion library/alloc/src/rcs/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use crate::alloc::{
};
use crate::borrow::{Cow, ToOwned};
use crate::boxed::Box;
use crate::rc::is_dangling;
#[cfg(not(no_global_oom_handling))]
use crate::string::String;
#[cfg(not(no_global_oom_handling))]
Expand All @@ -46,6 +45,13 @@ use crate::vec::Vec;
/// See comment in `Arc::clone`.
const MAX_REFCOUNT: usize = (isize::MAX) as usize;

fn is_dangling<T>(ptr: *const T) -> bool
where
T: ?Sized,
{
ptr.addr() == usize::MAX
}

#[cold]
#[cfg_attr(not(panic = "immediate-abort"), inline(never))]
#[cfg_attr(panic = "immediate-abort", inline)]
Expand Down
Loading
Loading