Skip to content

Commit a5d0757

Browse files
committed
Add note about possible allocation-sharing to Arc/Rc<str/[T]/CStr>::default.
1 parent 22bf367 commit a5d0757

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

alloc/src/ffi/c_str.rs

+4
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ impl From<&CStr> for Rc<CStr> {
914914
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
915915
impl Default for Arc<CStr> {
916916
/// Creates an empty CStr inside an Arc
917+
///
918+
/// This may or may not share an allocation with other Arcs.
917919
#[inline]
918920
fn default() -> Self {
919921
let c_str: &CStr = Default::default();
@@ -925,6 +927,8 @@ impl Default for Arc<CStr> {
925927
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
926928
impl Default for Rc<CStr> {
927929
/// Creates an empty CStr inside an Rc
930+
///
931+
/// This may or may not share an allocation with other Rcs on the same thread.
928932
#[inline]
929933
fn default() -> Self {
930934
let c_str: &CStr = Default::default();

alloc/src/rc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,8 @@ impl<T: Default> Default for Rc<T> {
22282228
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
22292229
impl Default for Rc<str> {
22302230
/// Creates an empty str inside an Rc
2231+
///
2232+
/// This may or may not share an allocation with other Rcs on the same thread.
22312233
#[inline]
22322234
fn default() -> Self {
22332235
Rc::from("")
@@ -2238,6 +2240,8 @@ impl Default for Rc<str> {
22382240
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
22392241
impl<T> Default for Rc<[T]> {
22402242
/// Creates an empty `[T]` inside an Rc
2243+
///
2244+
/// This may or may not share an allocation with other Rcs on the same thread.
22412245
#[inline]
22422246
fn default() -> Self {
22432247
let arr: [T; 0] = [];

alloc/src/sync.rs

+4
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,8 @@ impl<T: Default> Default for Arc<T> {
33043304
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
33053305
impl Default for Arc<str> {
33063306
/// Creates an empty str inside an Arc
3307+
///
3308+
/// This may or may not share an allocation with other Arcs.
33073309
#[inline]
33083310
fn default() -> Self {
33093311
Arc::from("")
@@ -3314,6 +3316,8 @@ impl Default for Arc<str> {
33143316
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
33153317
impl<T> Default for Arc<[T]> {
33163318
/// Creates an empty `[T]` inside an Arc
3319+
///
3320+
/// This may or may not share an allocation with other Arcs.
33173321
#[inline]
33183322
fn default() -> Self {
33193323
let arr: [T; 0] = [];

0 commit comments

Comments
 (0)