about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-04-15Deprecate the asm! macroAmanieu d'Antras-3/+8
2020-04-15Update stdarch submodule to use llvm_asm! instead of asm!Amanieu d'Antras-0/+4
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-7/+7
2020-04-14Rollup merge of #71133 - MiSawa:fix-sort-by-key-doc, r=Dylan-DPCDylan DPC-1/+1
Tighten time complexity on the doc of sort_by_key Fixes #71132
2020-04-14Rollup merge of #71082 - NeoRaider:ptr_slice_len, r=oli-obk,SimonSapinDylan DPC-0/+56
ptr: introduce len() method on raw slices It is already possible to extract the pointer part of a raw slice by a simple cast, but retrieving the length is not possible without relying on the representation of the raw slice when it is not valid to convert the raw slice into a slice reference (i.e. the pointer is null or unaligned). ~Introduce a new function ptr::slice_len() to add this missing feature.~ Introduce a len() method on raw slices to add this missing feature.
2020-04-14ptr: add tracking issue for len() method on raw slicesMatthias Schiffer-4/+4
2020-04-14ptr: introduce len() method on raw slicesMatthias Schiffer-2/+50
It is already possible to extract the pointer part of a raw slice by a simple cast, but retrieving the length is not possible without relying on the representation of the raw slice when it is not valid to convert the raw slice into a slice reference (i.e. the pointer is null or unaligned). Introduce a len() method on raw slices to add this missing feature.
2020-04-14ptr: implement "const_slice_ptr" and "mut_slice_ptr" lang itemsMatthias Schiffer-0/+8
2020-04-14Tighten time complexity on the docmi_sawa-1/+1
2020-04-13Remove the last remnant of unsigned NegJosh Stone-17/+4
It's been gone since #23945, before Rust 1.0. The former wrapping semantics have also been available as inherent methods for a long time now. There's no reason to keep this unused macro around.
2020-04-13Add examples to Pattern docsIvan Tham-0/+26
2020-04-13Add period to Pattern docsIvan Tham-5/+5
2020-04-12Document unsafety in `src/libcore/hash/sip.rs`LeSeulArtichaut-3/+8
2020-04-11Document unsafety in `src/libcore/hash/mod.rs`LeSeulArtichaut-2/+7
2020-04-11Document unsafety in `core::option`LeSeulArtichaut-2/+6
2020-04-11Store UNICODE_VERSION as a tuplePyfisch-30/+5
Remove the UnicodeVersion struct containing major, minor and update fields and replace it with a 3-tuple containing the version number. As the value of each field is limited to 255 use u8 to store them.
2020-04-10Added comments.Rakshith Ravi-21/+16
Removed unnecessarry empty impls. Moved code to organise it better
2020-04-09Rollup merge of #70896 - cuviper:optional-chain, r=scottmcmMazdak Farrokhzad-154/+113
Implement Chain with Option fuses The iterators are now "fused" with `Option` so we don't need separate state to track which part is already exhausted, and we may also get niche layout for `None`. We don't use the real `Fuse` adapter because its specialization for `FusedIterator` unconditionally descends into the iterator, and that could be expensive to keep revisiting stuff like nested chains. It also hurts compiler performance to add more iterator layers to `Chain`. This change was inspired by the [proposal](https://internals.rust-lang.org/t/proposal-implement-iter-chain-using-fuse/12006) on the internals forum. This is an alternate to #70332, directly employing some of the same `Fuse` optimizations as #70366 and #70750. r? @scottmcm
2020-04-08Adjust Step::forward_checked docs for large typesCAD97-12/+7
Co-Authored-By: Nadrieril Feneanar <nadrieril@users.noreply.github.com>
2020-04-08Redesign the Step traitCAD97-201/+539
2020-04-08Add inherent impls for unchecked math intrinsicsCAD97-0/+102
2020-04-08Stabilize some of alloc_layout_extrasCAD97-14/+11
2020-04-08Added FuseIteratorImpl, FustDoubleEndedIteratorImpl and ↵Rakshith Ravi-79/+250
FuseExactSizeIteratorImpl to avoid exposing default functions outside of the current crate.
2020-04-07Avoid extra &mut in Chain::fold and try_foldJosh Stone-2/+2
2020-04-07Reduce callsites in Chain::last()Josh Stone-11/+10
2020-04-07Reduce callsites in Chain::count()Josh Stone-6/+9
2020-04-07Implement Chain with Option fusesJosh Stone-149/+106
The iterators are now "fused" with `Option` so we don't need separate state to track which part is already exhausted, and we may also get niche layout for `None`. We don't use the real `Fuse` adapter because its specialization for `FusedIterator` unconditionally descends into the iterator, and that could be expensive to keep revisiting stuff like nested chains. It also hurts compiler performance to add more iterator layers to `Chain`.
2020-04-06Use integer assoc consts in libcoreLinus Färnstrand-5/+5
2020-04-06Use assoc float consts in libcoreLinus Färnstrand-28/+18
2020-04-05Remove a stack frame from .await callsSteven Fackler-5/+2
2020-04-06Rollup merge of #70782 - faern:use-assoc-float-consts, r=dtolnayMazdak Farrokhzad-24/+4
Stop importing the float modules in documentation Follow up to #69860. I realized I had not searched for and fixed this for the float values. So with this PR they also use the associated constants instead of the module level constants. For the documentation where it also was using the `consts` submodule I opted to change it to import that directly. This becomes more in line with how other docs that use the `consts` submodule looks. And it also makes it so there are not two `f32` or `f64` things in the current namespace (both the module and the primitive type) and then hopefully confusing documentation readers less. r? @dtolnay
2020-04-06Rollup merge of #70750 - cuviper:direct-fuse, r=scottmcmMazdak Farrokhzad-74/+63
Match options directly in the Fuse implementation Rather than using `as_ref()`, `as_mut()`, and `?`, we can use `match` directly to save a lot of generated code. This was mentioned as a possibility in https://github.com/rust-lang/rust/pull/70366#issuecomment-603462546, and I found that it had a very large impact on #70332 using `Fuse` within `Chain`. Let's evaluate this change on its own first.
2020-04-05Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnayDylan DPC-39/+23
Don't import integer and float modules, use assoc consts Stop importing the standard library integer and float modules to reach the `MIN`, `MAX` and other constants. They are available directly on the primitive types now. This PR is a follow up of #69860 which made sure we use the new constants in documentation. This type of change touches a lot of files, and previously all my assoc int consts PRs had collisions and were accepted only after a long delay. So I'd prefer to do it in smaller steps now. Just removing these imports seem like a good next step. r? @dtolnay
2020-04-05Rollup merge of #70760 - PonasKovas:docs, r=Dylan-DPCDylan DPC-2/+4
docs: make the description of Result::map_or more clear The documentation of [`Result::map_or`](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or) is very unclear and confusing, probably because it was copied straight from [`Option::map_or`](https://doc.rust-lang.org/std/option/enum.Option.html#method.map_or) and someone forgot to adapt it for Result.
2020-04-05Make libcore float constant examples similar to libstdLinus Färnstrand-12/+4
2020-04-05Stop importing the float modules. Use assoc constsLinus Färnstrand-12/+0
2020-04-05Stop importing int/float modules in libcoreLinus Färnstrand-39/+23
2020-04-05Rollup merge of #70752 - yoshuawuyts:slice_fill, r=dtolnayDylan DPC-0/+24
Add slice::fill Adds the `slice::fill` method to fill a slice with an item. This replaces manual for loops where items are copied one-by-one. This is a counterpart to C++20's [`std::fill`](https://en.cppreference.com/w/cpp/algorithm/fill) function. ## Usage ```rust let mut buf = vec![0; 10]; buf.fill(1); assert_eq!(buf, vec![1; 10]); ``` ## Performance When compiling in release mode, for `[u8]` and `[u16]` this method will optimize to a `memset(3)` call ([godbolt](https://godbolt.org/z/85El_c)). The initial implementation relies on LLVM's optimizer to make it as fast as possible for any given input. But as @jonas-schievink [pointed out](https://twitter.com/sheevink/status/1245756597453885442) this can later be optimized through specialization to guarantee it has a specific performance profile. ## Why now? Conversations about adding `slice::fill` are not new. In fact, https://github.com/rust-lang/rfcs/issues/2067 was opened 3 years ago about this exact topic. However discussion stranded while discussing implementation details, and it's not seen much forward motion since. In ["The Hunt for the Fastest Zero"](https://travisdowns.github.io/blog/2020/01/20/zero.html) Travis Downs provides disects C++'s `std::fill` performance profile on gcc, comparing it among others to `memset(3)`. Even though `memset(3)` outperforms `std::fill` in their tests, the author notes the following: > That the optimization fails, perhaps unexpectedly, in some cases is unfortunate but it’s nice that you can fix it yourself. [...] Do we throw out modern C++ idioms, at least where performance matters, for example by replacing std::fill with memset? I don’t think so. Much of the article focuses on how how to fix the performance of `std::fill` by providing specializations for specific input. In Rust we don't have any dedicated methods to fill slices with values, so it either needs to be optimized at the MIR layer, or more likely rely on LLVM's optimizer. By adding a dedicated method for filling slices with values it opens up the ability for us to in the future guarantee that e.g. `Vec<u8>` will always optimize to `memset` even in debug mode. Or perhaps provide stronger guarantees about memory when zeroing values when a certain flag is passed. But regardless of that, it improves general ergonomics of working with slices by providing a dedicated method with documentation and examples. ## References - [slice-fill prototype on docs.rs](https://docs.rs/slice-fill/1.0.1/slice_fill/) - [The Hunt For The Fastest Zero](https://travisdowns.github.io/blog/2020/01/20/zero.html) - [Safe memset for slices](https://github.com/rust-lang/rfcs/issues/2067) - [C++20 std::fill](https://en.cppreference.com/w/cpp/algorithm/fill) - [ASM output on Godbolt](https://godbolt.org/z/5-XU66)
2020-04-05Add slice::fillYoshua Wuyts-0/+24
2020-04-04docs: make the description of Result::map_or more clearPonas-2/+4
2020-04-03Rollup merge of #69860 - faern:use-assoc-int-consts, r=dtolnayMazdak Farrokhzad-29/+27
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of #67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
2020-04-03Use a macro to expand the specialized FuseJosh Stone-41/+23
2020-04-03Open-code Fuse's Option matchesJosh Stone-35/+42
2020-04-03Rollup merge of #70731 - JohnTitor:follow-up-rustc-middle, r=eddybDylan DPC-3/+6
Minor follow-up after renaming librustc(_middle) Fixes #70537 r? @Centril @eddyb
2020-04-03Rollup merge of #70728 - TimDiekmann:allocref-doc, r=AmanieuDylan DPC-19/+22
Minor doc improvements on `AllocRef` r? @Amanieu
2020-04-03Minor follow-up after renaming librustc(_middle)Yuki Okushi-3/+6
2020-04-03Replace float module consts with assoc consts in documentationLinus Färnstrand-11/+9
2020-04-03Replace max/min_value() with MAX/MIN assoc constsLinus Färnstrand-12/+12
2020-04-03Make documentation examples use new integer assoc constsLinus Färnstrand-6/+6
2020-04-03Update mod.rsTim Diekmann-1/+1