about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2014-11-26Remove special casing for some meta attributesSteven Fackler-1/+0
Descriptions and licenses are handled by Cargo now, so there's no reason to keep these attributes around.
2014-11-25Document liballoc::rcSteve Klabnik-57/+296
This commit introduces a bunch of documentation, fixes some consistency issues, and just basically brings Rc<T> and Weak<T> up to snuff.
2014-11-23rollup merge of #19225: reem/any-unnecessary-transmute-copyJakub Bukaj-7/+3
transmute_copy is no longer needed and is just slow.
2014-11-23rollup merge of #19193: scialex/rc-countsJakub Bukaj-4/+100
These functions allow you to see how many weak and strong references there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of `Arc` it is not possible to get the number of weak references of an arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation. On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic. This sort of information is useful for creating dynamically cleared caches for use in OS development, for example holding pages of files in memory until the address space is needed for something else.
2014-11-22Any: use plain transmute instead of transmute_copy for downcasting.Jonathan Reem-7/+3
transmute_copy is no longer needed and is just slow.
2014-11-21Shuffle locations for DerefAlexander Light-92/+57
Remove both `strong_count` and `weak_count` from `Weak`s and make the methods bare functions so as not to cause trouble with `deref`.
2014-11-21Add `weak_count` and `strong_count` to Rc and ArcAlexander Light-2/+133
These functions allow you to see how many weak and strong references there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of `Arc` it is not possible to get the number of weak references of an arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation. On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic.
2014-11-20Fallout from libgreen and libnative removalAaron Turon-1/+0
2014-11-14libs: fix #[stable] inheritance falloutAaron Turon-3/+1
A recent change turned off inheritance for the #[stable] by default, but failed to catch all the cases where this was being used in std. This patch fixes that problem.
2014-11-12Register new snapshotsAlex Crichton-40/+0
2014-11-07auto merge of #18714 : nikomatsakis/rust/issue-18621-deref-for-refs, r=aturonbors-1/+1
libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this. r? @aturon
2014-11-06libs: add Deref, DerefMut impls for references, fixing a bug in compiler in ↵Niko Matsakis-1/+1
the process that was blocking this. Fixes #18621.
2014-11-06Implement Default for Box<[T]>Jorge Aparicio-0/+4
2014-11-05DSTify Box<T> implementation of PartialEq, PartialOrd, Eq, OrdJorge Aparicio-0/+40
2014-11-01bubble up out-of-memory errors from liballocDaniel Micay-60/+33
This makes the low-level allocation API suitable for use cases where out-of-memory conditions need to be handled. Closes #18292 [breaking-change]
2014-10-30DSTify Show and all the other formatting traitsJorge Aparicio-1/+2
2014-10-29Rename fail! to panic!Steve Klabnik-5/+5
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-27alloc: Make deriving more friendly with ArcAlex Crichton-19/+53
This adds impls of Eq/Ord/PartialEq/PartialOrd/Show/Default to Arc<T>, and it also removes the `Send + Sync` bound on the `Clone` impl of Arc to make it more deriving-friendly. The `Send + Sync` requirement is still enforce on construction, of course!
2014-10-26Implement Show for `Arc<T>`Adolfo Ochagavía-0/+14
Fixes https://github.com/rust-lang/rust/issues/18299
2014-10-25fix sized deallocation documentationDaniel Micay-13/+13
2014-10-25return the new usable size from reallocate_inplaceDaniel Micay-19/+13
The real size is also more useful than just a boolean, and the caller can easily determine if the operation failed from the real size. In most cases, the caller is only going to be growing the allocation so a branch can be avoided. [breaking-change]
2014-10-25get rid of libc_heap::{malloc_raw, realloc_raw}Daniel Micay-60/+23
The C standard library functions should be used directly. The quirky NULL / zero-size allocation workaround is no longer necessary and was adding an extra branch to the allocator code path in a build without jemalloc. This is a small step towards liballoc being compatible with handling OOM errors instead of aborting (#18292). [breaking-change]
2014-10-25Make MIN_ALIGN a const to allow better optimizationBjörn Steinbrink-2/+2
With MIN_ALIGN as a static, other crates don't have access to its value at compile time, because it is an extern global. That means that the checks against it can't be optimized out, which is rather unfortunate. So let's make it a constant instead.
2014-10-16liballoc: Remove all uses of {:?}.Luqman Aden-2/+0
2014-10-16Remove libdebug and update tests.Luqman Aden-1/+0
2014-10-13Clean up rustc warnings.NODA, Kai-1/+0
compiletest: compact "linux" "macos" etc.as "unix". liballoc: remove a superfluous "use". libcollections: remove invocations of deprecated methods in favor of their suggested replacements and use "_" for a loop counter. libcoretest: remove invocations of deprecated methods; also add "allow(deprecated)" for testing a deprecated method itself. libglob: use "cfg_attr". libgraphviz: add a test for one of data constructors. libgreen: remove a superfluous "use". libnum: "allow(type_overflow)" for type cast into u8 in a test code. librustc: names of static variables should be in upper case. libserialize: v[i] instead of get(). libstd/ascii: to_lowercase() instead of to_lower(). libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend. It will serve better for testing various aspects of bitflags!. libstd/collections: "allow(deprecated)" for testing a deprecated method itself. libstd/io: remove invocations of deprecated methods and superfluous "use". Also add #[test] where it was missing. libstd/num: introduce a helper function to effectively remove invocations of a deprecated method. libstd/path and rand: remove invocations of deprecated methods and superfluous "use". libstd/task and libsync/comm: "allow(deprecated)" for testing a deprecated method itself. libsync/deque: remove superfluous "unsafe". libsync/mutex and once: names of static variables should be in upper case. libterm: introduce a helper function to effectively remove invocations of a deprecated method. We still see a few warnings about using obsoleted native::task::spawn() in the test modules for libsync. I'm not sure how I should replace them with std::task::TaksBuilder and native::task::NativeTaskBuilder (dependency to libstd?) Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-10-10auto merge of #17853 : alexcrichton/rust/issue-17718, r=pcwaltonbors-1/+1
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] Closes #17718 [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-09Use the same html_root_url for all docsBrian Anderson-1/+1
2014-10-09alloc: Convert statics to constantsAlex Crichton-1/+1
2014-10-08saner parameter order for reallocation functionsDaniel Micay-19/+14
Using reallocate(old_ptr, old_size, new_size, align) makes a lot more sense than reallocate(old_ptr, new_size, align, old_size) and matches up with the order used by existing platform APIs like mremap. Closes #17837 [breaking-change]
2014-10-02Test fixes from the rollupAlex Crichton-0/+1
2014-10-02rollup merge of #17666 : eddyb/take-garbage-outAlex Crichton-39/+0
Conflicts: src/libcollections/lib.rs src/libcore/lib.rs src/librustdoc/lib.rs src/librustrt/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/test/run-pass/issue-8898.rs
2014-10-02alloc: fix reallocate_inplace implementationDaniel Micay-9/+26
The returned size is the new real size of the allocation.
2014-10-02tests: remove uses of Gc.Eduard Burtescu-8/+0
2014-10-02core: remove raw::GcBox.Eduard Burtescu-31/+0
2014-09-30Fix liballocSteven Fackler-8/+8
2014-09-29rollup merge of #17582 : kmcallister/gc-boxAlex Crichton-1/+1
2014-09-26Rename raw::Box to raw::GcBoxKeegan McAllister-1/+1
Fixes #17470.
2014-09-26librustc: Eliminate the `ref` syntax for unboxed closure capture clausesPatrick Walton-6/+0
in favor of `move`. This breaks code that used `move` as an identifier, because it is now a keyword. Change such identifiers to not use the keyword `move`. Additionally, this breaks code that was counting on by-value or by-reference capture semantics for unboxed closures (behind the feature gate). Change `ref |:|` to `|:|` and `|:|` to `move |:|`. Part of RFC #63; part of issue #12831. [breaking-change]
2014-09-22Update calls of deprecated functions in macros.Victor Berger-3/+3
Fallout of #17185.
2014-09-16Register new snapshotsAlex Crichton-29/+0
This is the first linux snapshot created on our new CentOS 5.10 builders. Closes #9545
2014-09-16Fallout from renamingAaron Turon-5/+5
2014-09-16auto merge of #17197 : nikomatsakis/rust/issue-5527-trait-reform-revisited, ↵bors-1/+0
r=pcwalton This patch does not make many functional changes, but does a lot of restructuring towards the goals of #5527. This is the biggest patch, basically, that should enable most of the other patches in a relatively straightforward way. Major changes: - Do not track impls through trans, instead recompute as needed. - Isolate trait matching code into its own module, carefully structure to distinguish various phases (selection vs confirmation vs fulfillment) - Consider where clauses in their more general form - Integrate checking of builtin bounds into the trait matching process, rather than doing it separately in kind.rs (important for opt-in builtin bounds) What is not included: - Where clauses are still not generalized. This should be a straightforward follow-up patch. - Caching. I did not include much caching. I have plans for various kinds of caching we can do. Should be straightforward. Preliminary perf measurements suggested that this branch keeps compilation times roughly what they are. - Method resolution. The initial algorithm I proposed for #5527 does not work as well as I hoped. I have a revised plan which is much more similar to what we do today. - Deref vs deref-mut. The initial fix I had worked great for autoderef, but not for explicit deref. - Permitting blanket impls to overlap with specific impls. Initial plan to consider all nested obligations before considering an impl to match caused many compilation errors. We have a revised plan but it is not implemented here, should be a relatively straightforward extension.
2014-09-15remove the closure_exchange_malloc lang itemDaniel Micay-17/+1
2014-09-15heap: optimize EMPTY to avoid relocationsDaniel Micay-5/+6
Sized deallocation makes it pointless to provide an address that never overlaps with pointers returned by an allocator. Code can branch on the capacity of the allocation instead of a comparison with this sentinel. This improves the situation in #8859, and the remaining issues are only from the logging API, which should be disabled by default in optimized release builds anyway along with debug assertions. The remaining issues are part of #17081. Closes #8859
2014-09-15heap: rm out-of-date FIXMEsDaniel Micay-2/+0
2014-09-15silence various warnings in stdlib, no idea why they suddenly startedNiko Matsakis-1/+0
2014-09-11auto merge of #17110 : thestinger/rust/dst, r=cmrbors-6/+0
The pointer in the slice must not be null, because enum representations make that assumption. The `exchange_malloc` function returns a non-null sentinel for the zero size case, and it must not be passed to the `exchange_free` lang item. Since the length is always equal to the true capacity, a branch on the length is enough for most types. Slices of zero size types are statically special cased to never attempt deallocation. This is the same implementation as `Vec<T>`. Closes #14395
2014-09-10implement sized deallocationDaniel Micay-0/+11
Closes #13994
2014-09-10micro-optimize dynamic allocation alignmentDaniel Micay-34/+64
Previously, some parts of this optimization were impossible because the alignment passed to the free function was not correct. That was fully fixed by #17012. Closes #17092