Commit Graph

81 Commits

Author SHA1 Message Date
Ralf Jung
f1c30519f3 libcore: more compact way to adjust test sizes for Miri 2020-04-23 19:50:24 +02:00
Linus Färnstrand
3e4396b8b5 Use integer assoc consts in libcore 2020-04-06 23:08:12 +02:00
Linus Färnstrand
cf1c7edd2d Use assoc float consts in libcore 2020-04-06 22:44:51 +02:00
Ralf Jung
c34451ffb7 fix aliasing violation in align_to_mut 2020-02-29 14:53:20 +01:00
Tyler Mandry
e775820088
Rollup merge of #67119 - RalfJung:miri-test-libstd, r=alexcrichton
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-09 14:33:06 -08:00
Ralf Jung
7ba1232b5e libcore: ignore tests in Miri instead of removing them entirely 2019-12-07 12:38:13 +01:00
David Tolnay
c737169fe5
Format libcore with rustfmt (including tests and benches) 2019-12-06 20:20:51 -08:00
Mazdak Farrokhzad
60649e3a2e
Rollup merge of #63265 - JohnTitor:implement-nth-back-for-chunksexactmut, r=scottmcm
Implement `nth_back` for ChunksExactMut

This is a part of #54054.

r? @scottmcm
2019-08-20 16:26:37 +02:00
Mazdak Farrokhzad
4e3c209b67
Rollup merge of #63407 - RalfJung:miri-test-sizes, r=Centril
reduce some test sizes in Miri
2019-08-09 14:07:35 +02:00
Mazdak Farrokhzad
171e8457d0
Rollup merge of #63403 - sntdevco:master, r=Centril
Improve test output

I'm continuing to improve the test output for liballoc and libcore
2019-08-09 14:07:32 +02:00
Ralf Jung
78caca00d7 explain Miri disabling 2019-08-09 13:55:22 +02:00
Sayan Nandan
fb3a01354f
Merge pull request #1 from rust-lang/master
Merge recent changes into master
2019-08-09 13:01:05 +05:30
Sayan Nandan
623debfe9d
Improve tests for libcore/slice 2019-08-09 12:51:34 +05:30
bors
d8f8be4636 Auto merge of #61937 - AaronKutch:master, r=scottmcm
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-09 04:41:20 +00:00
Aaron Kutch
ad7fdb6859 Improve ptr_rotate performance, tests, and benchmarks 2019-08-06 10:42:48 -05:00
Yuki Okushi
d3019d16b9 Implement nth_back for ChunksExactMut 2019-08-05 02:44:08 +09:00
Ralf Jung
0cb16f7d5e bump libcore tests to rand 0.7 2019-08-04 14:50:32 +02:00
Mazdak Farrokhzad
cb8b491a65
Rollup merge of #62074 - wizAmit:feature/mut_chunks_nth_back, r=scottmcm
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-28 03:01:44 +02:00
Mazdak Farrokhzad
144ed029c5
Rollup merge of #62346 - RalfJung:miri-tests, r=Centril
enable a few more tests in Miri and update the comment for others
2019-07-04 01:39:02 +02:00
Ralf Jung
4dd5edc76d enable a few more tests in Miri and update the comment for others 2019-07-03 19:58:59 +02:00
@amit.chandra
b95bde4491 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>
2019-06-23 12:45:59 +05:30
@amit.chandra
45832383af squash commit for nth_back on chunks exact
wip nth_back for chunks_exact

working nth_back for chunks exact

Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-06-23 02:02:21 +05:30
Mazdak Farrokhzad
2e7e131b8e
Rollup merge of #60772 - timvermeulen:slice_iter_nth_back, r=scottmcm
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-20 08:36:00 +02:00
kennytm
427f1a49f6
Update src/libcore/tests/slice.rs
Co-Authored-By: Jack O'Connor <oconnor663@gmail.com>
2019-06-04 00:27:28 +08:00
kennytm
aac9bc5ffa
copy_within: replace element access by pointer arithmetic to avoid UB
This ensures we won't accidentally read *src or *dest even when count = 0.
2019-06-02 23:30:18 +08:00
Mazdak Farrokhzad
f0ea975a1c
Rollup merge of #61048 - wizAmit:feature/nth_back_chunks, r=scottmcm
Feature/nth back chunks

A succinct implementation for nth_back on chunks. Thank you @timvermeulen for the guidance.

r? @timvermeulen
2019-05-29 08:15:55 +02:00
Tim Vermeulen
97a6c932e0 Implement nth_back for slice::{Iter, IterMut} 2019-05-25 01:47:24 +02:00
wizAmit
16223e4bea new implementation for nth_back for chunks 2019-05-14 13:28:43 +05:30
@amit.chandra
aff83c80dd hopefully working nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14 12:26:25 +05:30
@amit.chandra
02a148dba2 wip nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14 12:26:25 +05:30
Tim Vermeulen
5eb0e08d0f Implement nth_back for RChunks(Exact)(Mut) 2019-05-05 11:21:30 +02:00
Ralf Jung
d55e4b7a25 test sort_unstable in Miri 2019-04-17 09:47:36 +02:00
Ralf Jung
9b21324db2 Miri now supports entropy, but is still slow 2019-04-16 20:04:17 +02:00
Mazdak Farrokhzad
2f37c5a358
Rollup merge of #55448 - Mokosha:SortAtIndex, r=bluss
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-04-03 04:36:09 +02:00
kennytm
cb2dde63d5
Rollup merge of #59328 - koalatux:iter-nth-back, r=scottmcm
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-24 19:00:10 +08:00
Pavel Krajcevski
3f306db3db Add initial implementation of 'sort_at_index' for slices -- analog to C++'s 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-11 10:31:21 -07:00
Ralf Jung
4888b1fb99 we can now skip should_panic tests with the libtest harness 2019-03-10 17:47:42 +01:00
Adrian Friedli
739ba0417a
implement nth_back for Windows 2019-02-24 00:28:04 +01:00
Ralf Jung
7f5dc49214 review or fix miri failures in iter, slice, cell, time 2019-02-13 17:56:43 +01:00
Ralf Jung
26ade1cfaa mark failures expected due to panics 2019-02-13 17:56:43 +01:00
Ralf Jung
81613ad7cf disable tests in Miri 2019-02-07 18:24:10 +01:00
Kevin Leimkuhler
02477f6f99 Add is_sorted impl for [T] 2019-01-17 22:34:43 -08:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alex Crichton
4c21a3bc2a std: Depend directly on crates.io crates
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]: 28ee12db81
2018-12-11 21:08:22 -08:00
Sebastian Dröge
80a8e5c1f7 Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()
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-10-18 10:38:05 +03:00
Pietro Albini
6a0f45b3f4
Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichton
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
2018-09-25 22:34:47 +02:00
Sebastian Dröge
e09e45041b 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
2018-09-24 22:43:06 +03:00
Clément Renault
78bccb3540 Introduce the partition_dedup/by/by_key methods for slices 2018-09-23 09:09:54 +02:00
Jack O'Connor
d0e59f563d add tests for copy_within 2018-09-20 02:35:32 -04:00
Mark Rousskov
9ec5ef541a Breaking change upgrades 2018-09-04 13:22:08 -06:00