about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2014-08-28Fallout from stabilizing core::optionAaron Turon-10/+10
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-30/+219
2014-08-26libcollections: In tests, remove some uses of deprecated methods andnham-77/+75
unused imports.
2014-08-26Rebasing changesNick Cameron-9/+16
2014-08-26DST coercions and DST structsNick Cameron-60/+0
[breaking-change] 1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code. 2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible. 3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-105/+197
2014-08-26Use the slice repr for ~[T]Nick Cameron-0/+60
2014-08-22auto merge of #16663 : Gankro/rust/heapify, r=alexcrichtonbors-4/+3
Heapify is O(n), extend as currently implemented is O(nlogn). No brainer. Currently investigating whether extend can just be implemented as a local heapify.
2014-08-21make priorityqueue's from_iter use heapifyAlexis Beingessner-4/+3
2014-08-21bitv: make sure benchmarks run long enoughVinzent Steinberg-7/+19
Previously they were too short (less than 10 ns), so the benchmarker could not resolve them meaningfully. Now they should run in the order of 100 ns.
2014-08-21bitv: make benchmarks always return a valueVinzent Steinberg-8/+11
This makes sure that the benchmarked code does not get optimized away. Also fixed a typo. Fixes #12118.
2014-08-19auto merge of #16241 : P1start/rust/doc-fixes, r=alexcrichtonbors-666/+668
For crates `alloc`–`collections`. This is mostly just updating a few function/method descriptions to use the indicative style. cc #4361; I’ve sort of assumed that the third-person indicative style has been decided on, but I could update this to use the imperative style if that’s preferred, or even update this to remove all function-style-related changes. (I think that standardising on one thing, even if it’s not the ‘best’ option, is still better than having no standard at all.) The indicative style seems to be more common in the Rust standard library at the moment, especially in the newer modules (e.g. `collections::vec`), more popular in the discussion about it, and also more popular amongst other languages (see https://github.com/rust-lang/rust/issues/4361#issuecomment-33470215).
2014-08-19auto merge of #16582 : Gankro/rust/bitv, r=alexcrichtonbors-26/+41
This was bothering me (and some other people). The macro was necessary in a transient step of my development, but I converged on a design where it was unnecessary, but it didn't really click that that had happened. This fixes it up.
2014-08-19A few minor documentation fixesP1start-666/+668
2014-08-19auto merge of #16580 : steveklabnik/rust/gh1498, r=pcwaltonbors-11/+0
Fixes #14948
2014-08-18Fixing bitvset is_disjoint, fixes #16587Alexis Beingessner-1/+19
2014-08-18Refactor BitV internals to not use macro, reduce duplicationAlexis Beingessner-25/+22
2014-08-18Remove innapropriate string mutability section.Steve Klabnik-11/+0
Fixes #14948
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-4/+4
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-18auto merge of #16559 : Gankro/rust/bitv, r=pcwaltonbors-3/+114
These were the only differing-size-based errors I noticed. Might be more.
2014-08-17Correct internal BitvSet 0-padding, fixes #16542Alexis Beingessner-3/+114
2014-08-17auto merge of #16550 : kaseyc/rust/fix_documentation_error, r=alexcrichtonbors-1/+1
2014-08-17auto merge of #16543 : huonw/rust/deprecated-btree, r=alexcrichtonbors-0/+7
This is very half-baked at the moment and very inefficient, e.g. inappropriate use of by-value `self` (and thus being forced into an overuse of `clone`). People get the wrong impression about Rust when using it, e.g. that Rust cannot express what other languages can because the implementation is inefficient: https://news.ycombinator.com/item?id=8187831 .
2014-08-17auto merge of #16498 : Kimundi/rust/inline-utf-encoding, r=alexcrichtonbors-3/+3
The first commit improves code generation through a few changes: - The `#[inline]` attributes allow llvm to constant fold the encoding step away in certain situations. For example, code like this changes from a call to `encode_utf8` in a inner loop to the pushing of a byte constant: ```rust let mut s = String::new(); for _ in range(0u, 21) { s.push_char('a'); } ``` - Both methods changed their semantic from causing run time failure if the target buffer is not large enough to returning `None` instead. This makes llvm no longer emit code for causing failure for these methods. - A few debug `assert!()` calls got removed because they affected code generation due to unwinding, and where basically unnecessary with today's sound handling of `char` as a Unicode scalar value. ~~The second commit is optional. It changes the methods from regular indexing with the `dst[i]` syntax to unsafe indexing with `dst.unsafe_mut_ref(i)`. This does not change code generation directly - in both cases llvm is smart enough to see that there can never be an out-of-bounds access. But it makes it emit a `nounwind` attribute for the function. However, I'm not sure whether that is a real improvement, so if there is any objection to this I'll remove the commit.~~ This changes how the methods behave on a too small buffer, so this is a [breaking-change]
2014-08-16Fix an error in a code sample in bitv.rsKasey Carrothers-1/+1
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-28/+27
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-17collections: deprecate BTree.Huon Wilson-0/+7
This is very half-baked at the moment and very inefficient, e.g. inappropriate use of by-value `self` (and thus being forced into an overuse of `clone`). People get the wrong impression about Rust when using it, e.g. that Rust cannot express what other languages can because the implementation is inefficient.
2014-08-16Optimized IR generation for UTF-8 and UTF-16 encodingMarvin Löbel-3/+3
- Both can now be inlined and constant folded away - Both can no longer cause failure - Both now return an `Option` instead Removed debug `assert!()`s over the valid ranges of a `char` - It affected optimizations due to unwinding - Char handling is now sound enought that they became uneccessary
2014-08-13Fix test falloutBrian Anderson-10/+10
2014-08-13core: Put stability attributes all over the slice moduleBrian Anderson-0/+2
Much of this is as discussed[1]. Many things are marked [1]: https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md
2014-08-13core: Add binary_search and binary_search_elem methods to slices.Brian Anderson-0/+1
These are like the existing bsearch methods but if the search fails, it returns the next insertion point. The new `binary_search` returns a `BinarySearchResult` that is either `Found` or `NotFound`. For convenience, the `found` and `not_found` methods convert to `Option`, ala `Result`. Deprecate bsearch and bsearch_elem.
2014-08-13core: Rename ImmutableEqSlice to ImmutablePartialEqSliceBrian Anderson-1/+1
This is in the prelude and won't break much code. [breaking-change]
2014-08-13collections: Deprecate Vec::tailn. Same as slice_fromBrian Anderson-1/+2
2014-08-13core: Rename ImmutableSlice::unsafe_ref to unsafe_getBrian Anderson-5/+5
Deprecate the previous.
2014-08-13std: Rename slice::Vector to SliceBrian Anderson-12/+16
This required some contortions because importing both raw::Slice and slice::Slice makes rustc crash. Since `Slice` is in the prelude, this renaming is unlikely to casue breakage. [breaking-change]
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-13/+13
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-12Deprecation fallout in libcollectionsAaron Turon-40/+43
2014-08-12auto merge of #16195 : P1start/rust/more-index, r=aturonbors-7/+159
Implement `Index` for `RingBuf`, `HashMap`, `TreeMap`, `SmallIntMap`, and `TrieMap`. If there’s anything that I missed or should be removed, let me know.
2014-08-12Implement Index for TrieMapP1start-0/+38
2014-08-12Implement Index for SmallIntMapP1start-4/+45
This also deprecates SmallIntMap::get. Use indexing instead.
2014-08-12Implement Index for TreeMapP1start-0/+36
2014-08-12Implement Index for RingBufP1start-3/+40
This also deprecates RingBuf::get. Use indexing instead.
2014-08-12auto merge of #16417 : jasonthompson/rust/docs/slice3, r=alexcrichtonbors-0/+33
- Moved examples for permutations and next into trait definition as comments on pull request #16244. - Fixed (hopefully) issue with erronious commit of changes to src/llvm.
2014-08-11API docs/examples for std::sliceJason Thompson-0/+33
- API doc/example for next() in Permutations - API doc/example for permutations() in ImmutableCloneableVector - Moved examples for permutations and next into trait definition as comments on pull request #16244. - Fix erroneus inclusion of src/llvm in older commit.
2014-08-09auto merge of #16314 : Ryman/rust/ringbuf_non_pow2, r=huonwbors-3/+44
See test for details.
2014-08-08auto merge of #16325 : froydnj/rust/vec-grammar-fix, r=alexcrichtonbors-1/+1
Just a small typo noticed while reading through documentation.
2014-08-08auto merge of #16279 : nham/rust/fix_slice_docs, r=alexcrichtonbors-48/+35
This does a few things: - remove references to ~[] and the OwnedVector trait, which are both obsolete - correct the docs to say that this is the slice module, not the vec module - add a sentence pointing out that vectors are distinct from Vec - remove documentation on Vec. closes #15459
2014-08-07Cleanup collections::slice documentation.nham-48/+35
This does a few things: - remove references to ~[] and the OwnedVector trait, which are both obsolete - correct the docs to say that this is the slice module, not the vec module - add a sentence pointing out that vectors are distinct from Vec - remove documentation on Vec. closes #15459
2014-08-07fix grammar in Vec.retain's doc commentNathan Froyd-1/+1
2014-08-07libcollections: Fix RingBuf growth for non-power-of-two capacitiesKevin Butler-3/+44