about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-06-13Rollup merge of #42496 - Razaekel:feature/integer_max-min, r=BurntSushiCorey Farwell-2/+53
Add max and min to Ord Pursuant to issue #25663, this PR adds max and min methods with default implementations to std::cmp::Ord. It also modifies std::cmp::max|min to internally alias to Ord::max|min, so that any overrides of the default implementations are automatically used by std::cmp::max|min. Closes #25663
2017-06-13Rollup merge of #42428 - scottmcm:str-get-overflow, r=sfacklerCorey Farwell-41/+30
Add overflow checking for `str::get` with inclusive ranges Fixes https://github.com/rust-lang/rust/issues/42401 Two commits here: 1. The first makes `str::index` just call `SliceIndex<str>::index`. It's intended to have no behavior change, except where the two methods were inconsistent. 2. The second actually adds the overflow checking to `get(_mut)` (and tests for it)
2017-06-13Change the for-loop desugar so the `break` does not affect type inference. ↵John Kåre Alsaker-2/+4
Fixes #42618
2017-06-13Removing tabs. Sorry - have updated my .vimrcGiles Cope-2/+2
2017-06-13Ignore some failing test on wasm32-unknown-emscriptenMarco A L Barbosa-0/+8
See #42629 and #42630.
2017-06-13Updated tests and fixed inconsistent message on assert_eqGiles Cope-8/+10
2017-06-13updated assert_eq test, fixed incorrect assert_ne message and added test.Giles Cope-8/+12
2017-06-12Auto merge of #42570 - birkenfeld:patch-3, r=frewsxcvbors-1/+21
Add dedicated docstrings to Sum/Product impl of Result (and fix a minor grammar typo below)
2017-06-12Add dedicated docstrings to Sum/Product impl of ResultGeorg Brandl-1/+21
(and fix a minor grammar typo below)
2017-06-11Auto merge of #42155 - seanmonstar:unimplemented, r=sfacklerbors-1/+2
core: allow messages in unimplemented!() macro This makes `unimplemented!()` match `unreachable!()`, allowing a message and possible formatting to be provided to better explain what and/or why something is not implemented. I've used this myself in hyper for a while, include the type and method name, to better help while prototyping new modules, like `unimplemented!("Conn::poll_complete")`, or `unimplemented!("Conn::poll; state={:?}", state)`.
2017-06-11Auto merge of #40454 - djzin:fast-swap, r=sfacklerbors-13/+54
speed up mem::swap I would have thought that the mem::swap code didn't need an intermediate variable precisely because the pointers are guaranteed never to alias. And.. it doesn't! It seems that llvm will also auto-vectorize this case for large structs, but alas it doesn't seem to have all the aliasing info it needs and so will add redundant checks (and even not bother with autovectorizing for small types). Looks like a lot of performance could still be gained here, so this might be a good test case for future optimizer improvements. Here are the current benchmarks for the simd version of mem::swap; the timings are in cycles (code below) measured with 10 iterations. The timings for sizes > 32 which are not a multiple of 8 tend to be ever so slightly faster in the old code, but not always. For large struct sizes (> 1024) the new code shows a marked improvement. \* = latest commit † = subtracted from other measurements | arr_length | noop<sup>†</sup> | rust_stdlib | simd_u64x4\* | simd_u64x8 |------------------|------------|-------------------|-------------------|------------------- 8|80|90|90|90 16|72|177|177|177 24|32|76|76|76 32|68|188|112|188 40|32|80|60|80 48|32|84|56|84 56|32|108|72|108 64|32|108|72|76 72|80|350|220|230 80|80|350|220|230 88|80|420|270|270 96|80|420|270|270 104|80|500|320|320 112|80|490|320|320 120|72|528|342|342 128|48|360|234|234 136|72|987|387|387 144|80|1070|420|420 152|64|856|376|376 160|68|804|400|400 168|80|1060|520|520 176|80|1070|520|520 184|32|464|228|228 192|32|504|228|228 200|32|440|248|248 208|72|987|573|573 216|80|1464|220|220 224|48|852|450|450 232|72|1182|666|666 240|32|428|288|288 248|32|428|308|308 256|80|860|770|770 264|80|1130|820|820 272|80|1340|820|820 280|80|1220|870|870 288|72|1227|804|804 296|72|1356|849|849
2017-06-11Auto merge of #42569 - birkenfeld:patch-2, r=frewsxcvbors-6/+3
Simplify FromIterator example of Result The previous version may be clearer for newcomers, but this is how you'd write it idiomaticly.
2017-06-10Auto merge of #42556 - scottmcm:ctz-nz, r=BurntSushibors-1/+50
Get LLVM to stop generating dead assembly in next_power_of_two It turns out that LLVM can turn `@llvm.ctlz.i64(_, true)` into `@llvm.ctlz.i64(_, false)` ([`ctlz`](http://llvm.org/docs/LangRef.html#llvm-ctlz-intrinsic)) where valuable, but never does the opposite. That leads to some silly assembly getting generated in certain cases. A contrived-but-clear example https://is.gd/VAIKuC: ```rust fn foo(x:u64) -> u32 { if x == 0 { return !0; } x.leading_zeros() } ``` Generates ```asm testq %rdi, %rdi je .LBB0_1 je .LBB0_3 ; <-- wha? bsrq %rdi, %rax xorq $63, %rax retq .LBB0_1: movl $-1, %eax retq .LBB0_3: movl $64, %eax ; <-- dead retq ``` I noticed this in `next_power_of_two`, which without this PR generates the following: ```asm cmpq $2, %rcx jae .LBB1_2 movl $1, %eax retq .LBB1_2: decq %rcx je .LBB1_3 bsrq %rcx, %rcx xorq $63, %rcx jmp .LBB1_5 .LBB1_3: movl $64, %ecx ; <-- dead .LBB1_5: movq $-1, %rax shrq %cl, %rax incq %rax retq ``` And with this PR becomes ```asm cmpq $2, %rcx jae .LBB0_2 movl $1, %eax retq .LBB0_2: decq %rcx bsrq %rcx, %rcx xorl $63, %ecx movq $-1, %rax shrq %cl, %rax incq %rax retq ```
2017-06-09Move Drop to module.Clar Charr-90/+103
2017-06-09Move CoerceUnsized to module.Clar Charr-69/+82
2017-06-09Move Index to module.Clar Charr-149/+162
2017-06-09Move Deref to module.Clar Charr-110/+123
2017-06-09Move Try to module.Clar Charr-102/+118
2017-06-09Move placement new operators to module.Clar Charr-119/+130
2017-06-09Move bit ops to module.Clar Charr-830/+846
2017-06-09Move arithmetic ops to module.Clar Charr-864/+880
2017-06-09Move Fn to module.Clar Charr-185/+198
2017-06-09Simplify FromIterator example of ResultGeorg Brandl-6/+3
2017-06-09hack around bug in emscriptenDjzin-1/+3
2017-06-08Use ctlz_nonzero to improve ASM from next_power_of_twoScott McMurray-1/+16
2017-06-08Add ctlz_nonzero & cttz_nonzero intrinsicsScott McMurray-0/+34
LLVM currently doesn't remove the "bypass if argument is zero" assembly inside branches where the value is known to be non-zero, pessimizing code that uses uN::leading_zeros
2017-06-08doc: a more complete explanation, and a better exampleTshepang Lekhonkhobe-5/+5
2017-06-08Assert failure message easier to readSquirrel-4/+6
By having the left and right strings above and below on the same line it helps spot the difference between the two. E.g. thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)` left: `"-aandb--S123.html"` right: `"-aandb-S123.html"`', When the strings are both on the same line it take a lot longer to spot the difference. It is a small change but the small time savings add up with repetition. This helps Rust be an excellent language to write tests in.
2017-06-08Auto merge of #42522 - frewsxcv:rollup, r=frewsxcvbors-1/+1
Rollup of 5 pull requests - Successful merges: #42470, #42490, #42497, #42510, #42512 - Failed merges:
2017-06-07Move Range to module.Clar Charr-356/+374
2017-06-07Move ops.rs to folder.Clar Charr-0/+0
2017-06-08Auto merge of #40706 - irfanhudda:doc-next-power-of-two, r=alexcrichtonbors-11/+27
Improve documentation of next_power_of_two Clarify overflow behavior of `next_power_of_two`. Related Issue: #18604
2017-06-07core: allow messages in unimplemented!() macroSean McArthur-1/+2
2017-06-07Update docs to say iterator instead of rangeMatt Brubeck-1/+1
2017-06-06Alias std::cmp::max/min to Ord::max/minNick Whitney-2/+6
2017-06-06Add max and min default fns to Ord traitNick Whitney-0/+47
Pursuant to issue #25663, this commit adds the max and min functions to the Ord trait, enabling items that implement Ord to use UFCS (ex. 1.max(2)) instead of the longer std::cmp::max(1,2) format.
2017-06-06Rollup merge of #42469 - citizen428:document-assert-macros, r=steveklabnikCorey Farwell-5/+13
Doc changes for assert macros See #29381
2017-06-05Doc changes for assert macrosMichael Kohl-5/+13
See #29381
2017-06-05doc rewordingking6cong-1/+1
2017-06-04Add overflow checking for str::get with inclusive rangesScott McMurray-4/+12
Fixes #42401
2017-06-04Delegate str:Index(Mut) to SliceIndex<str>Scott McMurray-37/+18
Move any extra logic that the former had into the latter, so they're consistent.
2017-06-04Auto merge of #42265 - Zoxc:for-sugar, r=eddybbors-3/+4
Change for-loop desugar to not borrow the iterator during the loop This is enables the use of suspend points inside for-loops in movable generators. This is illegal in the current desugaring as `iter` is borrowed across the body.
2017-06-02Rollup merge of #42310 - scottmcm:deprecate-range-stepby, r=alexcrichtonMark Simulacrum-13/+42
Deprecate range-specific `step_by` Deprecation attributes and test updates only. Was replaced by an any-iterator version in https://github.com/rust-lang/rust/pull/41439 Last follow-up (this release) to https://github.com/rust-lang/rust/pull/42110#issuecomment-303210138 r? @alexcrichton
2017-06-02Auto merge of #41670 - scottmcm:slice-rotate, r=alexcrichtonbors-0/+143
Add an in-place rotate method for slices to libcore A helpful primitive for moving chunks of data around inside a slice. For example, if you have a range selected and are drag-and-dropping it somewhere else (Example from [Sean Parent's talk](https://youtu.be/qH6sSOr-yk8?t=560)). (If this should be an RFC instead of a PR, please let me know.) Edit: changed example
2017-06-02Auto merge of #41418 - hirschenberger:prefetch-intrinsic, r=nagisabors-0/+47
Adding support for the llvm `prefetch` intrinsic Optimize `slice::binary_search` by using prefetching.
2017-06-01Change for-loop desugar to not borrow the iterator during the loopJohn Kåre Alsaker-3/+4
2017-06-01Adding support for the llvm `prefetch` intrinsicFalco Hirschenberger-0/+47
Related to #37251
2017-05-31Avoid range::step_by in another testScott McMurray-2/+2
2017-05-31Deprecate iter::range::StepByScott McMurray-0/+15
Only exposed as DeprecatedStepBy (as of PR 41439)
2017-05-31Deprecate Range*::step_byScott McMurray-13/+27
Changed all the tests except test_range_step to use Iterator::step_by.