about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-04-03Minor doc improvements on `AllocRef`Tim Diekmann-19/+22
2020-04-03Rollup merge of #70708 - Pocakking:fix-ascii-case-conv-typo, r=sfacklerMazdak Farrokhzad-2/+2
Fix typo in u8::to_ascii_uppercase and u8::to_ascii_lowercase Corrects misspelling of fifth.
2020-04-03Rollup merge of #70700 - jrvidal:include-macro-paths, r=Dylan-DPCMazdak Farrokhzad-5/+11
Expand on platform details of `include_xxx` macros This is a small detail that is not explicitly mentioned, but it left me scratching my head for a while until I looked into its implementation details. Maybe worth mentioning.
2020-04-03Rollup merge of #70691 - TimDiekmann:allocref-docs, r=RalfJungMazdak Farrokhzad-5/+7
Improve docs in `AllocRef` r? @RalfJung
2020-04-03Rollup merge of #70487 - Mark-Simulacrum:float-unchecked-casts, r=SimonSapinMazdak Farrokhzad-18/+29
Stabilize float::to_int_unchecked This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts. As such, I believe this also likely unblocks #10184 (our oldest I-unsound issue!), as once this rolls out to stable it would be far easier IMO to change the behavior of `as` to be safe by default. This does not stabilize the trait or the associated method, as they are deemed internal implementation details (and consumers should not, generally, want to expose them, as in practice all callers likely know statically/without generics what the return type is). Closes #67058
2020-04-02Fix typo in u8::to_ascii_uppercase and u8::to_ascii_lowercasePocakking-2/+2
fith => fifth
2020-04-02Expand on platform details of `include_xxx` macrosRoberto Vidal-5/+11
2020-04-02Rollup merge of #70281 - xfix:infallible-hash, r=dtolnayMazdak Farrokhzad-0/+8
Implement Hash for Infallible https://www.reddit.com/r/rust/comments/fmllgx/never_crate_stable_alternative_to/ lists not implementing `Hash` as a reason for the `never` crate. I see no reason not to implement `Hash` for `Infallible`, so might as well do it. No changes necessary for `!`, because `!` already implements `Hash` (see https://github.com/rust-lang/rust/pull/51404).
2020-04-02Improve docs in `AllocRef`Tim Diekmann-5/+7
2020-04-02Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieubors-1043/+906
Overhaul of the `AllocRef` trait to match allocator-wg's latest consens; Take 2 GitHub won't let me reopen #69889 so I make a new PR. In addition to #69889 this fixes the unsoundness of `RawVec::into_box` when using allocators supporting overallocating. Also it uses `MemoryBlock` in `AllocRef` to unify `_in_place` methods by passing `&mut MemoryBlock`. Additionally, `RawVec` now checks for `size_of::<T>()` again and ignore every ZST. The internal capacity of `RawVec` isn't used by ZSTs anymore, as `into_box` now requires a length to be specified. r? @Amanieu fixes rust-lang/wg-allocators#38 fixes rust-lang/wg-allocators#41 fixes rust-lang/wg-allocators#44 fixes rust-lang/wg-allocators#51
2020-04-01Rollup merge of #70081 - lcnr:issue68387, r=varkorDylan DPC-9/+9
add `unused_braces` lint Add the lint `unused_braces` which is warn by default. `unused_parens` is also extended and now checks anon consts. closes #68387 r? @varkor
2020-03-31fix internal lint falloutBastian Kauschke-9/+9
2020-03-31Rollup merge of #70588 - Coder-256:str-split-at-docs, r=Dylan-DPCMazdak Farrokhzad-2/+2
Fix incorrect documentation for `str::{split_at, split_at_mut}` The documentation for each method currently states: > Panics if `mid` is not on a UTF-8 code point boundary, or if it is beyond the last code point of the string slice. However, this is not consistent with the real behavior, or that of the corresponding methods for `[T]` slices. A comment inside each of the `str` methods states: > is_char_boundary checks that the index is in [0, .len()] That is what I would expect the behavior to be, and in fact this seems to be the real behavior. For example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8e03dcc209d4dd176df2297523f9fee1)): ```rust fn main() { // Prints ("abc", "") and doesn't panic println!("{:?}", "abc".split_at(3)); } ``` In this case, I would interpret "the last code point of the string slice" to mean the byte at index 2 in UTF-8. However, it is possible to pass an index of 3, which is definitely "beyond the last code point of the string slice". I think that this is much clearer, but feel free to bikeshed.
2020-03-31Rollup merge of #69784 - benesch:fast-strip-prefix-suffix, r=kennytmMazdak Farrokhzad-30/+92
Optimize strip_prefix and strip_suffix with str patterns As mentioned in https://github.com/rust-lang/rust/issues/67302#issuecomment-585639226. I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? #56345 ---- Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
2020-03-30Fix incorrect documentation for `str::{split_at, split_at_mut}`Jacob Greenfield-2/+2
2020-03-30Optimize strip_prefix and strip_suffix with str patternsNikhil Benesch-30/+92
Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-1/+1
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-2/+2
2020-03-29Rollup merge of #70140 - Nemo157:result-flatten, r=AmanieuMazdak Farrokhzad-1/+33
Add Result<Result<T, E>, E>::flatten -> Result<T, E> This PR makes this possible (modulo type inference): ```rust assert_eq!(Ok(6), Ok(Ok(6)).flatten()); ``` Tracking issue: #70142 <sub>largely cribbed directly from <https://github.com/rust-lang/rust/pull/60256></sub>
2020-03-29Stabilize float::to_int_uncheckedMark Rousskov-18/+29
This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts.
2020-03-29Fix links for `AllocInit` methodsTim Diekmann-2/+2
2020-03-29Revert "Fix links for `AllocInit` methods"Tim Diekmann-2/+2
This reverts commit d241db2d4e620277ddb47dd26779982709f851d8.
2020-03-29Rollup merge of #70101 - tmiasko:intrinsics-copy, r=eddybMazdak Farrokhzad-112/+112
Add copy bound to atomic & numeric intrinsics
2020-03-29Auto merge of #70370 - petrochenkov:nosmatch, r=Centrilbors-2/+0
Remove attribute `#[structural_match]` and any references to it A small remaining part of https://github.com/rust-lang/rust/issues/63438.
2020-03-29Fix links for `AllocInit` methodsTim Diekmann-2/+2
2020-03-29Minor doc fixes in `AllocInit::init`Tim Diekmann-3/+3
2020-03-29Implement `init` and `init_offset` on `AllocInit` and mark it unsafeTim Diekmann-22/+31
2020-03-28Make fields in `MemoryBlock` publicTim Diekmann-43/+20
2020-03-28Rollup merge of #70486 - Mark-Simulacrum:unicode-shrink, r=dtolnayDylan DPC-539/+443
Shrink Unicode tables (even more) This shrinks the Unicode tables further, building upon the wins in #68232 (the previous counts differ due to an interim Unicode version update, see #69929. The new data structure is slower by around 3x, on the benchmark of looking up every Unicode scalar value in each data set sequentially in every data set included. Note that for ASCII, the exposed functions on `char` optimize with direct branches, so ASCII will retain the same performance regardless of internal optimizations (or the reverse). Also, note that the size reduction due to the skip list (from where the performance losses come) is around 40%, and, as a result, I believe the performance loss is acceptable, as the routines are still quite fast. Anywhere where this is hot, should probably be using a custom data structure anyway (e.g., a raw bitset) or something optimized for frequently seen values, etc. This PR updates both the bitset data structure, and introduces a new data structure similar to a skip list. For more details, see the [main.rs] of the table generator, which describes both. The commits mostly work individually and document size wins. As before, this is tested on all valid chars to have the same results as nightly (and the canonical Unicode data sets), happily, no bugs were found. [main.rs]: https://github.com/rust-lang/rust/blob/fb4a715e18b/src/tools/unicode-table-generator/src/main.rs Set | Previous | New | % of old | Codepoints | Ranges | ----------------|---------:|------:|-----------:|-----------:|-------:| Alphabetic | 3055 | 1599 | 52% | 132875 | 695 | Case Ignorable | 2136 | 949 | 44% | 2413 | 410 | Cased | 934 | 359 | 38% | 4286 | 141 | Cc | 43 | 9 | 20% | 65 | 2 | Grapheme Extend | 1774 | 813 | 46% | 1979 | 344 | Lowercase | 985 | 867 | 88% | 2344 | 652 | N | 1266 | 419 | 33% | 1781 | 133 | Uppercase | 934 | 777 | 83% | 1911 | 643 | White_Space | 140 | 37 | 26% | 25 | 10 | ----------------|----------|-------|------------|------------|--------| Total | 11267 | 5829 | 51% | - | - |
2020-03-27Remove separate encoding for a single nonzero-mapping byteMark Rousskov-15/+7
In practice, for the two data sets that still use the bitset encoding (uppercase and lowercase) this is not a significant win, so just drop it entirely. It costs us about 5 bytes, and the complexity is nontrivial.
2020-03-27Add skip list based implementation for smaller encodingMark Rousskov-777/+244
This arranges for the sparser sets (everything except lower and uppercase) to be encoded in a significantly smaller context. However, it is also a performance trade-off (roughly 3x slower than the bitset encoding). The 40% size reduction is deemed to be sufficiently important to merit this performance loss, particularly as it is unlikely that this code is hot anywhere (and if it is, paying the memory cost for a bitset that directly represents the data seems worthwhile). Alphabetic : 1599 bytes (- 937 bytes) Case_Ignorable : 949 bytes (- 822 bytes) Cased : 359 bytes (- 429 bytes) Cc : 9 bytes (- 15 bytes) Grapheme_Extend: 813 bytes (- 675 bytes) Lowercase : 863 bytes N : 419 bytes (- 619 bytes) Uppercase : 776 bytes White_Space : 37 bytes (- 46 bytes) Total table sizes: 5824 bytes (-3543 bytes)
2020-03-27Rollup merge of #65222 - Lucretiel:fold_self, r=kodrAusDylan DPC-16/+39
Proposal: `fold_self` and `try_fold_self` for Iterators This pull request proposes & implements two new methods on Iterators: `fold_self` and `try_fold_self`. These are variants of `fold` and `try_fold` that use the first element in the iterator as the initial accumulator. Let me know if a public feature like this requires an RFC, or if this pull request is sufficient as place for discussion.
2020-03-27remove unused importdylan_DPC-1/+0
2020-03-27simplify testdylan_DPC-4/+1
2020-03-26fix docsdylan_DPC-2/+5
2020-03-26Add fold_selfNathan West-16/+40
- Added `Iterator::fold_first`, which is like `fold`, but uses the first element in the iterator as the initial accumulator - Includes doc and doctest - Rebase commit; see #65222 for details Co-Authored-By: Tim Vermeulen <tvermeulen@me.com>
2020-03-26Mark `Layout::dangling` inlineTim Diekmann-0/+1
2020-03-26Apply suggestions from code reviewTim Diekmann-10/+11
Co-Authored-By: Amanieu d'Antras <amanieu@gmail.com>
2020-03-26Remove alignment from `MemoryBlock`Tim Diekmann-61/+104
2020-03-26Remove unused import from libcore/allocTim Diekmann-1/+1
2020-03-26Use `NonNull` instead of `Unique` in `MemoryBlock`Tim Diekmann-4/+3
2020-03-26Fix issues from review and unsoundness of `RawVec::into_box`Tim Diekmann-180/+137
2020-03-26Overhaul of the `AllocRef` trait to match allocator-wg's latest consensTim Diekmann-1043/+919
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-6/+48
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-26convert to doc commentsNiko Matsakis-4/+4
2020-03-26introduce `negative_impls` feature gate and documentNiko Matsakis-0/+1
They used to be covered by `optin_builtin_traits` but negative impls are now applicable to all traits, not just auto traits. This also adds docs in the unstable book for the current state of auto traits.
2020-03-26permit negative impls for non-auto traitsNiko Matsakis-0/+9
2020-03-25Rollup merge of #70366 - cuviper:option-fuse, r=dtolnayDylan DPC-255/+344
Implement Fuse with Option The former `done` flag was roughly similar to an `Option` tag, but left the possibity of misuse. By using a real `Option`, we can set `None` when the iterator is exhausted, removing any way to call it again. We also allow niche layout this way, so the `Fuse` may be smaller. The `FusedIterator` specialization does want to ignore the possibility of exhaustion though, so it uses `unsafe { intrinsics::unreachable() }` to optimize that branch away. The entire `Fuse` implementation is now isolated in its own module to contain that unsafety. r? @scottmcm
2020-03-25impl TrustedRandomAccess for Fuse without FusedIteratorJosh Stone-2/+6
2020-03-24Rollup merge of #70234 - anp:tracked-std-traits, r=AmanieuMazdak Farrokhzad-0/+10
#[track_caller] on core::ops::{Index, IndexMut}. Applies the attribute to `core::ops::Index(Mut)` and enough std internals to cover the [functions listed in "tier 1" in the original RFC](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md#survey-of-panicking-standard-functions). Split out from #69251 to allow separate assessment of perf impact. To my knowledge, this is the last piece of implementing RFC 2091. Tracking issue: https://github.com/rust-lang/rust/issues/47809