about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2017-06-15implement Error trait for error structs added in allocator API.Felix S. Klock II-0/+28
2017-06-15Allocator integration in `RawVec`.Felix S. Klock II-117/+220
Includes methods exposing underlying allocator and the dellocation routine. Includes test illustrating a tiny `Alloc` that just bounds the total bytes allocated. Alpha-renamed `Allocator` to `Alloc` (and `HeapAllocator` to `HeapAlloc`).
2017-06-15Add impl of `Alloc` for the global rust heap.Felix S. Klock II-1/+78
Alpha-renamed `HeapAllocator` to `HeapAlloc`. `<HeapAlloc as Alloc>::alloc_zeroed` is hooked up to `heap::allocate_zeroed`. `HeapAlloc::realloc` falls back on alloc+copy+realloc on align mismatch.
2017-06-15Changed `Layout::from_size_align` to return `Option`.Felix S. Klock II-19/+43
Added `unwrap` calls in all the places where I can infer that the conditions are met to avoid panic (or when the calling method itself says it will panic in such a case).
2017-06-15Add API for `Alloc` trait.Felix S. Klock II-0/+990
Includes `alloc_zeroed` method that `RawVec` has come to depend on. Exposed private `Layout::from_size_align` ctor to be `pub`, and added explicit conditions for when it will panic (namely, when `align` is not power-of-two, or if rounding up `size` to a multiple of `align` overflows). Normalized all `Layout` construction to go through `Layout::from_size_align`. Addressed review feedback regarding `struct Layout` and zero-sized layouts. Restrict specification for `dealloc`, adding additional constraint that the given alignment has to match that used to allocate the block. (This is a maximally conservative constraint on the alignment. An open question to resolve (before stabilization) is whether we can return to a looser constraint such as the one previously specified.) Split `fn realloc_in_place` into separate `fn grow_in_place` and `fn shrink_in_place` methods, which have default impls that check against usable_size for reuse. Make `realloc` default impl try `grow_in_place` or `shrink_in_place` as appropriate before fallback on alloc+copy+dealloc. Drive-by: When reviewing calls to `padding_needed_for`, discovered what I think was an over-conservative choice for its argument alignment. Namely, in `fn extend`, we automatically realign the whole resulting layout to satisfy both old (self) and new alignments. When the old alignment exceeds the new, this means we would insert unnecessary padding. So I changed the code to pass in `next.align` instead of `new_align` to `padding_needed_for`. Replaced ref to `realloc_in_place` with `grow_in_place`/`shrink_in_place`. Revised docs replacing my idiosyncratic style of `fn foo` with just `foo` when referring to the function or method `foo`. (Alpha-renamed `Allocator` to `Alloc`.) Post-rebased, added `Debug` derive for `allocator::Excess` to satisfy `missing_debug_implementations`.
2017-06-15Utf8Lossy type with chunks iterator and impl Display and DebugStepan Koltsov-99/+22
2017-06-13Merge crate `collections` into `alloc`Murarth-13/+29825
2017-06-05Use single quotes, and doc the Rc struct itself.Ulysse Carion-5/+6
2017-06-03Explicate what "Rc" and "Arc" stand for.Ulysse Carion-2/+4
2017-05-22Update Rc and Arc documentation.Nicolas Silva-28/+64
It was decided in the RFC discussion https://github.com/rust-lang/rfcs/pull/1954 to make the function call syntax Rc::clone(&foo) the idiomatic way to clone a reference counted pointer (over the method call syntax foo.clone(). This change updates the documentation of Rc, Arc and their respoective Weak pointers to reflect it and bring more exposure to the existence of the function call syntax.
2017-05-20Correct some stability versionsOliver Middleton-1/+1
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-09Improve docs on Arc<T> and Send/Syncsteveklabnik-10/+29
This is something I always forget, so let's actually explain in the docs.
2017-05-05Rollup merge of #41064 - Gankro:ptr-redux, r=alexcrichtonCorey Farwell-64/+53
refactor NonZero, Shared, and Unique APIs Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `ptr` getter to Shared/Unique to replace Deref impl * Added Unique's `get` and `get_mut` conveniences to Shared * Deprecated `as_mut_ptr` on Shared in favour of `ptr` Note that Shared used to primarily expose only `*const` but there isn't a good justification for that, so I made it `*mut`.
2017-05-04Deprecate heap::EMPTY in favour of Unique::empty or otherwise.Alexis Beingessner-17/+17
2017-05-04fallout from NonZero/Unique/Shared changesAlexis Beingessner-48/+37
2017-05-03Document the reasoning for the Acquire/Release handshake when dropping Arcs.Bobby Holley-0/+11
2017-04-29Update stage0 bootstrap compilerAlex Crichton-1/+0
We've got a freshly minted beta compiler, let's update to use that on nightly! This has a few other changes associated with it as well * A bump to the rustc version number (to 1.19.0) * Movement of the `cargo` and `rls` submodules to their "proper" location in `src/tools/{cargo,rls}`. Now that Cargo workspaces support the `exclude` option this can work. * Updates of the `cargo` and `rls` submodules to their master branches. * Tweak to the `src/stage0.txt` format to be more amenable for Cargo version numbers. On the beta channel Cargo will bootstrap from a different version than rustc (e.g. the version numbers are different), so we need different configuration for this. * Addition of `dev` as a readable key in the `src/stage0.txt` format. If present then stage0 compilers are downloaded from `dev-static.rust-lang.org` instead of `static.rust-lang.org`. This is added to accomodate our updated release process with Travis and AppVeyor.
2017-04-26Auto merge of #41258 - clarcharr:str_box_extras, r=Kimundibors-5/+36
More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes) This is a follow-up to #41096 that adds safer methods for converting between `Box<str>` and `Box<[u8]>`. They're gated under a different feature from the `&mut str` methods because they may be too niche to include in public APIs, although having them internally helps reduce the number of transmutes the standard library uses. What's added: * `From<Box<str>> for Box<[u8]>` * `<Box<str>>::into_boxed_bytes` (just calls `Into::into`) * `alloc::str` (new module) * `from_boxed_utf8` and `from_boxed_utf8_unchecked`, defined in `alloc:str`, exported in `collections::str` * exports `from_utf8_mut` in `collections::str` (missed from previous PR)
2017-04-24More methods for str boxes.Clar Charr-5/+36
2017-04-23Auto merge of #41437 - cuviper:remove-unstable-deprecated, r=alexcrichtonbors-18/+1
Remove items that are unstable and deprecated This removes unstable items that have been deprecated for more than one cycle. - Since 1.16.0, `#![feature(enumset)]` - All of `mod collections::enum_set` - Since 1.15.0, `#![feature(borrow_state)]` - `cell::BorrowState` - `RefCell::borrow_state()` - Since 1.15.0, `#![feature(is_unique)]` - `Rc::is_unique()` (made private like `Arc::is_unique()`) - Since 1.15.0, `#![feature(rc_would_unwrap)]` - `Rc::would_wrap()` - Since 1.13.0, `#![feature(binary_heap_extras)]` - `BinaryHeap::push_pop()` - `BinaryHeap::replace()` - Since 1.12.0, `#![feature(as_unsafe_cell)]` - `Cell::as_unsafe_cell()` - `RefCell::as_unsafe_cell()` - Since 1.12.0, `#![feature(map_entry_recover_keys)]` - `btree_map::OccupiedEntry::remove_pair()` - `hash_map::OccupiedEntry::remove_pair()` - Since 1.11.0, `#![feature(float_extras)]` - `Float::nan()` - `Float::infinity()` - `Float::neg_infinity()` - `Float::neg_zero()` - `Float::zero()` - `Float::one()` - `Float::integer_decode()` - `f32::integer_decode()` - `f32::ldexp()` - `f32::frexp()` - `f32::next_after()` - `f64::integer_decode()` - `f64::ldexp()` - `f64::frexp()` - `f64::next_after()` - Since 1.11.0, `#![feature(zero_one)]` - `num::Zero` - `num::One`
2017-04-22cache attributes of items from foreign cratesAriel Ben-Yehuda-6/+36
this avoids parsing item attributes on each call to `item_attrs`, which takes off 33% (!) of translation time and 50% (!) of trans-item collection time.
2017-04-20Privatize Rc::is_uniqueJosh Stone-5/+1
[unstable, deprecated since 1.15.0]
2017-04-20Remove Rc::would_wrapJosh Stone-13/+0
[unstable, deprecated since 1.15.0]
2017-04-15Specialize Vec::from_elem<u8> to use calloc or memsetMatt Brubeck-1/+50
Fixes #38723.
2017-04-13Rollup merge of #41266 - projektir:weak_docs_rc, r=alexcrichtonCorey Farwell-33/+33
Updating docs for std::rc::Rc The same changes as PR [#41240 ](https://github.com/rust-lang/rust/pull/41240), but for [`std::rc::Weak`](https://doc.rust-lang.org/std/rc/struct.Weak.html). At least, as far as I am aware, the Weak pointer is the same for both, and they're basically the same, just one is thread-safe and the other is not. r? @alexcrichton
2017-04-12Updating docs for std::rc::Rcprojektir-33/+33
2017-04-12Updating docs for std::sync::Weak #29377projektir-33/+33
2017-03-20Fix up various linkssteveklabnik-2/+2
The unstable book, libstd, libcore, and liballoc all needed some adjustment.
2017-03-17Minor fixups to fix tidy errorsAlex Crichton-1/+4
2017-03-17Stabilize rc_raw feature, closes #37197Aaron Turon-26/+18
2017-03-17Stabilize ptr_eq feature, closes #36497Aaron Turon-10/+2
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-2/+2
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-08Box docs: no allocation is done for ZSTs.Clar Charr-0/+2
2017-02-20Revert "Fix up links"Steve Klabnik-2/+2
This reverts commit 7f1d1c6d9a7be5e427bace30e740b16b25f25c92. The original commit was created because mdBook and rustdoc had different generation algorithms for header links; now with https://github.com/rust-lang/rust/pull/39966 , the algorithms are the same. So let's undo this change. ... when I came across this problem, I said "eh, this isn't fun, but it doesn't take that long." I probably should have just actually taken the time to fix upstream, given that they were amenable. Oh well!
2017-02-15Auto merge of #39594 - clarcharr:cstr_box, r=aturonbors-0/+8
Conversions between CStr, OsStr, Path and boxes This closes a bit of the inconsistencies between `CStr`, `OsStr`, `Path`, and `str`, allowing people to create boxed versions of DSTs other than `str` and `[T]`. Full list of additions: * `Default` for `Box<str>`, `Box<CStr>`, `Box<OsStr>`, and `Box<Path>` (note: `Default` for `PathBuf` is already implemented) * `CString::into_boxed_c_str` (feature gated) * `OsString::into_boxed_os_str` (feature gated) * `Path::into_boxed_path` (feature gated) * `From<&CStr> for Box<CStr>` * `From<&OsStr> for Box<OsStr>` * `From<&Path> for Box<Path>` This also includes adding the internal methods: * `sys::*::os_str::Buf::into_box` * `sys::*::os_str::Slice::{into_box, empty_box}` * `sys_common::wtf8::Wtf8Buf::into_box` * `sys_common::wtf8::Wtf8::{into_box, empty_box}`
2017-02-14Conversions between CStr/OsStr/Path and boxes.Clar Charr-0/+8
2017-02-13Fix up linksSteve Klabnik-2/+2
mdbook and rustdoc generate links differently, so we need to change all these links.
2017-02-06Direct conversions between slices and boxes.Clar Charr-0/+40
2017-02-03Bump version, upgrade bootstrapAlex Crichton-9/+0
This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-02Rollup merge of #39299 - federicomenaquintero:master, r=GuillaumeGomezGuillaume Gomez-3/+6
In std:rc, clarify the lack of mutability inside an Rc Also, point to the example in Cell's docs for how to do it.
2017-01-31In std:rc, clarify the lack of mutability inside an RcFederico Mena Quintero-3/+6
Also, point to the example in Cell's docs for how to do it.
2017-01-30Implement Drop for BoxVadim Petrochenkov-0/+8
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-0/+1
2017-01-28Fix typo in liballoc/lib.rsDenis Andrejew-1/+1
2017-01-27Fix a few links in the docsOliver Middleton-1/+1
2017-01-10Rollup merge of #38664 - apasel422:may-dangle, r=pnkfelixSeo Sanghyeon-7/+5
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]` CC #34761 r? @pnkfelix
2017-01-09Auto merge of #38244 - estebank:escape-reason-docs, r=ollie27bors-4/+4
rustdoc: escape the deprecated and unstable reason text Fix #38220. Instead of the [current output](https://doc.rust-lang.org/std/boxed/trait.FnBox.html): <img width="967" alt="incorrect unescaped unstable reason in docs" src="https://cloud.githubusercontent.com/assets/1606434/21021898/73121d42-bd2f-11e6-8076-8a5127dbc010.png"> display: <img width="979" alt="escaped unstable reason in docs" src="https://cloud.githubusercontent.com/assets/1606434/21021876/52eb0f88-bd2f-11e6-9088-58bdc7d92328.png">
2017-01-08Auto merge of #38679 - alexcrichton:always-deny-warnings, r=nrcbors-1/+1
Remove not(stage0) from deny(warnings) Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2016-12-29Remove not(stage0) from deny(warnings)Alex Crichton-1/+1
Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2016-12-29Rollup merge of #38587 - GuillaumeGomez:arc_docs, r=frewsxcvAlex Crichton-15/+17
Add missing urls in Arc docs r? @frewsxcv