about summary refs log tree commit diff
path: root/src/libcore/tests
AgeCommit message (Collapse)AuthorLines
2019-02-23Rollup merge of #58122 - matthieu-m:range_incl_perf, r=dtolnayMazdak Farrokhzad-3/+21
RangeInclusive internal iteration performance improvement. Specialize `Iterator::try_fold` and `DoubleEndedIterator::try_rfold` to improve code generation in all internal iteration scenarios. This changes brings the performance of internal iteration with `RangeInclusive` on par with the performance of iteration with `Range`: - Single conditional jump in hot loop, - Unrolling and vectorization, - And even Closed Form substitution. Unfortunately, it only applies to internal iteration. Despite various attempts at stream-lining the implementation of `next` and `next_back`, LLVM has stubbornly refused to optimize external iteration appropriately, leaving me with a choice between: - The current implementation, for which Closed Form substitution is performed, but which uses 2 conditional jumps in the hot loop when optimization fail. - An implementation using a `is_done` boolean, which uses 1 conditional jump in the hot loop when optimization fail, allowing unrolling and vectorization, but for which Closed Form substitution fails. In the absence of any conclusive evidence as to which usecase matters most, and with no assurance that the lack of Closed Form substitution is not indicative of other optimizations being foiled, there is no way to pick one implementation over the other, and thus I defer to the statu quo as far as `next` and `next_back` are concerned.
2019-02-20Rollup merge of #58576 - SimonSapin:successors, r=Centrilkennytm-1/+0
Stabilize iter::successors and iter::from_fn FCP: https://github.com/rust-lang/rust/issues/58045#issuecomment-464674773, https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234
2019-02-19Stabilize iter::from_fnSimon Sapin-1/+0
FCP: https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234
2019-02-17Remove UB in test_ptr_subtraction testKonrad Borowski-2/+4
2019-02-17Remove UB in test_is_null testKonrad Borowski-3/+2
2019-02-13review failures in btree, stringRalf Jung-1/+0
2019-02-13the formatting issue got fixedRalf Jung-3/+3
2019-02-13review or fix remaining miri failures in libcoreRalf Jung-9/+28
2019-02-13review or fix miri failures in iter, slice, cell, timeRalf Jung-15/+11
2019-02-13mark failures expected due to panicsRalf Jung-15/+15
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-09Fix exhaustion of inclusive range try_fold and try_rfoldMatthieu M-3/+21
2019-02-07disable tests in MiriRalf Jung-0/+38
2019-01-22Auto merge of #57475 - SimonSapin:signed, r=estebankbors-1/+9
Add signed num::NonZeroI* types 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-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