about summary refs log tree commit diff
path: root/src/liballoc/boxed.rs
AgeCommit message (Collapse)AuthorLines
2018-05-22Make `Unpin` safe to implementTaylor Cramer-1/+1
2018-05-07Rename Pin to PinMutRalf Jung-3/+3
As discussed at [1] §3 and [2] and [3], a formal look at pinning requires considering a distinguished "shared pinned" mode/typestate. Given that, it seems desirable to at least eventually actually expose that typestate as a reference type. This renames Pin to PinMut, freeing the name Pin in case we want to use it for a shared pinned reference later on. [1] https://www.ralfj.de/blog/2018/04/10/safe-intrusive-collections-with-pinning.html [2] https://github.com/rust-lang/rfcs/pull/2349#issuecomment-379250361 [3] https://github.com/rust-lang/rust/issues/49150#issuecomment-380488275
2018-04-28Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnikkennytm-0/+1
std: Mark `ptr::Unique` with `#[doc(hidden)]` `Unique` is now perma-unstable, so let's hide its docs.
2018-04-17Rollup merge of #49555 - nox:inline-into-boxed, r=alexcrichtonkennytm-0/+2
Inline most of the code paths for conversions with boxed slices This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case. Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with `#[inline]`. For the record, that function was: ```rust pub fn foo() -> Box<[u8]> { vec![0].into_boxed_slice() } ``` To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-04-14Cleanup liballoc use statementsMike Hommey-2/+2
Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2018-04-11alloc: Mark `Box::into_unique` with `#[doc(hidden)]`Daiki Mizukami-0/+1
2018-04-05Rollup merge of #49621 - Nemo157:impl-unpin-for-pin, r=withoutboatsAlex Crichton-0/+3
2018-04-05impl Unpin for PinBoxWim Looman-0/+3
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-150/+1
Closes #22181, #27779
2018-04-02Use Alloc and Layout from core::heap.Mike Hommey-1/+2
94d1970bba87f2d2893f6e934e4c3f02ed50604d moved the alloc::allocator module to core::heap, moving e.g. Alloc and Layout out of the alloc crate. While alloc::heap reexports them, it's better to use them from where they really come from.
2018-04-01Inline most of the code paths for conversions with boxed slicesAnthony Ramine-0/+2
This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case. Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with `#[inline]`. For the record, that function was: ```rust pub fn foo() -> Box<[u8]> { vec![0].into_boxed_slice() } ``` To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-03-29Remove unnecessary use core::hash in liballoc/boxed.rsMike Hommey-2/+2
It' only used for hash::Hasher, but Hasher is also imported.
2018-03-25Rollup merge of #49194 - Zoxc:unsafe-generator, r=cramertjkennytm-1/+1
Make resuming generators unsafe instead of the creation of immovable generators cc @withoutboats Fixes #47787
2018-03-21Make resuming generators unsafe instead of the creation of immovable ↵John Kåre Alsaker-1/+1
generators. Fixes #47787
2018-03-19Auto merge of #49058 - withoutboats:pin, r=cramertjbors-2/+99
Pin, Unpin, PinBox Implementing rust-lang/rfcs#2349 (do not merge until RFC is merged) @bors r? @cramertj
2018-03-18Update tracking issue.boats-12/+12
2018-03-15Pin and PinBox are fundamental.boats-0/+1
2018-03-15CoerceUnsized for PinBoxboats-0/+3
2018-03-15Add liballoc APIs.boats-2/+95
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-1/+1
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-1/+1
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-02-10stabilize Box::leak: remove #![feature(box_leak)] in docsMazdak Farrokhzad-4/+0
2018-02-10stabilize (version: 1.26.0) Box::leak, cc #46179Mazdak Farrokhzad-2/+1
2018-01-24Auto merge of #47299 - cramertj:unsafe-placer, r=alexcrichtonbors-1/+1
Make core::ops::Place an unsafe trait Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
2018-01-20Assign its own tracking issue to Box::into_raw_non_nullSimon Sapin-1/+3
https://github.com/rust-lang/rust/issues/47336
2018-01-20Revert Box::into_raw_non_null to unstableSimon Sapin-1/+1
2018-01-20Rename Box::into_non_null_raw to Box::into_raw_non_nullSimon Sapin-6/+6
2018-01-20Remove `Box::from_non_null_raw`Simon Sapin-35/+3
Per https://github.com/rust-lang/rust/pull/46952#issuecomment-353956225
2018-01-20Rename Box::*_nonnull_raw to *_non_null_rawSimon Sapin-11/+11
2018-01-20Stabilize std::ptr::NonNullSimon Sapin-8/+2
2018-01-20Replace Box::{from,into}_unique with {from,into}_nonnull_rawSimon Sapin-20/+27
Thew `_raw` prefix is included because the fact that `Box`’s ownership semantics are "dissolved" or recreated seem more important than the exact parameter type or return type.
2018-01-09Make core::ops::Place an unsafe traitTaylor Cramer-1/+1
2017-11-29Update bootstrap compilerAlex Crichton-12/+4
Also remove a number of `stage0` annotations and such
2017-11-23Auto merge of #45881 - Centril:box-leak, r=alexcrichtonbors-0/+53
Add Box::leak<'a>(Box<T>) -> &'a mut T where T: 'a Adds: ```rust impl<T: ?Sized> Box<T> { pub fn leak<'a>(b: Box<T>) -> &'a mut T where T: 'a { unsafe { &mut *Box::into_raw(b) } } } ``` which is useful for when you just want to put some stuff on the heap and then have a reference to it for the remainder of the program. r? @sfackler cc @durka
2017-11-22Box::leak: update unstable issue number (46179).Mazdak-1/+1
2017-11-19rustc: don't special-case Box<T> as having a pointer layout.Eduard-Mihai Burtescu-4/+14
2017-11-09Box::leak - made an oops, fixed now =)Mazdak-1/+4
2017-11-09Box::leak - updated documentationMazdak-2/+2
2017-11-09Box::leak - relaxed constraints wrt. lifetimesMazdak-2/+2
2017-11-09Box::leak - fixed bug in documentationMazdak-8/+16
2017-11-08Box::leak - improve documentationMazdak-5/+6
2017-11-08added associated function Box::leakMazdak-0/+41
2017-10-10Auto merge of #44877 - nvzqz:box-conversions, r=alexcrichtonbors-4/+40
Improve raw Box conversions This PR has two goals: - Reduce use of `mem::transmute` in `Box` conversions I understand that `mem::transmute`-ing non `#[repr(C)]` types is implementation-defined behavior. This may not matter within the reference implementation of Rust, but I believe it's important to remain consistent. For example, I noticed that `str::from_utf8_unchecked` went from using `mem::transmute` to using pointer casts. - Make `Box` pointer conversions more straightforward regarding `Unique`
2017-10-06Add unique feature in Box::from_unique docsNikolai Vazquez-3/+7
2017-10-06Add missing word in Box::from_unique docsNikolai Vazquez-2/+2
2017-10-06Create Box::from_unique functionNikolai Vazquez-3/+35
Provides a reasonable interface for Box::from_raw implementation. Does not get around the requirement of mem::transmute for converting back and forth between Unique and Box.
2017-10-06Revert to using mem::transmute in Box::from_rawNikolai Vazquez-1/+1
Same reasons as commit 904133e1e28b690e2bbd101b719509aa897539a0.
2017-10-06Revert to using mem::transmute in Box::into_uniqueNikolai Vazquez-3/+1
Seems to cause this error: "Cannot handle boxed::Box<[u8]> represented as TyLayout".
2017-09-27Remove mem::transmute used in Box<str> conversionsNikolai Vazquez-3/+1
2017-09-26Remove uses of mem::transmute in Box methodsNikolai Vazquez-3/+5
Makes use of conversions via Unique.