about summary refs log tree commit diff
path: root/src/libcore/tests/slice.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1751/+0
2020-07-19Fix panic message when `RangeFrom` index is out of boundsLukas Kalbertodt-1/+1
Before, the `Range` method was called with `end = slice.len()`. Unfortunately, because `Range::index` first checks the order of the indices (start has to be smaller than end), an out of bounds index leads to `core::slice::slice_index_order_fail` being called. This prints the message 'slice index starts at 27 but ends at 10', which is worse than 'index 27 out of range for slice of length 10'. This is not only useful to normal users reading panic messages, but also for people inspecting assembly and being confused by `slice_index_order_fail` calls.
2020-06-22add: testsVillSnow-0/+40
2020-06-10Migrate to numeric associated constsLzu Tao-2/+2
2020-04-23libcore: more compact way to adjust test sizes for MiriRalf Jung-9/+3
2020-04-06Use integer assoc consts in libcoreLinus Färnstrand-2/+2
2020-04-06Use assoc float consts in libcoreLinus Färnstrand-1/+1
2020-02-29fix aliasing violation in align_to_mutRalf Jung-0/+12
2019-12-09Rollup merge of #67119 - RalfJung:miri-test-libstd, r=alexcrichtonTyler Mandry-4/+4
libstd miri tests: avoid warnings Ignore tests in a way that all the code still gets compiled, to get rid of all the "unused" warnings that otherwise show up when running the test suite in Miri.
2019-12-07libcore: ignore tests in Miri instead of removing them entirelyRalf Jung-4/+4
2019-12-06Format libcore with rustfmt (including tests and benches)David Tolnay-42/+69
2019-08-20Rollup merge of #63265 - JohnTitor:implement-nth-back-for-chunksexactmut, ↵Mazdak Farrokhzad-0/+19
r=scottmcm Implement `nth_back` for ChunksExactMut This is a part of #54054. r? @scottmcm
2019-08-09Rollup merge of #63407 - RalfJung:miri-test-sizes, r=CentrilMazdak Farrokhzad-1/+1
reduce some test sizes in Miri
2019-08-09Rollup merge of #63403 - sntdevco:master, r=CentrilMazdak Farrokhzad-8/+8
Improve test output I'm continuing to improve the test output for liballoc and libcore
2019-08-09explain Miri disablingRalf Jung-1/+1
2019-08-09Merge pull request #1 from rust-lang/masterSayan Nandan-14/+291
Merge recent changes into master
2019-08-09Improve tests for libcore/sliceSayan Nandan-8/+8
2019-08-09Auto merge of #61937 - AaronKutch:master, r=scottmcmbors-0/+38
Improve `ptr_rotate` performance, tests, and benches The corresponding issue is #61784. I am not actually sure if miri can handle the test, but I can change the commit if necessary.
2019-08-06Improve `ptr_rotate` performance, tests, and benchmarksAaron Kutch-0/+38
2019-08-05Implement nth_back for ChunksExactMutYuki Okushi-0/+19
2019-08-04bump libcore tests to rand 0.7Ralf Jung-5/+5
2019-07-28Rollup merge of #62074 - wizAmit:feature/mut_chunks_nth_back, r=scottmcmMazdak Farrokhzad-0/+22
squash of all commits for nth_back on ChunksMut wip nth_back for chunks_mut working chunksmut fixed nth_back for chunksmut Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com> r? @timvermeulen r? @scottmcm
2019-07-04Rollup merge of #62346 - RalfJung:miri-tests, r=CentrilMazdak Farrokhzad-2/+2
enable a few more tests in Miri and update the comment for others
2019-07-03enable a few more tests in Miri and update the comment for othersRalf Jung-2/+2
2019-06-23squash of all commits for nth_back on ChunksMut@amit.chandra-0/+22
wip nth_back for chunks_mut working chunksmut fixed nth_back for chunksmut Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-06-23squash commit for nth_back on chunks exact@amit.chandra-0/+19
wip nth_back for chunks_exact working nth_back for chunks exact Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-06-20Rollup merge of #60772 - timvermeulen:slice_iter_nth_back, r=scottmcmMazdak Farrokhzad-0/+13
Implement nth_back for slice::{Iter, IterMut} Part of #54054. I implemented `nth_back` as straightforwardly as I could, and then slightly changed `nth` to match `nth_back`. I believe I did so correctly, but please double-check 🙂 I also added the helper methods `zst_shrink`, `next_unchecked`, and `next_back_unchecked` to get rid of some duplicated code. These changes hopefully make this code easier to understand for new contributors like me. I noticed the `is_empty!` and `len!` macros which sole purpose seems to be inlining, according to the comment right above them, but the `is_empty` and `len` methods are already marked with `#[inline(always)]`. Does that mean we could replace these macros with method calls, without affecting anything? I'd love to get rid of them.
2019-06-04Update src/libcore/tests/slice.rskennytm-1/+1
Co-Authored-By: Jack O'Connor <oconnor663@gmail.com>
2019-06-02copy_within: replace element access by pointer arithmetic to avoid UBkennytm-0/+14
This ensures we won't accidentally read *src or *dest even when count = 0.
2019-05-29Rollup merge of #61048 - wizAmit:feature/nth_back_chunks, r=scottmcmMazdak Farrokhzad-0/+24
Feature/nth back chunks A succinct implementation for nth_back on chunks. Thank you @timvermeulen for the guidance. r? @timvermeulen
2019-05-25Implement nth_back for slice::{Iter, IterMut}Tim Vermeulen-0/+13
2019-05-14new implementation for nth_back for chunkswizAmit-1/+5
2019-05-14hopefully working nth_back on chunks@amit.chandra-1/+8
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14wip nth_back on chunks@amit.chandra-0/+13
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-05Implement nth_back for RChunks(Exact)(Mut)Tim Vermeulen-0/+52
2019-04-17test sort_unstable in MiriRalf Jung-3/+12
2019-04-16Miri now supports entropy, but is still slowRalf Jung-2/+2
2019-04-03Rollup merge of #55448 - Mokosha:SortAtIndex, r=blussMazdak Farrokhzad-0/+118
Add 'partition_at_index/_by/_by_key' for slices. This is an analog to C++'s std::nth_element (a.k.a. quickselect). Corresponds to tracking bug #55300.
2019-03-24Rollup merge of #59328 - koalatux:iter-nth-back, r=scottmcmkennytm-0/+13
Implement specialized nth_back() for Box and Windows. Hi there, this is my first pull request to rust :-) I started implementing some specializations for DoubleEndedIterator::nth_back() and these are the first two. The problem has been discussed in #54054 and nth_back() is tracked in #56995. I'm stuck with the next implementation so I though I do a PR for the ones I'm confident with to get some feedback.
2019-03-11Add initial implementation of 'sort_at_index' for slices -- analog to C++'s ↵Pavel Krajcevski-0/+118
std::nth_element (a.k.a. quickselect) Add some more notes to the documentation: - Mention that the median can be found if we used `len() / 2`. - Mention that this function is usually called "kth element" in other libraries. Address some comments in PR: - Change wording on some of the documentation - Change recursive function into a loop Update name to `partition_at_index` and add convenience return values. Address reviewer comments: - Don't swap on each iteration when searching for min/max element. - Add some docs about when we panic. - Test that the sum of the lengths of the output matches the length of the input. - Style fix for for-loop. Address more reviewer comments Fix Rng stuff for test Fix doc test build Don't run the partition_at_index test on wasm targets Miri does not support entropy for test partition_at_index
2019-03-10we can now skip should_panic tests with the libtest harnessRalf Jung-7/+0
2019-02-24implement nth_back for WindowsAdrian Friedli-0/+13
2019-02-13review or fix miri failures in iter, slice, cell, timeRalf Jung-5/+3
2019-02-13mark failures expected due to panicsRalf Jung-7/+7
2019-02-07disable tests in MiriRalf Jung-0/+12
2019-01-17Add is_sorted impl for [T]Kevin Leimkuhler-0/+15
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-3/+3
Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from #52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-10-18Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()Sebastian Dröge-0/+222
These work exactly like the normal chunks iterators but start creating chunks from the end of the slice. See #55177 for the tracking issue
2018-09-25Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichtonPietro Albini-29/+29
Rename slice::exact_chunks() to slice::chunks_exact() See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547