about summary refs log tree commit diff
path: root/src/libcore/tests
AgeCommit message (Collapse)AuthorLines
2019-01-17Add is_sorted impl for [T]Kevin Leimkuhler-0/+15
2019-01-17Add initial impl of is_sorted to IteratorKevin Leimkuhler-0/+14
2019-01-17Add signed num::NonZeroI* typesSimon Sapin-1/+9
Multiple people have asked for them, in https://github.com/rust-lang/rust/issues/49137. Given that the unsigned ones already exist, they are very easy to add and not an additional maintenance burden.
2019-01-14Remove unnecessary mutStjepan Glavina-1/+1
2019-01-14Fix failing testStjepan Glavina-6/+7
2019-01-13Add core::iter::once_withStjepan Glavina-0/+18
2018-12-26Auto merge of #56534 - xfix:copied, r=@SimonSapinbors-0/+40
Add unstable Iterator::copied() Initially suggested at https://github.com/bluss/rust-itertools/pull/289, however the maintainers of itertools suggested this may be better of in a standard library. The intent of `copied` is to avoid accidentally cloning iterator elements after doing a code refactoring which causes a structure to be no longer `Copy`. This is a relatively common pattern, as it can be seen by calling `rg --pcre2 '[.]map[(][|](?:(\w+)[|] [*]\1|&(\w+)[|] \2)[)]'` on Rust main repository. Additionally, many uses of `cloned` actually want to simply `Copy`, and changing something to be no longer copyable may introduce unnoticeable performance penalty. Also, this makes sense because the standard library includes `[T].copy_from_slice` to pair with `[T].clone_from_slice`. This also adds `Option::copied`, because it makes sense to pair it with `Iterator::copied`. I don't think this feature is particularly important, but it makes sense to update `Option` along with `Iterator` for consistency.
2018-12-25Remove licensesMark Rousskov-499/+0
2018-12-23Merge branch 'master' into copiedKonrad Borowski-23/+79
2018-12-23Rollup merge of #56936 - ubsan:euclidean_div_rem, r=dtolnaykennytm-15/+15
rename div_euc -> div_euclid, and mod_euc -> rem_euclid logic is written up in #49048 Also, update the documentation slightly. cc @alexcrichton @clarcharr @varkor
2018-12-20Add DoubleEndedIterator::nth_backClar Fon-0/+28
2018-12-17fix testsNicole Mazzuca-2/+2
2018-12-17rename div_euc -> div_euclid, and mod_euc -> rem_euclidNicole Mazzuca-15/+15
logic is written up in https://github.com/rust-lang/rust/issues/49048 Also, update the documentation slightly
2018-12-17Remove `<Cycle as Iterator>::try_fold` overrideShotaro Yamada-0/+2
It was a incorrect optimization.
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-6/+13
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-12-09Auto merge of #56630 - sinkuu:core_iter, r=kennytmbors-0/+2
Resolve FIXME in libcore/iter/mod.rs and makes a few improvements.
2018-12-09Override Cycle::try_foldShotaro Yamada-0/+2
name old ns/iter new ns/iter diff ns/iter diff % speedup iter::bench_cycle_take_ref_sum 927,152 927,194 42 0.00% x 1.00 iter::bench_cycle_take_sum 938,129 603,492 -334,637 -35.67% x 1.55
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-12-05Add a test for cloned side effectsKonrad Borowski-0/+17
2018-12-05Add tests for Iterator::copied()Konrad Borowski-0/+18
2018-12-05Add tests for Option::copied()Konrad Borowski-0/+22
2018-11-20Add std::iter::successorsSimon Sapin-0/+12
2018-11-20Auto merge of #56049 - newpavlov:revert_51601, r=sfacklerbors-0/+7
Revert #51601 Closes: #55985 Specialization of `StepBy<Range(Inclusive)>` results in an incorrectly behaving code when `step_by` is combined with `skip` or `nth`. If this will get merged we probably should reopen issues previously closed by #51601 (if there was any).
2018-11-19fix testАртём Павлов [Artyom Pavlov]-1/+1
2018-11-18testsАртём Павлов [Artyom Pavlov]-0/+10
2018-11-18revertАртём Павлов [Artyom Pavlov]-5/+2
2018-11-14core/tests/num: Simplify `test_int_from_str_overflow()` test codeTobias Bieniek-16/+8
This commit changes the test code to compare against easier-to-read, static values instead of relying on the result of `wrapping_add()` which may or may not result in the value that we expect.
2018-10-31Bump nightly to 1.32.0Alex Crichton-1/+0
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-19Stabilize impl_header_lifetime_elision in 2015Scott McMurray-1/+1
It's already stable in 2018; this finishes the stabilization.
2018-10-18Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()Sebastian Dröge-1/+0
Fixes #55177
2018-10-18Stabilize slice::chunks_exact() and slice::chunks_exact_mut()Sebastian Dröge-1/+0
Fixes #47115
2018-10-18Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()Sebastian Dröge-0/+223
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-08Stabilize the `Option::replace` methodClément Renault-1/+0
2018-09-29Activate the feature in the libcore tests tooScott McMurray-0/+1
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-1/+1
2018-09-29Auto merge of #54240 - csmoe:nonzero_from, r=alexcrichtonbors-0/+7
Impl From<NonZero<T>> for T Closes https://github.com/rust-lang/rust/issues/54171 r? @SimonSapin
2018-09-25Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichtonPietro Albini-30/+30
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-24Rename slice::exact_chunks() to slice::chunks_exact()Sebastian Dröge-30/+30
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-23Introduce the partition_dedup/by/by_key methods for slicesClément Renault-0/+60
2018-09-20add tests for copy_withinJack O'Connor-0/+47
2018-09-17move from_nonzero test from run-pass to libcorecsmoe-0/+7
2018-09-16Auto merge of #53754 - RalfJung:slice_align_to, r=alexcrichtonbors-1/+0
stabilize slice_align_to This is very hard to implement correctly, and leads to [serious bugs](https://github.com/llogiq/bytecount/pull/42) when done incorrectly. Moreover, this is needed to be able to run code that opportunistically exploits alignment on miri. So code using `align_to`/`align_to_mut` gets the benefit of a well-tested implementation *and* of being able to run in miri to test for (some kinds of) UB. This PR also clarifies the guarantee wrt. the middle part being as long as possible. Should the docs say under which circumstances the middle part could be shorter? Currently, that can only happen when running in miri.
2018-09-04Breaking change upgradesMark Rousskov-10/+10
2018-08-28stabilize slice_align_toRalf Jung-1/+0
2018-08-25Auto merge of #53385 - matklad:stabilize-find-map, r=KodrAusbors-1/+0
Stablize Iterator::find_map Stabilization PR for https://github.com/rust-lang/rust/issues/49602
2018-08-19Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichtonbors-0/+14
debug_assert to ensure that from_raw_parts is only used properly aligned This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all. I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline? EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
2018-08-15Stablize Iterator::find_mapAleksey Kladov-1/+0
2018-08-14Auto merge of #53033 - RalfJung:manually_dro, r=SimonSapinbors-0/+5
unsized ManuallyDrop I think this matches what @eddyb had in https://github.com/rust-lang/rust/pull/52711 originally. ~~However, I have never added a `CoerceUnsized` before so I am not sure if I did this right. I copied the `unstable` attribute on the `impl` from elsewhere, but AFAIK it is useless because `impl`'s are insta-stable... so shouldn't this rather say "stable since 1.30"?~~ This is insta-stable and hence requires FCP, at least. Fixes https://github.com/rust-lang/rust/issues/47034
2018-08-06unconfuse @eddybRalf Jung-1/+2
2018-08-05Fix 2018 edition testsvarkor-1/+0