about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2015-03-09Auto merge of #22561 - richo:as_slice-as_str, r=Manishearthbors-6/+6
This may not be quite ready to go out, I fixed some docs but suspect I missed a bunch. I also wound up fixing a bunch of redundant `[]` suffixes, but on closer inspection I don't believe that can land until after a snapshot.
2015-03-09Rename #[should_fail] to #[should_panic]Steven Fackler-33/+33
2015-03-09doc: Fix extraneous as_slice()'s in docstringsRicho Healey-6/+6
2015-03-06Rollup merge of #23067 - oli-obk:doc_examle_fix, r=alexcrichtonManish Goregaokar-1/+1
The compiler even tells us this won't work. ``` let mut i = s.len(); while i < 0 { ... } ```
2015-03-06Rollup merge of #23056 - awlnx:master, r=nrcManish Goregaokar-1/+2
2015-03-05fix for new attributes failing. issue #22964awlnx-1/+2
2015-03-05doc example does nothingOliver Schneider-1/+1
2015-03-05Rollup merge of #22937 - MDCox:str-docs, r=steveklabnikManish Goregaokar-5/+8
Fixes #22902 r? @steveklabnik
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-59/+59
2015-03-04Reword str docs and include links to StrExtMatt Cox-5/+8
2015-03-04Auto merge of #22920 - tshepang:remove-some-warnings, r=huonwbors-2/+2
2015-03-03Add `: Box<_>` or `::Box<_>` type annotations to various places.Felix S. Klock II-17/+19
This is the kind of change that one is expected to need to make to accommodate overloaded-`box`. ---- Note that this is not *all* of the changes necessary to accommodate Issue 22181. It is merely the subset of those cases where there was already a let-binding in place that made it easy to add the necesasry type ascription. (For unnamed intermediate `Box` values, one must go down a different route; `Box::new` is the option that maximizes portability, but has potential inefficiency depending on whether the call is inlined.) ---- There is one place worth note, `run-pass/coerce-match.rs`, where I used an ugly form of `Box<_>` type ascription where I would have preferred to use `Box::new` to accommodate overloaded-`box`. I deliberately did not use `Box::new` here, because that is already done in coerce-match-calls.rs. ---- Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-35/+56
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
2015-03-03Rollup merge of #22876 - Florob:const, r=nikomatsakisManish Goregaokar-8/+8
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-03Rollup merge of #22943 - ipetkov:lint-recursion, r=alexcrichtonManish Goregaokar-6/+7
* The lint visitor's visit_ty method did not recurse, and had a reference to the now closed #10894 * The newly enabled recursion has only affected the `deprectated` lint which now detects uses of deprecated items in trait impls and function return types * Renamed some references to `CowString` and `CowVec` to `Cow<str>` and `Cow<[T]>`, respectively, which appear outside of the crate which defines them * Replaced a few instances of `InvariantType<T>` with `PhantomData<Cell<T>>` * Disabled the `deprecated` lint in several places that reference/implement traits on deprecated items which will get cleaned up in the future * Unfortunately, this means that if a library declares `#![deny(deprecated)]` and marks anything as deprecated, it will have to disable the lint for any uses of said item, e.g. any impl the now deprecated item For any library that denies deprecated items but has deprecated items of its own, this is a [breaking-change] I had originally intended for the lint to ignore uses of deprecated items that are declared in the same crate, but this goes against some previous test cases that expect the lint to capture *all* uses of deprecated items, so I maintained the previous approach to avoid changing the expected behavior of the lint. Tested locally on OS X, so hopefully there aren't any deprecated item uses behind a `cfg` that I may have missed.
2015-03-03Fixes to collections to accommodate arith-overflow changes.Felix S. Klock II-32/+53
* `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-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-3/+3
Many of the core rust libraries have places that rely on integer wrapping behaviour. These places have been altered to use the wrapping_* methods: * core::hash::sip - A number of macros * core::str - The `maximal_suffix` method in `TwoWaySearcher` * rustc::util::nodemap - Implementation of FnvHash * rustc_back::sha2 - A number of macros and other places * rand::isaac - Isaac64Rng, changed to use the Wrapping helper type Some places had "benign" underflow. This is when underflow or overflow occurs, but the unspecified value is not used due to other conditions. * collections::bit::Bitv - underflow when `self.nbits` is zero. * collections::hash::{map,table} - Underflow when searching an empty table. Did cause undefined behaviour in this case due to an out-of-bounds ptr::offset based on the underflowed index. However the resulting pointers would never be read from. * syntax::ext::deriving::encodable - Underflow when calculating the index of the last field in a variant with no fields. These cases were altered to avoid the underflow, often by moving the underflowing operation to a place where underflow could not happen. There was one case that relied on the fact that unsigned arithmetic and two's complement arithmetic are identical with wrapping semantics. This was changed to use the wrapping_* methods. Finally, the calculation of variant discriminants could overflow if the preceeding discriminant was `U64_MAX`. The logic in `rustc::middle::ty` for this was altered to avoid the overflow completely, while the remaining places were changed to use wrapping methods. This is because `rustc::middle::ty::enum_variants` now throws an error when the calculated discriminant value overflows a `u64`. This behaviour can be triggered by the following code: ``` enum Foo { A = U64_MAX, B } ``` This commit also implements the remaining integer operators for Wrapped<T>.
2015-03-02core: Audit num module for int/uintBrian Anderson-62/+62
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. [breaking-change]
2015-03-02Enable recursion for visit_ty in lint visitorIvan Petkov-6/+7
* The lint visitor's visit_ty method did not recurse, and had a reference to the now closed #10894 * The newly enabled recursion has only affected the `deprectated` lint which now detects uses of deprecated items in trait impls and function return types * Renamed some references to `CowString` and `CowVec` to `Cow<str>` and `Cow<[T]>`, respectively, which appear outside of the crate which defines them * Replaced a few instances of `InvariantType<T>` with `PhantomData<Cell<T>>` * Disabled the `deprecated` lint in several places that reference/implement traits on deprecated items which will get cleaned up in the future * Disabled the `exceeding_bitshifts` lint for compile-fail/huge-array-simple test so it doesn't shadow the expected error on 32bit systems * Unfortunately, this means that if a library declares `#![deny(deprecated)]` and marks anything as deprecated, it will have to disable the lint for any uses of said item, e.g. any impl the now deprecated item For any library that denies deprecated items but has deprecated items of its own, this is a [breaking-change]
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-8/+8
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-01Addresses rust-lang/rust#22646Leonids Maslovs-1/+1
Removes deprecated `{:08d}` format from the module documentation. `{:08}` should be used instead now.
2015-03-01remove some compiler warningsTshepang Lekhonkhobe-2/+2
2015-02-28Fix incorrectly parsed markdown linkmdinger-3/+3
2015-02-28Auto merge of #22669 - dotdash:fast_slice_iter, r=huonwbors-1/+4
This adds the assume() calls back that got lost when rebasing #21886.
2015-02-27Rollup merge of #22835 - tshepang:remove-some-warnings, r=jakub-Manish Goregaokar-4/+4
2015-02-26Send/Sync audit for libcollectionsEdward Wang-13/+13
In the process, also replaces a raw mutable pointers with Unique to spell out the ownership semantics. cc #22709
2015-02-26Tweak VecDeque's IterMut implementationEdward Wang-15/+9
So it is symmetric to its `Iter` implementation. Also kills an FIXME.
2015-02-26remove some compiler warningsTshepang Lekhonkhobe-4/+4
2015-02-25Rollup merge of #22729 - alexcrichton:ptr-stabilization, r=aturonManish Goregaokar-51/+50
Specifically, the following actions were takend: * 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. [breaking-change]
2015-02-25Rollup merge of #22157 - tbu-:pr_debug_collections, r=alexcrichtonManish Goregaokar-20/+20
r? @Gankro
2015-02-25Rollup merge of #22635 - kmcallister:macros-chapter, r=steveklabnikManish Goregaokar-1/+1
r? @steveklabnik
2015-02-24Change `Debug` implementation of `BTree*` as wellTobias Bucher-4/+4
2015-02-24Modify collection's `Debug` output to resemble in their content onlyTobias Bucher-16/+16
2015-02-24std: Stabilize some `ptr` functionsAlex Crichton-51/+50
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-25Rollup merge of #22539 - oli-obk:style_nitpicks, r=ManishearthManish Goregaokar-4/+4
I tried to follow [the style guide][1] as much as possible. This is just from some random readings of the code, so no guarantees on completeness, even in the edited files. [1]: http://aturon.github.io/style/README.html
2015-02-24Fix broken testsVadim Petrochenkov-6/+6
2015-02-24Use arrays instead of vectors in testsVadim Petrochenkov-132/+132
2015-02-24style nitpicksOliver Schneider-4/+4
2015-02-24Fix fallout from correct stability handling in UFCS.Eduard Burtescu-1/+1
2015-02-24Rollup merge of #22632 - nagisa:kill-show-string-with-fire!, r=alexcrichtonManish Goregaokar-1/+1
Toss the tomatoes! r? @aturon Fixes #22478. The underlying bug(?) behind that issue still exists though and there’s another issue that reports it.
2015-02-24Rollup merge of #22653 - tsion:master, r=alexcrichtonManish Goregaokar-1/+1
r? @steveklabnik
2015-02-23Rollup merge of #22320 - petrochenkov:eq, r=alexcrichtonManish Goregaokar-59/+24
2015-02-23Rollup merge of #22494 - msiemens:vec_map-append-split_off, r=GankroManish Goregaokar-2/+170
2015-02-23Rollup merge of #22696 - stepancheg:use-box, r=alexcrichtonManish Goregaokar-1/+1
e. g. ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails. (And there are two more patches in PR: fix typo in doc and mark `from_raw` and `into_raw` functions inline.)
2015-02-23Rollup merge of #22643 - fhartwig:bitvec-doc-fix, r=alexcrichtonManish Goregaokar-1/+1
It looks like a few spots in the documentation were missed when renaming `Bitv` and `BitvSet`. This fixes the docs to use their current names.
2015-02-23Rollup merge of #22513 - steveklabnik:doc_str, r=brsonManish Goregaokar-274/+440
2015-02-22Change int to i32 in Cow example.Scott Olson-1/+1
2015-02-23Use boxed functions instead of transmuteStepan Koltsov-1/+1
... to convert between Box and raw pointers. E. g. use ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails in practice.
2015-02-22Auto merge of #22466 - Kimundi:str_pattern_ai_safe, r=aturonbors-56/+35
This is not a complete implementation of the RFC: - only existing methods got updated, no new ones added - doc comments are not extensive enough yet - optimizations got lost and need to be reimplemented See https://github.com/rust-lang/rfcs/pull/528 Technically a [breaking-change]
2015-02-23Use while letMikhail Zabaluev-16/+9