about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-02-14Remove Copy bound from some Cell trait implsRalf Jung-2/+2
Contributes to #39264
2017-02-14Auto merge of #38981 - sdleffler:patch-1, r=alexcrichtonbors-1/+5
Add PartialOrd, Ord derivations to TypeId I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` and `PartialEq`/`Eq` already exist, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2017-02-13Allow more Cell methods for non-Copy typesRalf Jung-60/+60
Contributes to #39264
2017-02-13Fix up linksSteve Klabnik-2/+2
mdbook and rustdoc generate links differently, so we need to change all these links.
2017-02-13Rollup merge of #39716 - F001:swapCell, r=alexcrichtonCorey Farwell-0/+27
Add `swap` method for `Cell` Addition to #39264 r? @alexcrichton
2017-02-12Fix some typos in the core::fmt docs.Ahmed Charles-2/+2
2017-02-12Rollup merge of #39756 - JordiPolo:feature/try_to_question, r=steveklabnikGuillaume Gomez-23/+15
Sustitutes try! for ? in the Result documentation Hopefully newcomers will go strait to use `?`
2017-02-12Auto merge of #39554 - ↵bors-6/+6
zackmdavis:assert_eq_has_a_terrible_error_message_when_given_a_trailing_comma, r=BurntSushi improve error message when two-arg assert_eq! receives a trailing comma Previously, `assert_eq!(left, right,)` (respectively, `assert_ne!(left, right,)`; note the trailing comma) would result in a confusing "requires at least a format string argument" error. In reality, a format string is optional, but the trailing comma puts us into the "match a token tree of zero or more tokens" branch of the macro (in order to support the optional format string), and passing the empty token tree into `format_args!` results in the confusing error. If instead we match a token tree of one or more tokens, we get a much more sensible "unexpected end of macro invocation" error. While we're here, fix up a stray space before a comma in the match guards. Resolves #39369. ----- **Before:** ``` $ rustc scratch.rs error: requires at least a format string argument --> scratch.rs:2:5 | 2 | assert_eq!(1, 2,); | ^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro outside of the current crate error: aborting due to previous error ``` **After:** ``` $ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc scratch.rs error: unexpected end of macro invocation --> scratch.rs:2:20 | 2 | assert_eq!(1, 2,); | ^ ```
2017-02-12Sustitutes try! for ? in the Result documentationJordi Polo-23/+15
2017-02-11Auto merge of #39736 - frewsxcv:rollup, r=frewsxcvbors-2/+5
Rollup of 9 pull requests - Successful merges: #39174, #39660, #39676, #39692, #39701, #39710, #39721, #39724, #39725 - Failed merges:
2017-02-11Add `swap` method for `Cell`Charlie Fan-0/+27
2017-02-10Rollup merge of #39174 - rspeer:iter-nth-doc-fix, r=alexcrichtonCorey Farwell-2/+5
Fix a misleading statement in `Iterator.nth()` The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well. The way I read the documentation, I assumed that `nth(0)` would not discard anything (there are 0 preceding elements, and maybe it just peeks at the start of the iterator somehow), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing.
2017-02-11Auto merge of #39642 - stjepang:specialize-slice-partialord, r=alexcrichtonbors-3/+4
Specialize `PartialOrd<A> for [A] where A: Ord` This way we can call `cmp` instead of `partial_cmp` in the loop, removing some burden of optimizing `Option`s away from the compiler. PR #39538 introduced a regression where sorting slices suddenly became slower, since `slice1.lt(slice2)` was much slower than `slice1.cmp(slice2) == Less`. This problem is now fixed. To verify, I benchmarked this simple program: ```rust fn main() { let mut v = (0..2_000_000).map(|x| x * x * x * 18913515181).map(|x| vec![x, x ^ 3137831591]).collect::<Vec<_>>(); v.sort(); } ``` Before this PR, it would take 0.95 sec, and now it takes 0.58 sec. I also tried changing the `is_less` lambda to use `cmp` and `partial_cmp`. Now all three versions (`lt`, `cmp`, `partial_cmp`) are equally performant for sorting slices - all of them take 0.58 sec on the benchmark. Tangentially, as soon as we get `default impl`, it might be a good idea to implement a blanket default impl for `lt`, `gt`, `le`, `ge` in terms of `cmp` whenever possible. Today, those four functions by default are only implemented in terms of `partial_cmp`. r? @alexcrichton
2017-02-10iterator docs: Move paragraph about discarding; clarify "consumed"Rob Speer-5/+5
2017-02-10Rephrase my proposed edit ("objects" -> "elements")Rob Speer-1/+1
2017-02-10Fix a misleading statement in `Iterator.nth()`Rob Speer-1/+4
The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well. The way I read the documentation, I assumed that `nth(0)` would not discard anything (as there are 0 preceding elements), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing.
2017-02-09name anonymous fn parameters in libcore traitsTrevor Spiteri-22/+22
2017-02-09Rollup merge of #39615 - phungleson:corefloat, r=alexcrichtonCorey Farwell-83/+98
Improve format float * Move float into mod float like in test * Add more tests for f64 f32, lower exp, upper exp, which can come if handy in the future if we want refactor further * Use `assert_eq` for clearer error messages
2017-02-08Remove unnecessary specialization for [u8]Stjepan Glavina-7/+0
2017-02-08Rollup merge of #39561 - phungleson:libcollectionsbench, r=alexcrichtonCorey Farwell-2/+2
Extract collections benchmarks to libcollections/bench Good suggestion from @stjepang https://github.com/rust-lang/rust/issues/39484#issuecomment-277467765 r? @alexcrichton
2017-02-08Simplify by calling SliceOrd::compareStjepan Glavina-15/+1
2017-02-08Specialize `PartialOrd<A> for [A] where A: Ord`Stjepan Glavina-0/+22
This way we can call `cmp` instead of `partial_cmp` in the loop, removing some burden of optimizing `Option`s away from the compiler. PR #39538 introduced a regression where sorting slices suddenly became slower, since `slice1.lt(slice2)` was much slower than `slice1.cmp(slice2) == Less`. This problem is now fixed. To verify, I benchmarked this simple program: ```rust fn main() { let mut v = (0..2_000_000).map(|x| x * x * x * 18913515181).map(|x| vec![x, x ^ 3137831591]).collect::<Vec<_>>(); v.sort(); } ``` Before this PR, it would take 0.95 sec, and now it takes 0.58 sec. I also tried changing the `is_less` lambda to use `cmp` and `partial_cmp`. Now all three versions (`lt`, `cmp`, `partial_cmp`) are equally performant for sorting slices - all of them take 0.58 sec on the benchmark.
2017-02-07Improve fmt floatSon-83/+98
* Move to a separate float mod * Add more tests for f64 f32 lower exp upper exp * Use assert_eq for a clearer error message
2017-02-06improve error message when two-arg assert_eq! receives a trailing commaZack M. Davis-6/+6
Previously, `assert_eq!(left, right,)` (respectively, `assert_ne!(left, right,)`; note the trailing comma) would result in a confusing "requires at least a format string argument" error. In reality, a format string is optional, but the trailing comma puts us into the "match a token tree of zero or more tokens" branch of the macro (in order to support the optional format string), and passing the empty token tree into `format_args!` results in the confusing error. If instead we match a token tree of one or more tokens, we get a much more sensible "unexpected end of macro invocation" error. While we're here, fix up a stray space before a comma in the match guards. Resolves #39369.
2017-02-06Revert "Add 128-bit atomics"Alex Crichton-18/+0
This reverts commit 9903975003276cc42a1ed5f21eee292b7c62c331.
2017-02-06Extract collections benchmarks to libcollections/benchesSon-2/+2
And libcore/benches
2017-02-05Auto merge of #39567 - frewsxcv:rollup, r=frewsxcvbors-4/+664
Rollup of 12 pull requests - Successful merges: #39439, #39472, #39481, #39491, #39501, #39509, #39514, #39519, #39526, #39528, #39530, #39538 - Failed merges:
2017-02-05Rollup merge of #39501 - phungleson:libcorebench, r=alexcrichtonCorey Farwell-4/+664
Extract libcore benchmarks to a separate folder Fix #39484 r? @alexcrichton since you seem to know about this :) Thanks!
2017-02-05Auto merge of #39408 - ollie27:i128_try_from, r=alexcrichtonbors-4/+4
Fix TryFrom for i128/u128 Another case of `as` cast silent truncation being error prone. This also adds a few missing TryFrom tests to libcoretest. cc #33417 cc #35118
2017-02-05Rollup merge of #39477 - jimmycuadra:try-from-parameter-name, r=alexcrichtonCorey Farwell-1/+1
Add a name for the parameter to `TryFrom::try_from`. Although signatures with anonymous parameters may not be deprecated or removed at this point, the team seems to agree that the ability to have an anonymous parameter is unfortunate historical baggage, and that we shouldn't create new code that uses it. Context: https://github.com/rust-lang/rust/issues/33417#issuecomment-276933861
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-37/+59
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-05Rollup merge of #39289 - shahn:option_entry, r=alexcrichtonCorey Farwell-0/+70
Provide Entry-like API for Option This implements #39288. I am wondering whether to use std::intrinsics::unreachable!() here. Both seems fine to me (the second match optimizes away in release mode).
2017-02-05Rollup merge of #39107 - llogiq:branchless_filter_count, r=alexcrichtonCorey Farwell-1/+21
branchless .filter(_).count() I found that the branchless version is only slower if we have little to no branch misses, which usually isn't the case. I notice speedups between -5% (perfect prediction) and 60% (real world data).
2017-02-05Rollup merge of #38959 - Amanieu:atomic128, r=alexcrichtonCorey Farwell-0/+18
Add 128-bit atomics This is currently only supported on AArch64 since that is the only target which unconditionally supports 128-bit atomic operations. cc #35118
2017-02-05Provide Entry-like API for OptionSebastian Hahn-0/+70
This implements #39288. Thanks to @steveklabnik and @oli-obk for their review comments :)
2017-02-04Fix TryFrom for i128/u128Oliver Middleton-4/+4
Another case of `as` cast silent truncation being error prone. This also adds a few missing TryFrom tests to libcoretest.
2017-02-04Auto merge of #39399 - clarcharr:iter_rfind, r=alexcrichtonbors-0/+58
Add Iterator::rfind. I found it weird that `Iterator` has `rpostition` but not `rfind`. This adds that method.
2017-02-04Extract libcore benchmarks to a separate folderSon-4/+664
2017-02-03Auto merge of #39463 - alexcrichton:update-bootstrap, r=alexcrichtonbors-187/+31
Bump version, upgrade bootstrap This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03Bump version, upgrade bootstrapAlex Crichton-187/+31
This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03Merge remote-tracking branch 'upstream/master' into format-with-capacityMichał Krasnoborski-66/+138
2017-02-03Move rfind to DoubleEndedIterator, add tracking issue.Clar Charr-58/+58
2017-02-03Auto merge of #39287 - wesleywiser:move_cell, r=aturonbors-41/+108
Extend Cell to work with non-Copy types I'm not sure that I did this right but all of the tests pass. I also had to move the `new()` function so that `Cell`s with non-`Copy` `T`s could be created. That wasn't in the RFC but I assume it needed to be done?
2017-02-02Add a name for the parameter to `TryFrom::try_from`.Jimmy Cuadra-1/+1
Although signatures with anonymous parameters may not be deprecated or removed at this point, the team seems to agree that the ability to have an anonymous parameter is unfortunate historical baggage, and that we shouldn't create new code that uses it. Context: https://github.com/rust-lang/rust/issues/33417#issuecomment-276933861
2017-02-01Update cell docsWesley Wiser-5/+13
2017-02-02remove the wrapping arithmeticsMichał Krasnoborski-10/+5
2017-02-01Adjust heuristics to better handle "{}..." format strings.Michał Krasnoborski-9/+12
2017-01-30Auto merge of #39407 - GuillaumeGomez:convert_module, r=frewsxcvbors-10/+18
Add missing url in convert module r? @frewsxcv
2017-01-30Auto merge of #39405 - tshepang:nits, r=sfacklerbors-3/+3
doc: minor Option improvements
2017-01-30doc: minor Option improvementsTshepang Lekhonkhobe-3/+3