diff options
| author | Michał Krasnoborski <mkrdln@gmail.com> | 2017-02-03 17:48:07 +0100 |
|---|---|---|
| committer | Michał Krasnoborski <mkrdln@gmail.com> | 2017-02-03 17:48:07 +0100 |
| commit | 0267529681e2fac6ef4560afe7d8d439d04e6303 (patch) | |
| tree | 00bac1c7b714a59f1e4f230a64cb5427de2b62eb /src/liballoc | |
| parent | ecda7f314fa79bbfbf2125c99fd66288ca83c875 (diff) | |
| parent | aed6410a7b0f15dc68536e0735787436526ba395 (diff) | |
| download | rust-0267529681e2fac6ef4560afe7d8d439d04e6303.tar.gz rust-0267529681e2fac6ef4560afe7d8d439d04e6303.zip | |
Merge remote-tracking branch 'upstream/master' into format-with-capacity
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 9 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 9 |
4 files changed, 17 insertions, 5 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 459dc94f336..38d843263ff 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -59,7 +59,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// as long as `T` implements [`Send`] and [`Sync`][sync]. The disadvantage is /// that atomic operations are more expensive than ordinary memory accesses. /// If you are not sharing reference-counted values between threads, consider -/// using [`rc::Rc`] for lower overhead. [`Rc`] is a safe default, because +/// using [`rc::Rc`][`Rc`] for lower overhead. [`Rc`] is a safe default, because /// the compiler will catch any attempt to send an [`Rc`] between threads. /// However, a library might choose `Arc` in order to give library consumers /// more flexibility. diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 5409ade2923..b6f490e09cd 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -103,6 +103,7 @@ pub struct ExchangeHeapSingleton { /// /// See the [module-level documentation](../../std/boxed/index.html) for more. #[lang = "owned_box"] +#[fundamental] #[stable(feature = "rust1", since = "1.0.0")] pub struct Box<T: ?Sized>(Unique<T>); @@ -292,6 +293,14 @@ impl<T: ?Sized> Box<T> { } } +#[cfg(not(stage0))] +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl<#[may_dangle] T: ?Sized> Drop for Box<T> { + fn drop(&mut self) { + // FIXME: Do nothing, drop is currently performed by compiler. + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<T: Default> Default for Box<T> { /// Creates a `Box<T>`, with the `Default` value for T. diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index c67106cf57a..0c01eabd593 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -47,7 +47,7 @@ //! that the contained type `T` is shareable. Additionally, `Arc<T>` is itself //! sendable while `Rc<T>` is not. //! -//! This types allows for shared access to the contained data, and is often +//! This type allows for shared access to the contained data, and is often //! paired with synchronization primitives such as mutexes to allow mutation of //! shared resources. //! diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 010e378ef2f..6108a06634b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -17,9 +17,11 @@ //! pointer to the same value in the heap. When the last [`Rc`] pointer to a //! given value is destroyed, the pointed-to value is also destroyed. //! -//! Shared references in Rust disallow mutation by default, and `Rc` is no -//! exception. If you need to mutate through an [`Rc`], use [`Cell`] or -//! [`RefCell`]. +//! Shared references in Rust disallow mutation by default, and [`Rc`] +//! is no exception: you cannot obtain a mutable reference to +//! something inside an [`Rc`]. If you need mutability, put a [`Cell`] +//! or [`RefCell`] inside the [`Rc`]; see [an example of mutability +//! inside an Rc][mutability]. //! //! [`Rc`] uses non-atomic reference counting. This means that overhead is very //! low, but an [`Rc`] cannot be sent between threads, and consequently [`Rc`] @@ -214,6 +216,7 @@ //! [upgrade]: struct.Weak.html#method.upgrade //! [`None`]: ../../std/option/enum.Option.html#variant.None //! [assoc]: ../../book/method-syntax.html#associated-functions +//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable #![stable(feature = "rust1", since = "1.0.0")] |
