about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-05-19Auto merge of #41439 - ivandardi:master, r=BurntSushibors-3/+99
Stabilize step_by by adding it to Iterator (issue #27741) Inspired by itertools' `take()` method. See issue #27741
2017-05-19Try to optimise char patternsSimonas Kazlauskas-1/+27
2017-05-18core: fix unused_macro warningJorge Aparicio-0/+1
when compiling the crate for a target with max-atomic-width = 0 fixes #42097
2017-05-16Auto merge of #41907 - est31:macro_unused, r=jseyfriedbors-0/+2
Add lint for unused macros Addresses parts of #34938, to add a lint for unused macros. We now output warnings by default when we encounter a macro that we didn't use for expansion. Issues to be resolved before this PR is ready for merge: - [x] fix the NodeId issue described above - [x] remove all unused macros from rustc and the libraries or set `#[allow(unused_macros)]` next to them if they should be kept for some reason. This is needed for successful boostrap and bors to accept the PR. -> #41934 - [x] ~~implement the full extent of #34938, that means the macro match arm checking as well.~~ *let's not do this for now*
2017-05-15Update documentationIvan Dardi-2/+1
2017-05-15Remove `FusedIterator` implementation of `iter::Scan`Tobias Bucher-4/+0
Fixes #41964. This is a breaking change.
2017-05-15Auto merge of #41859 - froydnj:align-float-parts, r=sfacklerbors-12/+12
fix confusion about parts required for float formatting The documentation for flt2dec doesn't match up with the actual implementation, so fix the documentation to align with reality. Presumably due to the mismatch, the formatting code for floats in std::fmt can use correspondingly shorter arrays in some places, so fix those places up as well. Fixes #41304.
2017-05-13Rollup merge of #41612 - mandeep:add-ops-generics, r=GuillaumeGomez,frewsxcvMark Simulacrum-0/+36
Added generic example of std::ops::Add in doc comments We discussed on IRC how the std::ops examples were potentially missing examples using generics. This PR adds an example to std::ops::Add that shows the use of a generic type T. I'm not sure this is ready for merge as I think the two examples now make the documentation a bit verbose, but I think it's a good starting point. I'd love to hear others thoughts on this. This is in relation to the last item in issue #29365.
2017-05-13libcore: #[allow] some unused macrosest31-0/+2
2017-05-13Auto merge of #41920 - arielb1:inline-drop, r=eddybbors-1/+0
remove the #[inline] attribute from drop_in_place Apparently LLVM has exponential code growth while inlining landing pads if that attribute is present. Fixes #41696. beta-nominating because regression. r? @eddyb
2017-05-12Rollup merge of #41934 - est31:remove_unused_macros, r=nagisaMark Simulacrum-31/+0
Remove unused macros from the codebase Thanks to the lint I've implemented in #41907 I've found some unused macros inside the rustc codebase.
2017-05-12Fix commit derp and update implementations and documentationIvan Dardi-3/+100
2017-05-12Remove some unused macros from the rust codebaseest31-31/+0
Removes unused macros from: * libcore * libcollections The last use of these two macros was removed in commit b64c9d56700e2c41207166fe8709711ff02488ff when the char_range_at_reverse function was been removed. * librustc_errors Their last use was removed by commits 2f2c3e178325dc1837badcd7573c2c0905fab979 and 11dc974a38fd533aa692cea213305056cd3a6902. * libsyntax_ext * librustc_trans Also, put the otry macro in back/msvc/mod.rs under the same cfg argument as the places that use it.
2017-05-11remove the #[inline] attribute from drop_in_placeAriel Ben-Yehuda-1/+0
Apparently LLVM has exponential code growth while inlining landing pads if that attribute is present. Fixes #41696.
2017-05-11Fix typo in size_hint example commentMartin Glagla-1/+1
2017-05-11Added generic example of std::ops::Add in doc commentsmandeep-0/+36
Added blank lines around example Added comment to Add example referencing the Output type Removed whitespace from lines 272 and 273 Removed Debug derivation from Add examples Added Debug derivation
2017-05-10fix typo in Unique::empty docRalf Jung-1/+1
2017-05-10Auto merge of #41764 - scottmcm:faster-reverse, r=brsonbors-0/+49
Make [u8]::reverse() 5x faster Since LLVM doesn't vectorize the loop for us, do unaligned reads of a larger type and use LLVM's bswap intrinsic to do the reversing of the actual bytes. cfg!-restricted to x86 and x86_64, as I assume it wouldn't help on things like ARMv5. Also makes [u16]::reverse() a more modest 1.5x faster by loading/storing u32 and swapping the u16s with ROT16. Thank you ptr::*_unaligned for making this easy :) Benchmark results (from my i5-2500K): ```text # Before test slice::reverse_u8 ... bench: 273,836 ns/iter (+/- 15,592) = 3829 MB/s test slice::reverse_u16 ... bench: 139,793 ns/iter (+/- 17,748) = 7500 MB/s test slice::reverse_u32 ... bench: 74,997 ns/iter (+/- 5,130) = 13981 MB/s test slice::reverse_u64 ... bench: 47,452 ns/iter (+/- 2,213) = 22097 MB/s # After test slice::reverse_u8 ... bench: 52,170 ns/iter (+/- 3,962) = 20099 MB/s test slice::reverse_u16 ... bench: 93,330 ns/iter (+/- 4,412) = 11235 MB/s test slice::reverse_u32 ... bench: 74,731 ns/iter (+/- 1,425) = 14031 MB/s test slice::reverse_u64 ... bench: 47,556 ns/iter (+/- 3,025) = 22049 MB/s ``` If you're curious about the assembly, instead of doing this ``` movzx eax, byte ptr [rdi] movzx ecx, byte ptr [rsi] mov byte ptr [rdi], cl mov byte ptr [rsi], al ``` it does this ``` mov rax, qword ptr [rdx] mov rbx, qword ptr [r11 + rcx - 8] bswap rbx mov qword ptr [rdx], rbx bswap rax mov qword ptr [r11 + rcx - 8], rax ```
2017-05-09fix confusion about parts required for float formattingNathan Froyd-12/+12
The documentation for flt2dec doesn't match up with the actual implementation, so fix the documentation to align with reality. Presumably due to the mismatch, the formatting code for floats in std::fmt can use correspondingly shorter arrays in some places, so fix those places up as well. Fixes #41304.
2017-05-07fix nitDjzin-1/+1
2017-05-07improve wordingDjzin-2/+1
2017-05-07optimize out stack alignment for sizes < 32Djzin-5/+12
2017-05-05Improve implementation approach comments in [T]::reverse()Scott McMurray-4/+15
2017-05-05Rollup merge of #41064 - Gankro:ptr-redux, r=alexcrichtonCorey Farwell-62/+138
refactor NonZero, Shared, and Unique APIs Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `ptr` getter to Shared/Unique to replace Deref impl * Added Unique's `get` and `get_mut` conveniences to Shared * Deprecated `as_mut_ptr` on Shared in favour of `ptr` Note that Shared used to primarily expose only `*const` but there isn't a good justification for that, so I made it `*mut`.
2017-05-04fallout from NonZero/Unique/Shared changesAlexis Beingessner-9/+7
2017-05-04Make [u8]::reverse() 5x fasterScott McMurray-0/+38
Since LLVM doesn't vectorize the loop for us, do unaligned reads of a larger type and use LLVM's bswap intrinsic to do the reversing of the actual bytes. cfg!-restricted to x86 and x86_64, as I assume it wouldn't help on things like ARMv5. Also makes [u16]::reverse() a more modest 1.5x faster by loading/storing u32 and swapping the u16s with ROT16. Thank you ptr::*_unaligned for making this easy :)
2017-05-04refactor NonZero, Shared, and Unique APIsAlexis Beingessner-53/+131
Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `as_ptr` to Shared/Unique to replace Deref impl * Added Unique's `as_ref` and `as_mut` conveniences to Shared * Added `::empty()` convenience constructor for Unique/Shared * Deprecated `as_mut_ptr` on Shared in favour of `as_ptr` * Improved documentation of types Note that Shared now only refers to *mut, and not *const
2017-05-04Simplify types in `std::option` doc comment example.Corey Farwell-6/+6
2017-05-02Rollup merge of #41217 - topecongiro:docs/atomic-fence, r=steveklabnikCorey Farwell-3/+52
Update docs of 'fence' This PR updates the docs for `std::sync::atomic::fence` with an example and a diagram. Part of #29377. r? @steveklabnik
2017-05-02Auto merge of #41207 - sstewartgallus:spinpause, r=alexcrichtonbors-0/+23
Spin loop pause function redux GitHub's interface is screwy. This is the same PR as https://github.com/rust-lang/rust/pull/40537
2017-05-02Address reviewest31-1/+1
2017-05-02Removal pass for anonymous parametersest31-5/+5
Removes occurences of anonymous parameters from the rustc codebase, as they are to be deprecated. See issue #41686 and RFC 1685.
2017-05-01Added spin loop pause functionSteven Stewart-Gallus-0/+23
2017-05-01Add an example for 'fence'topecongiro-3/+52
2017-04-30Auto merge of #41602 - hsivonen:explainnonnull, r=steveklabnikbors-3/+10
Explain why zero-length slices require a non-null pointer In reference to [a thread on Discourse](https://users.rust-lang.org/t/why-does-std-slice-from-raw-parts-require-a-non-null-pointer-for-zero-length-slices/10534), explain why `from_raw_parts` requires a non-null pointer for zero-length slices. r? @steveklabnik
2017-04-29Rollup merge of #41636 - moosingin3space:fix/process-exit-in-forget-doc, ↵Corey Farwell-1/+1
r=sfackler process:exit -> process::exit in mem::forget docs The documentation in mem::forget says "...or call `process:exit`..." instead of `process::exit`. r? @steveklabnik
2017-04-29Rollup merge of #41509 - froydnj:float-stack-reduction, r=nagisaCorey Farwell-18/+104
reduce stack requirements for floating-point formatting Doing this speeds up float formatting by ~10% or so, and also makes the formatting code more suitable for embedded environments where stack space is at a premium.
2017-04-29Update stage0 bootstrap compilerAlex Crichton-102/+1
We've got a freshly minted beta compiler, let's update to use that on nightly! This has a few other changes associated with it as well * A bump to the rustc version number (to 1.19.0) * Movement of the `cargo` and `rls` submodules to their "proper" location in `src/tools/{cargo,rls}`. Now that Cargo workspaces support the `exclude` option this can work. * Updates of the `cargo` and `rls` submodules to their master branches. * Tweak to the `src/stage0.txt` format to be more amenable for Cargo version numbers. On the beta channel Cargo will bootstrap from a different version than rustc (e.g. the version numbers are different), so we need different configuration for this. * Addition of `dev` as a readable key in the `src/stage0.txt` format. If present then stage0 compilers are downloaded from `dev-static.rust-lang.org` instead of `static.rust-lang.org`. This is added to accomodate our updated release process with Travis and AppVeyor.
2017-04-29process:exit -> process::exit in mem::forget docsNathan Moos-1/+1
The documentation in mem::forget says "...or call `process:exit`..." instead of `process::exit`. r? @steveklabnik
2017-04-29Simplify `checked_next_power_of_two` functionIrfan Hudda-6/+1
2017-04-28fmt: use mem::uninitialized for float formatting buffersNathan Froyd-22/+34
Spending time to initialize these is just wasted work, as we'll overwrite them soon anyway. Fixes #41259.
2017-04-28fmt: use the minimum parts array sizeNathan Froyd-4/+4
The comments for flt2dec::to_shortest_str says that we only need a slice of length 5 for the parts array. Initializing a 16-part array is just wasted effort and wasted stack space. Other functions in the flt2dec module have similar comments, so we adjust the parts arrays passed to those functions accordingly.
2017-04-28fmt: reduce the stack space required by float formattingNathan Froyd-16/+66
For the two major entry points for float formatting, we split the exact case and the shortest cases into separate functions. We mark the separate functions as #[inline(never) so the exact cases won't bloat stack space in their callers unnecessarily. The shortest cases are marked so for similar reasons. Fixes #41234.
2017-04-28num: add minimal benchmarks for full floating-point formattingNathan Froyd-0/+24
We have benchmarks for the floating-point formatting algorithms themselves, but not for the surrounding machinery like Formatter and translating to the flt2dec::Part slices.
2017-04-29Add comment about overflow behavior for next_power_of_twoIrfan Hudda-0/+3
2017-04-28Add helper functions for `next_power_of_two` and `checked_next_power_of_two`Irfan Hudda-10/+14
2017-04-28Explain why zero-length slices require a non-null pointerHenri Sivonen-3/+10
2017-04-26Rollup merge of #41493 - scottmcm:fix-step-replace, r=sfacklerAriel Ben-Yehuda-6/+46
Step::replace_one should put a one, not a zero (Issue #41492) Turns out all six of the replace_* impls were backwards.
2017-04-25Rollup merge of #41528 - steveklabnik:gh33269, r=frewsxcvCorey Farwell-2/+3
Clarify "side effect" in peek's docs Fixes #33269 /cc @tshepang
2017-04-25Clarify "side effect" in peek's docssteveklabnik-2/+3
Fixes #33269