summary refs log tree commit diff
path: root/src/libcollections/btree/node.rs
AgeCommit message (Collapse)AuthorLines
2015-10-13Correct spelling in docsAndrew Paseltiner-1/+1
2015-10-06Add RFC 1238's `unsafe_destructor_blind_to_params` (UGEH) where needed.Felix S. Klock II-0/+3
I needed it in `RawVec`, `Vec`, and `TypedArena` for `rustc` to bootstrap; but of course that alone was not sufficient for `make check`. Later I added `unsafe_destructor_blind_to_params` to collections, in particular `LinkedList` and `RawTable` (the backing representation for `HashMap` and `HashSet`), to get the regression tests exercising cyclic structure from PR #27185 building. ---- Note that the feature is `dropck_parametricity` (which is not the same as the attribute's name). We will almost certainly vary our strategy here in the future, so it makes some sense to have a not-as-ugly name for the feature gate. (The attribute name was deliberately selected to be ugly looking.)
2015-09-30Auto merge of #28731 - bluss:by-ref, r=alexcrichtonbors-1/+1
Remove redundant uses of Iterator::by_ref()
2015-09-29Remove redundant uses of Iterator::by_ref()Ulrik Sverdrup-1/+1
2015-09-18Avoid zero-sized leaf allocations in `BTreeMap`Andrew Paseltiner-1/+6
When both the key and value types were zero-sized, `BTreeMap` previously called `heap::allocate` with `size == 0` for leaf nodes, which is undefined behavior, and jemalloc would attempt to read invalid memory, crashing the process. This avoids undefined behavior by allocating enough space to store one edge in leaf nodes that would otherwise have `size == 0`. Although this uses extra memory, maps with zero-sized key types that have sensible implementations of the ordering traits can only contain a single key-value pair (and therefore only a single leaf node), and maps with key and value types that are both zero-sized have few uses, if any. Furthermore, this is a temporary fix that will likely be unnecessary once the `BTreeMap` implementation is rewritten to use parent pointers. Closes #28493.
2015-09-03Use `null()`/`null_mut()` instead of `0 as *const T`/`0 as *mut T`Vadim Petrochenkov-1/+1
2015-08-18Auto merge of #27624 - apasel422:issue-27620, r=Gankrobors-2/+23
Closes #27620.
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-10Remove transmute from `btree::node::Node::as_slices_internal_mut`Andrew Paseltiner-2/+23
Closes #27620.
2015-08-09Change TODO to FIXMETobias Bucher-1/+1
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-6/+7
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-08-05Fully generalize `BTree{Map, Set}` range iteratorsAndrew Paseltiner-2/+6
This permits collections with `String` keys to be ranged over with `&str` bounds. The `K` defaults for `Min` and `Max` permit the default type parameter fallback to work with things like ```rust use std::collections::{BTreeSet, Bound}; let set = BTreeSet::<String>::new(); set.range(Bound::Included("a"), Bound::Unbounded); ``` Without the defaults, the type of the maximum bound would be unconstrained.
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-06-24Make `align_of` behave like `min_align_of`.Huon Wilson-5/+5
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-05-27Remove #[cfg(stage0)] items.Eduard Burtescu-67/+0
2015-05-15Allow for better optimizations of iterators for zero-sized typesBjörn Steinbrink-0/+68
Using regular pointer arithmetic to iterate collections of zero-sized types doesn't work, because we'd get the same pointer all the time. Our current solution is to convert the pointer to an integer, add an offset and then convert back, but this inhibits certain optimizations. What we should do instead is to convert the pointer to one that points to an i8*, and then use a LLVM GEP instructions without the inbounds flag to perform the pointer arithmetic. This allows to generate pointers that point outside allocated objects without causing UB (as long as you don't dereference them), and it wraps around using two's complement, i.e. it behaves exactly like the wrapping_* operations we're currently using, with the added benefit of LLVM being able to better optimize the resulting IR.
2015-04-28Register new snapshotsTamir Duberstein-3/+0
2015-04-14Fill in missing implementationTamir Duberstein-0/+3
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14Positive case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-1/+1
2015-03-30std: Standardize (input, output) param orderingsAlex Crichton-12/+12
This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes #22890 [breaking-change]
2015-03-27rollup merge of #23738: alexcrichton/snapshotsAlex Crichton-61/+0
Conflicts: src/libcollections/vec.rs
2015-03-26Register new snapshotsAlex Crichton-61/+0
2015-03-26Switch drop-flag to `u8` to allow special tags to instrument state.Felix S. Klock II-2/+4
Refactored code so that the drop-flag values for initialized (`DTOR_NEEDED`) versus dropped (`DTOR_DONE`) are given explicit names. Add `mem::dropped()` (which with `DTOR_DONE == 0` is semantically the same as `mem::zeroed`, but the point is that it abstracts away from the particular choice of value for `DTOR_DONE`). Filling-drop needs to use something other than `ptr::read_and_zero`, so I added such a function: `ptr::read_and_drop`. But, libraries should not use it if they can otherwise avoid it. Fixes to tests to accommodate filling-drop.
2015-03-23rollup merge of #23604: apasel422/btreeAlex Crichton-0/+2
`btree_map::IntoIter` (and `btree_set::IntoIter`) remains, but it is a bit trickier.
2015-03-23Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses ofNiko Matsakis-0/+61
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about how to use `[]`.
2015-03-21implement `Clone` for `btree` iteratorsAndrew Paseltiner-0/+2
2015-03-18Register new snapshotsAlex Crichton-3/+0
2015-03-16impl {i,u}{8,16,32,64,size}Jorge Aparicio-2/+5
2015-03-13slice::from_raw_parts is preferred over transmuting a fresh raw::SliceOliver Schneider-8/+2
2015-03-03Fixes to collections to accommodate arith-overflow changes.Felix S. Klock II-1/+2
* `collections::btree::node`: accommodate (transient) underflow. * `collections::btree::map`: avoid underflow during `fn next` for `BTreeMap::range` methods. * `collections::slice`: note that pnkfelix deliberately used `new_pos_wrapping` only once; the other cases of arithmetic do not over- nor underflow, which is a useful property to leave implicitly checked/documented via the remaining calls to `fn new_pos(..)`. * `collections::vec_deque` applied wrapping ops (somewhat blindly) to two implementation methods, and many tests. * `std::collections::hash::table` : Use `OverflowingOps` trait to track overflow during `calculate_offsets` and `calculate_allocation` functions.
2015-02-26Send/Sync audit for libcollectionsEdward Wang-5/+8
In the process, also replaces a raw mutable pointers with Unique to spell out the ownership semantics. cc #22709
2015-02-24std: Stabilize some `ptr` functionsAlex Crichton-12/+12
Specifically, the following actions were taken: * The `copy_memory` and `copy_nonoverlapping_memory` functions to drop the `_memory` suffix (as it's implied by the functionality). Both functions are now marked as `#[stable]`. * The `set_memory` function was renamed to `write_bytes` and is now stable. * The `zero_memory` function is now deprecated in favor of `write_bytes` directly. * The `Unique` pointer type is now behind its own feature gate called `unique` to facilitate future stabilization. * All type parameters now are `T: ?Sized` wherever possible and new clauses were added to the `offset` functions to require that the type is sized. [breaking-change]
2015-02-18rollup merge of #22286: nikomatsakis/variance-4bAlex Crichton-32/+52
Conflicts: src/librustc/middle/infer/combine.rs src/librustc_typeck/check/wf.rs
2015-02-18Stabilize std::borrowAaron Turon-4/+5
This commit stabilizes `std::borrow`, making the following modifications to catch up the API with language changes: * It renames `BorrowFrom` to `Borrow`, as was originally intended (but blocked for technical reasons), and reorders the parameters accordingly. * It moves the type parameter of `ToOwned` to an associated type. This is somewhat less flexible, in that each borrowed type must have a unique owned type, but leads to a significant simplification for `Cow`. Flexibility can be regained by using newtyped slices, which is advisable for other reasons anyway. * It removes the owned type parameter from `Cow`, making the type much less verbose. * Deprecates the `is_owned` and `is_borrowed` predicates in favor of direct matching. The above API changes are relatively minor; the basic functionality remains the same, and essentially the whole module is now marked `#[stable]`. [breaking-change]
2015-02-18Fallout: port btree to use Unique, some markers.Niko Matsakis-32/+52
2015-02-11Add core::marker::PhantomData.Felix S. Klock II-8/+8
Port `core::ptr::Unique` to have `PhantomData`. Add `PhantomData` to `TypedArena` and `Vec` as well. As a drive-by, switch `ptr::Unique` from a tuple-struct to a struct with fields.
2015-02-06Rollup merge of #21969 - Gankro:collections-cleanup, r=alexcrichtonManish Goregaokar-61/+61
This is 99% burning ints to the ground, but I also got rid of useless annotations or made code more \"idiomatic\" as I went along. Mostly changes in tests.
2015-02-05misc collections code cleanupAlexis-61/+61
2015-02-04Fix for misspelled comments.Joseph Crail-1/+1
The spelling corrections were made in both documentation comments and regular comments.
2015-02-02`for x in xs.iter()` -> `for x in &xs`Jorge Aparicio-3/+3
2015-01-30fix falloutJorge Aparicio-4/+4
2015-01-29`for x in range(a, b)` -> `for x in a..b`Jorge Aparicio-1/+1
sed -i 's/in range(\([^,]*\), *\([^()]*\))/in \1\.\.\2/g' **/*.rs
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-11/+10
Conflicts: mk/tests.mk src/liballoc/arc.rs src/liballoc/boxed.rs src/liballoc/rc.rs src/libcollections/bit.rs src/libcollections/btree/map.rs src/libcollections/btree/set.rs src/libcollections/dlist.rs src/libcollections/ring_buf.rs src/libcollections/slice.rs src/libcollections/str.rs src/libcollections/string.rs src/libcollections/vec.rs src/libcollections/vec_map.rs src/libcore/any.rs src/libcore/array.rs src/libcore/borrow.rs src/libcore/error.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/ops.rs src/libcore/result.rs src/libcore/slice.rs src/libcore/str/mod.rs src/libregex/lib.rs src/libregex/re.rs src/librustc/lint/builtin.rs src/libstd/collections/hash/map.rs src/libstd/collections/hash/set.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/mutex.rs src/libstd/sync/poison.rs src/libstd/sync/rwlock.rs src/libsyntax/feature_gate.rs src/libsyntax/test.rs
2015-01-23grandfathered -> rust1Brian Anderson-1/+1
2015-01-21Add 'feature' and 'since' to stability attributesBrian Anderson-1/+1
2015-01-21Fallout from stabilization.Aaron Turon-11/+10
2015-01-21Rollup merge of #21375 - petrochenkov:ssbsl, r=alexcrichtonBarosl LEE-3/+3
After PR #19766 added implicit coersions `*mut T -> *const T`, the explicit casts can be removed. (The number of such casts turned out to be relatively small).
2015-01-19Implement range and range_mut for BTreePiotr Czarnecki-75/+215
Simplify BTree's iterators, too.