summary refs log tree commit diff
path: root/src/liballoc/rc.rs
AgeCommit message (Collapse)AuthorLines
2015-12-31Auto merge of #30593 - steveklabnik:small_rc_refactoring, r=Gankrobors-4/+6
This hairy conditional doesn't need to be so. It _does_ need to be a thin pointer, otherwise, it will fail to compile, so let's pull that out into a temporary for future readers of the source. /cc @nrc @SimonSapin @Gankro @durka , who brought this up on IRC
2015-12-30Auto merge of #30467 - shahn:master, r=brsonbors-1/+38
This adds a constructor for a Weak that can never be upgraded. These are mostly useless, but for example are required when deserializing.
2015-12-30Small refactoring to make this code more clearSteve Klabnik-4/+6
This hairy conditional doesn't need to be so. It _does_ need to be a thin pointer, otherwise, it will fail to compile, so let's pull that out into a temporary for future readers of the source. Also, after a discussion with @pnkfelix and @gankro, we don't need these null checks anymore, as zero-on-drop has been gone for a while now.
2015-12-21Register new snapshotsAlex Crichton-6/+0
Lots of cruft to remove!
2015-12-19Address review commentsSebastian Hahn-2/+1
2015-12-19Rename Weak::new_downgraded to Weak::newSebastian Hahn-4/+4
2015-12-19use core::mem::unintialized instead of uninit intrinsicSebastian Hahn-3/+3
2015-12-19Fix doctest failureSebastian Hahn-1/+3
2015-12-18Implement Weak::new_downgraded() (#30425)Sebastian Hahn-1/+37
This adds a constructor for a Weak that can never be upgraded. These are mostly useless, but for example are required when deserializing.
2015-12-10std: Remove deprecated functionality from 1.5Alex Crichton-8/+0
This is a standard "clean out libstd" commit which removes all 1.5-and-before deprecated functionality as it's now all been deprecated for at least one entire cycle.
2015-11-25Auto merge of #30017 - nrc:fmt, r=brsonbors-10/+10
2015-11-24rustfmt: liballoc, liballoc_*, libarenaNick Cameron-10/+10
2015-11-20Rename #[deprecated] to #[rustc_deprecated]Vadim Petrochenkov-1/+1
2015-11-18Add missing annotations and some testsVadim Petrochenkov-0/+7
2015-11-16Auto merge of #29580 - alexbool:smart-pointer-conversion, r=alexcrichtonbors-0/+16
Sometimes when writing generic code you want to abstract over owning/pointer type so that calling code isn't restricted by one concrete owning/pointer type. This commit makes possible such code: ```rust fn i_will_work_with_arc<T: Into<Arc<MyTy>>>(t: T) { let the_arc = t.into(); // Do something } i_will_work_with_arc(MyTy::new()); i_will_work_with_arc(Box::new(MyTy::new())); let arc_that_i_already_have = Arc::new(MyTy::new()); i_will_work_with_arc(arc_that_i_already_have); ``` Please note that this patch doesn't work with DSTs. Also to mention, I made those impls stable, and I don't know whether they should be actually stable from the beginning. Please tell me if this should be feature-gated.
2015-11-16Fix feature nameAlexander Bulaev-1/+1
2015-11-12Remove impls for cases considered `niche`Alexander Bulaev-14/+0
2015-11-11Fix import warnings for stage0Steve Klabnik-2/+6
2015-11-06Remove stability annotations from trait impl itemsVadim Petrochenkov-1/+0
Remove `stable` stability annotations from inherent impls
2015-11-04liballoc: implement From for Box, Rc, ArcAlexander Bulaev-0/+30
Sometimes when writing generic code you want to abstract over owning/pointer type so that calling code isn't restricted by one concrete owning/pointer type. This commit makes possible such code: ``` fn i_will_work_with_arc<T: Into<Arc<MyTy>>>(t: T) { let the_arc = t.into(); // Do something } i_will_work_with_arc(MyTy::new()); i_will_work_with_arc(Box::new(MyTy::new())); let arc_that_i_already_have = Arc::new(MyTy::new()); i_will_work_with_arc(arc_that_i_already_have); ``` Please note that this patch doesn't work with DSTs.
2015-11-02remove #![feature(rc_unique)] from Rc docsAlex Burka-3/+0
`Rc::try_unwrap` and `Rc::make_mut` are stable since 1.4.0, but the example code still has `#![feature(rc_unique)]`. Ideally the stable and beta docs would be updated, but I don't think that's possible...
2015-10-30don't use drop_in_place as an intrinsicAlexis Beingessner-2/+2
2015-10-16Add `Shared` pointer and have `{Arc, Rc}` use itAndrew Paseltiner-5/+6
This change has two consequences: 1. It makes `Arc<T>` and `Rc<T>` covariant in `T`. 2. It causes the compiler to reject code that was unsound with respect to dropck. See compile-fail/issue-29106.rs for an example of code that no longer compiles. Because of this, this is a [breaking-change]. Fixes #29037. Fixes #29106.
2015-10-11Run rustfmt on liballoc.Ahmed Charles-7/+5
2015-10-10Auto merge of #28861 - pnkfelix:fsk-nonparam-dropck-issue28498, r=arielb1bors-0/+1
implement RFC 1238: nonparametric dropck. cc #28498 cc @nikomatsakis
2015-10-09Added the param-blindness attribute to `Rc` and `Arc`.Felix S. Klock II-0/+1
This was proven necessary after I added `Rc` and `Arc` to the rpass test `dropck_legal_cycles.rs`; see PR #28929.
2015-10-02std: Add AsRef/AsMut impls to Box/Rc/ArcAlex Crichton-0/+5
These common traits were left off originally by accident from these smart pointers, and a past attempt (#26008) to add them was later reverted (#26160) due to unexpected breakge (#26096) occurring. The specific breakage in worry is the meaning of this return value changed: let a: Box<Option<T>> = ...; a.as_ref() Currently this returns `Option<&T>` but after this change it will return `&Option<T>` because the `AsRef::as_ref` method shares the same name as `Option::as_ref`. A [crater report][crater] of this change, however, has shown that the fallout of this change is quite minimal. These trait implementations are "the right impls to add" to these smart pointers and would enable various generalizations such as those in #27197. [crater]: https://gist.github.com/anonymous/0ba4c3512b07641c0f99 This commit is a breaking change for the above reasons mentioned, and the mitigation strategies look like any of: Option::as_ref(&a) a.as_ref().as_ref() (*a).as_ref()
2015-09-24Better function callsNick Cameron-2/+6
2015-09-24rustfmt liballocNick Cameron-23/+48
2015-09-11std: Stabilize/deprecate features for 1.4Alex Crichton-26/+18
The FCP is coming to a close and 1.4 is coming out soon, so this brings in the libs team decision for all library features this cycle. Stabilized APIs: * `<Box<str>>::into_string` * `Arc::downgrade` * `Arc::get_mut` * `Arc::make_mut` * `Arc::try_unwrap` * `Box::from_raw` * `Box::into_raw` * `CStr::to_str` * `CStr::to_string_lossy` * `CString::from_raw` * `CString::into_raw` * `IntoRawFd::into_raw_fd` * `IntoRawFd` * `IntoRawHandle::into_raw_handle` * `IntoRawHandle` * `IntoRawSocket::into_raw_socket` * `IntoRawSocket` * `Rc::downgrade` * `Rc::get_mut` * `Rc::make_mut` * `Rc::try_unwrap` * `Result::expect` * `String::into_boxed_slice` * `TcpSocket::read_timeout` * `TcpSocket::set_read_timeout` * `TcpSocket::set_write_timeout` * `TcpSocket::write_timeout` * `UdpSocket::read_timeout` * `UdpSocket::set_read_timeout` * `UdpSocket::set_write_timeout` * `UdpSocket::write_timeout` * `Vec::append` * `Vec::split_off` * `VecDeque::append` * `VecDeque::retain` * `VecDeque::split_off` * `rc::Weak::upgrade` * `rc::Weak` * `slice::Iter::as_slice` * `slice::IterMut::into_slice` * `str::CharIndices::as_str` * `str::Chars::as_str` * `str::split_at_mut` * `str::split_at` * `sync::Weak::upgrade` * `sync::Weak` * `thread::park_timeout` * `thread::sleep` Deprecated APIs * `BTreeMap::with_b` * `BTreeSet::with_b` * `Option::as_mut_slice` * `Option::as_slice` * `Result::as_mut_slice` * `Result::as_slice` * `f32::from_str_radix` * `f64::from_str_radix` Closes #27277 Closes #27718 Closes #27736 Closes #27764 Closes #27765 Closes #27766 Closes #27767 Closes #27768 Closes #27769 Closes #27771 Closes #27773 Closes #27775 Closes #27776 Closes #27785 Closes #27792 Closes #27795 Closes #27797
2015-09-03doc: reduce indentation of examples to 4 spacesTshepang Lekhonkhobe-7/+7
Also, add trailing commas
2015-08-22Move the Borrow and BorrowMut traits to libcore.Simon Sapin-0/+5
2015-08-19don't do deprecations yetAlexis Beingessner-3/+0
2015-08-19Rework Rc for FCP of #27718Alexis Beingessner-82/+117
* Add `Rc::would_unwrap(&Self) -> bool` to introspect whether try_unwrap would succeed, because it's destructive (unlike get_mut). * Move `rc.downgrade()` to `Rc::downgrade(&Self)` per conventions. * Deprecate `Rc::weak_count` and `Rc::strong_count` for questionable utility. * Deprecate `Rc::is_unique` for questionable semantics (there are two kinds of uniqueness with Weak pointers in play). * Rename `rc.make_unique()` to `Rc::make_mut(&mut Self)` per conventions, to avoid uniqueness terminology, and to clarify the relation to `Rc::get_mut`.
2015-08-15alloc: Add issues for all unstable featuresAlex Crichton-10/+14
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-106/+28
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-03syntax: Implement #![no_core]Alex Crichton-1/+2
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-30Auto merge of #27174 - Gankro:rc-sat, r=alexcrichtonbors-3/+16
See https://internals.rust-lang.org/t/rc-is-unsafe-mostly-on-32-bit-targets-due-to-overflow/2120 for detailed discussion of this problem.
2015-07-29make Rc mem::forget safeAlexis Beingessner-3/+16
2015-07-27Show appropriate feature flags in docsSteve Klabnik-12/+24
2015-07-01Implement CoerceUnsized for rc::WeakRemi Rampin-0/+2
Fixes #26704
2015-06-24Make `align_of` behave like `min_align_of`.Huon Wilson-4/+4
This removes a footgun, since it is a reasonable assumption to make that pointers to `T` will be aligned to `align_of::<T>()`. This also matches the behaviour of C/C++. `min_align_of` is now deprecated. Closes #21611.
2015-06-17More test fixes and fallout of stability changesAlex Crichton-22/+19
2015-06-17std: Move free-functions to associated functionsAlex Crichton-28/+105
This commit moves the free functions in the `rc`, `arc`, and `boxed` modules to associated functions on their respective types, following the recent trend towards this pattern. The previous free functions are all left in-place with `#[deprecated]` pointers towards the new locations. This commit also deprecates `arc::get_mut` and `Arc::make_unique` with no replacement as they are racy in the face of weak pointers.
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-18/+15
2015-06-17alloc: Split apart the global `alloc` featureAlex Crichton-10/+10
2015-06-09Revert "Added AsRef implementations for Arc and Rc"Alex Crichton-10/+0
This reverts commit 7f3ae0aa26d24100379ae0f3eef29916a32f4e79.
2015-06-04Added AsRef implementations for Arc and RcMarkus Westerlind-0/+10
2015-05-27Remove #[cfg(stage0)] items.Eduard Burtescu-415/+4