summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2021-07-22i sweat to godJane Lusby-1/+1
2021-07-22pls this timeJane Lusby-2/+2
2021-07-22rename assert_matches moduleJane Lusby-1/+1
2021-07-22Move [debug_]assert_matches to mod {core, std}::assert.Mara Bos-6/+21
2021-07-14Remove unsound TrustedRandomAccess implementationsFrank Steffahn-24/+1
Removes the implementations that depend on the user-definable trait `Copy`. Beta backport: Does not modify `vec::IntoIter`. (cherry picked from commit 28ea3582642e9b41c7e047e007f68cd7bf20ba45)
2021-06-19Revert #85176 addition of `clone_from` for `ManuallyDrop`Peter Todd-14/+1
Forwarding `clone_from` to the inner value changes the observable behavior, as previously the inner value would *not* be dropped by the default implementation.
2021-06-11Auto merge of #86204 - alexcrichton:wasm-simd-stable, r=Amanieubors-0/+1
std: Stabilize wasm simd intrinsics This commit performs two changes to stabilize Rust support for WebAssembly simd intrinsics: * The stdarch submodule is updated to pull in rust-lang/stdarch#1179. * The `wasm_target_feature` feature gate requirement for the `simd128` feature has been removed, stabilizing the name `simd128`. This should conclude the FCP started on #74372 and... Closes #74372
2021-06-10std: Stabilize wasm simd intrinsicsAlex Crichton-0/+1
This commit performs two changes to stabilize Rust support for WebAssembly simd intrinsics: * The stdarch submodule is updated to pull in rust-lang/stdarch#1179. * The `wasm_target_feature` feature gate requirement for the `simd128` feature has been removed, stabilizing the name `simd128`. This should conclude the FCP started on #74372 and... Closes #74372
2021-06-10Auto merge of #85630 - gilescope:to_digit_speedup3, r=nagisabors-15/+10
to_digit simplification (less jumps) I just realised we might be able to make use of the fact that changing case in ascii is easy to help simplify to_digit some more. It looks a bit cleaner and it looks like it's less jumps and there's less instructions in the generated assembly: https://godbolt.org/z/84Erh5dhz The benchmarks don't really tell me much. Maybe a slight improvement on the var radix. Before: ``` test char::methods::bench_to_digit_radix_10 ... bench: 53,819 ns/iter (+/- 8,314) test char::methods::bench_to_digit_radix_16 ... bench: 57,265 ns/iter (+/- 10,730) test char::methods::bench_to_digit_radix_2 ... bench: 55,077 ns/iter (+/- 5,431) test char::methods::bench_to_digit_radix_36 ... bench: 56,549 ns/iter (+/- 3,248) test char::methods::bench_to_digit_radix_var ... bench: 43,848 ns/iter (+/- 3,189) test char::methods::bench_to_digit_radix_10 ... bench: 51,707 ns/iter (+/- 10,946) test char::methods::bench_to_digit_radix_16 ... bench: 52,835 ns/iter (+/- 2,689) test char::methods::bench_to_digit_radix_2 ... bench: 51,012 ns/iter (+/- 2,746) test char::methods::bench_to_digit_radix_36 ... bench: 53,210 ns/iter (+/- 8,645) test char::methods::bench_to_digit_radix_var ... bench: 40,386 ns/iter (+/- 4,711) test char::methods::bench_to_digit_radix_10 ... bench: 54,088 ns/iter (+/- 5,677) test char::methods::bench_to_digit_radix_16 ... bench: 55,972 ns/iter (+/- 17,229) test char::methods::bench_to_digit_radix_2 ... bench: 52,083 ns/iter (+/- 2,425) test char::methods::bench_to_digit_radix_36 ... bench: 54,132 ns/iter (+/- 1,548) test char::methods::bench_to_digit_radix_var ... bench: 41,250 ns/iter (+/- 5,299) ``` After: ``` test char::methods::bench_to_digit_radix_10 ... bench: 48,907 ns/iter (+/- 19,449) test char::methods::bench_to_digit_radix_16 ... bench: 52,673 ns/iter (+/- 8,122) test char::methods::bench_to_digit_radix_2 ... bench: 48,509 ns/iter (+/- 2,885) test char::methods::bench_to_digit_radix_36 ... bench: 50,526 ns/iter (+/- 4,610) test char::methods::bench_to_digit_radix_var ... bench: 38,618 ns/iter (+/- 3,180) test char::methods::bench_to_digit_radix_10 ... bench: 54,202 ns/iter (+/- 6,994) test char::methods::bench_to_digit_radix_16 ... bench: 56,585 ns/iter (+/- 8,448) test char::methods::bench_to_digit_radix_2 ... bench: 50,548 ns/iter (+/- 1,674) test char::methods::bench_to_digit_radix_36 ... bench: 52,749 ns/iter (+/- 2,576) test char::methods::bench_to_digit_radix_var ... bench: 40,215 ns/iter (+/- 3,327) test char::methods::bench_to_digit_radix_10 ... bench: 50,233 ns/iter (+/- 22,272) test char::methods::bench_to_digit_radix_16 ... bench: 50,841 ns/iter (+/- 19,981) test char::methods::bench_to_digit_radix_2 ... bench: 50,386 ns/iter (+/- 4,555) test char::methods::bench_to_digit_radix_36 ... bench: 52,369 ns/iter (+/- 2,737) test char::methods::bench_to_digit_radix_var ... bench: 40,417 ns/iter (+/- 2,766) ``` I removed the likely as it resulted in a few less instructions. (It's not been in there long - I added it in the last to_digit iteration).
2021-06-10Further simplification of to_digitGiles Cope-15/+10
2021-06-10Rollup merge of #86111 - spookyvision:master, r=JohnTitorYuki Okushi-1/+1
fix off by one in `std::iter::Iterator` documentation the range `(0..10)` is documented as "The even numbers from zero to ten." - should be ".. to nine".
2021-06-09Auto merge of #86003 - pnkfelix:issue-84297-revert-81238, r=Mark-Simulacrumbors-164/+198
Make copy/copy_nonoverlapping fn's again Make copy/copy_nonoverlapping fn's again, rather than intrinsics. This a short-term change to address issue #84297. It effectively reverts PRs #81167 #81238 (and part of #82967), #83091, and parts of #79684.
2021-06-09Auto merge of #85975 - the8472:revert-take-tra, r=scottmcmbors-22/+1
Revert "implement TrustedRandomAccess for Take iterator adapter" This reverts commit 37a5b515e9c36ee3f57d9e0d7db7efce2fb02195 (#83990). The original change unintentionally caused side-effects from certain iterator chains combining `take`, `zip` and `next_back()` to be omitted which is observable by user code and thus likely a breaking change Technically one could declare it not a breaking change since `Zip`'s API contract is silent about about its backwards iteration behavior but on the other hand there is nothing in the stable Iterator API that could justify the currently observable behavior. And either way, this impact wasn't noticed or discussed in the original PR. Fixes #85969
2021-06-09Update library/core/src/iter/traits/iterator.rsAnatol Ulrich-1/+1
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-06-08Rollup merge of #86101 - glittershark:bound-as-mut-doc-fix, r=m-ou-seYuki Okushi-1/+1
Correct type signature in doc for Bound::as_mut Thanks to ``@drmason13`` for pointing this out!
2021-06-08Rollup merge of #85985 - Lionelf329:master, r=joshtriplettYuki Okushi-9/+15
Clarify documentation of slice sorting methods After reading about [this](https://polkadot.network/a-polkadot-postmortem-24-05-2021/), I realized that although the documentation of these methods is not ambiguous in its current state, it is very easy to read it and erroneously assume that their exact behaviour can be relied upon to be deterministic. Although the docs make no guarantees about which index is returned when there are multiple matches, being more explicit about when and how their determinism can be relied upon should help prevent people from making this mistake in the future. r? ``@steveklabnik``
2021-06-07Clarify documentation of slice sorting methodsLionel Foxcroft-9/+15
2021-06-07fix off by oneAnatol Ulrich-1/+1
2021-06-07Correct type signature in doc for Bound::as_mutGriffin Smith-1/+1
2021-06-06Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-seYuki Okushi-4/+4
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue #84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ```@m-ou-se```
2021-06-05Rollup merge of #83646 - glittershark:bound-map, r=m-ou-seGuillaume Gomez-1/+35
Add a map method to Bound Add a map method to std::ops::range::Bound, patterned off of the method of the same name on Option. Have left off creating a tracking issue initially, but as soon as I get the go-ahead from a reviewer I'll make that right away 😄
2021-06-05Add a map method to BoundGriffin Smith-1/+35
Add a map method to std::ops::range::Bound, patterned off of the method of the same name on Option
2021-06-05Auto merge of #85457 - jyn514:remove-doc-include, r=GuillaumeGomezbors-1/+0
Remove `doc(include)` This nightly feature is redundant now that `extended_key_value_attributes` is stable (https://github.com/rust-lang/rust/pull/83366). `@rust-lang/rustdoc` not sure if you think this needs FCP; there was already an FCP in #82539, but technically it was for deprecating, not removing the feature altogether. This should not be merged before #83366. cc `@petrochenkov`
2021-06-04Revert PRs 81238 and 82967 (which made copy and copy_nonoverlapping intrinsics).Felix S. Klock II-152/+192
This is to address issue 84297.
2021-06-04Revert effects of PRs 81167 and 83091.Felix S. Klock II-12/+6
This is preparation for reverting 81238 for short-term resolution of issue 84297.
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-1/+0
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-06-04Remove `doc(include)`Joshua Nelson-1/+0
2021-06-04Rollup merge of #85888 - steffahn:fix_internal_trustedrandomaccess_docs, ↵Yuki Okushi-1/+1
r=Mark-Simulacrum Fix typo in internal documentation for `TrustedRandomAccess` `next_back` is a method of DoubleEndedIterator, not Iterator.
2021-06-03Revert "implement TrustedRandomAccess for Take iterator adapter"The8472-22/+1
This reverts commit 37a5b515e9c36ee3f57d9e0d7db7efce2fb02195.
2021-06-03Rollup merge of #85877 - est31:intra_doc_links, r=jyn514Yuki Okushi-4/+4
Intra doc link-ify a reference to a function
2021-06-02Update expressions where we can use array's IntoIterator implementationMuhammad Mominul Huque-2/+2
2021-06-02Replace IntoIter::new with IntoIterator::into_iter in stdMuhammad Mominul Huque-2/+2
2021-06-02Auto merge of #85687 - m-ou-se:new-prelude, r=yaahcbors-7/+13
New prelude RFC: rust-lang/rfcs#3114 Tracking issue: https://github.com/rust-lang/rust/issues/85684
2021-06-01Fix typo in internal documentation for `TrustedRandomAccess`Frank Steffahn-1/+1
`next_back` is a method of DoubleEndedIterator, not Iterator.
2021-06-01Rollup merge of #85826 - jsha:npo, r=joshtriplettGuillaume Gomez-0/+2
Mention "null pointer optimization" in option docs. I had seen people discuss "null pointer optimization," but when I tried to find official documentation (using Google), the `std::option` page didn't show up, because it doesn't use that term. Hopefully adding the term will help others find it in the future.
2021-06-01Intra doc link-ify a reference to a functionest31-4/+4
2021-05-30Auto merge of #85754 - the8472:revert-83770, r=Mark-Simulacrumbors-4/+0
Revert "Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum" Due to a performance regression that didn't show up in the original perf run this reverts commit 9111b8ae9793f18179a1336417618fc07a9cac85 (#83770), reversing changes made to 9a700d2947f2d7f97a2c0dfca3117a8dcc255bdd. Since since is expected to have the inverse impact it should probably be rollup=never. r? `@Mark-Simulacrum`
2021-05-30Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrumbors-108/+381
Make `Step` trait safe to implement This PR makes a few modifications to the `Step` trait that I believe better position it for stabilization in the short term. In particular, 1. `unsafe trait TrustedStep` is introduced, indicating that the implementation of `Step` for a given type upholds all stated invariants (which have remained unchanged). This is gated behind a new `trusted_step` feature, as stabilization is realistically blocked on min_specialization. 2. The `Step` trait is internally specialized on the `TrustedStep` trait, which avoids a serious performance regression. 3. `TrustedLen` is implemented for `T: TrustedStep` as the latter's invariants subsume the former's. 4. The `Step` trait is no longer `unsafe`, as the invariants must not be relied upon by unsafe code (unless the type implements `TrustedStep`). 5. `TrustedStep` is implemented for all types that implement `Step` in the standard library and compiler. 6. The `step_trait_ext` feature is merged into the `step_trait` feature. I was unable to find any reasoning for the features being split; the `_unchecked` methods need not necessarily be stabilized at the same time, but I think it is useful to have them under the same feature flag. All existing implementations of `Step` will be broken, as it is not possible to `unsafe impl` a safe trait. Given this trait only exists on nightly, I feel this breakage is acceptable. The blanket `impl<T: Step> TrustedLen for T` will likely cause some minor breakage, but this should be covered by the equivalent impl for `TrustedStep`. Hopefully these changes are sufficient to place `Step` in decent position for stabilization, which would allow user-defined types to be used with `a..b` syntax.
2021-05-29Mention "null pointer optimization" in option docs.Jacob Hoffman-Andrews-0/+2
2021-05-28Add inherent unchecked_shl, unchecked_shr to integersltdk-12/+154
2021-05-27Rollup merge of #85730 - Smittyvb:iter-min-max-floats, r=m-ou-seGuillaume Gomez-2/+26
Mention workaround for floats in Iterator::{min, max} `Iterator::{min, max}` can't be used with iterators of floats due to NaN issues. This suggests a workaround in the documentation of those functions.
2021-05-27Revert "Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum"The8472-4/+0
Due to a performance regression that didn't show up in the original perf run this reverts commit 9111b8ae9793f18179a1336417618fc07a9cac85, reversing changes made to 9a700d2947f2d7f97a2c0dfca3117a8dcc255bdd.
2021-05-27Rollup merge of #85689 - m-ou-se:array-intoiter-3, r=estebankDylan DPC-34/+0
Remove Iterator #[rustc_on_unimplemented]s that no longer apply. Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust. Separated these from #85670, because we should discuss a potential new (clippy?) lint for these. Until Rust 1.52, `for _ in [1..3] {}` produced: ``` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> src/main.rs:2:14 | 2 | for _ in [1..3] {} | ^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` ``` But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`. This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it? cc ```@estebank``` ```@flip1995``` cc https://github.com/rust-lang/rust/issues/84513
2021-05-26don't use unneeded closureSmittyvb-1/+1
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2021-05-26don't use unneeded closureSmittyvb-1/+1
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2021-05-26Unify feature flags as `step_trait`Jacob Pratt-6/+0
While stdlib implementations of the unchecked methods require unchecked math, there is no reason to gate it behind this for external users. The reasoning for a separate `step_trait_ext` feature is unclear, and as such has been merged as well.
2021-05-26Specialize implementationsJacob Pratt-105/+376
Implementations in stdlib are now optimized as they were before.
2021-05-26Mention float workaround in Iterator::{min,max}Smitty-2/+26
2021-05-26Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrumbors-0/+4
Add `TrustedRandomAccess` specialization for `Vec::extend()` This should do roughly the same as the `TrustedLen` specialization but result in less IR by using `__iterator_get_unchecked` instead of `Iterator::for_each` Conflicting specializations are manually prioritized by grouping them under yet another helper trait.
2021-05-26Rollup merge of #85712 - BlackHoleFox:fix-iter-typo, r=jyn514Dylan DPC-1/+1
Fix typo in core::array::IntoIter comment Saw a small typo reading some internal comments and decided to just throw this up to fix it for future readers.