summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2022-01-05Remove portable_simdMark Rousskov-23/+0
Stand-in for a backport of "Sync portable-simd to remove autosplats #91484".
2021-11-27Auto merge of #91269 - matthiaskrgr:rollup-jh8i8eh, r=matthiaskrgrbors-16/+17
Rollup of 7 pull requests Successful merges: - #90611 (Fix another ICE in rustdoc scrape_examples) - #91197 (rustdoc: Rename `Type::ResolvedPath` to `Type::Path` and don't re-export it) - #91223 (Fix headings indent) - #91240 (Saner formatting for UTF8_CHAR_WIDTH table) - #91248 (Bump compiler-builtins to 0.1.53) - #91252 (Fix bug where submodules wouldn't be updated when running x.py from a subdirectory) - #91259 (Remove `--display-doctest-warnings`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-26Auto merge of #91246 - nnethercote:faster-layout-array, r=dtolnaybors-4/+14
Faster `Layout::array` `Layout::array` is called (indirectly) by `Vec::push()`, which is typically instantiated many times, and so making it smaller can help with compile times because less LLVM IR is generated. r? `@ghost`
2021-11-26Optimize `Layout::array`.Nicholas Nethercote-3/+11
The current implementation is much more conservative than it needs to be, because it's dealing with the size and alignment of a given `T`, which are more restricted than an arbitrary `Layout`. For example, imagine a struct with a `u32` and a `u4`. You can safely create a `Layout { size_: 5, align_: 4 }` by hand, but `Layout::new::<T>` will give `Layout { size_: 8, align_: 4}`, where the size already has padding that accounts for the alignment. (And the existing `debug_assert_eq!` in `Layout::array` already demonstrates that no additional padding is required.)
2021-11-26Use unchecked construction in `Layout::pad_to_align`.Nicholas Nethercote-1/+3
Other, similar methods for `Layout` do likewise, and there's already an `unwrap()` around the result demonstrating the safety.
2021-11-25Saner formatting for UTF8_CHAR_WIDTH tableDavid Tolnay-16/+17
2021-11-25Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebankMatthias Krüger-0/+1
Print associated types on opaque `impl Trait` types This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future. before: ``` error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32` ``` after: ``` error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32` ``` --- Questions: 1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary? 2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later.. 3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back? 4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that? r? ````@estebank````
2021-11-24Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelidGuillaume Gomez-1/+2
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag. This is pretty much what it would look like (needs to update the tests too). The tracking issue is https://github.com/rust-lang/rust/issues/90418. What do you think ``@rust-lang/rustdoc`` ?
2021-11-24Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obkGuillaume Gomez-19/+24
Partially stabilize `duration_consts_2` Methods that were only blocked on `const_panic` have been stabilized. The remaining methods of `duration_consts_2` are all related to floats, and as such have been placed behind the `duration_consts_float` feature gate.
2021-11-24Create rustdoc_internals feature gateGuillaume Gomez-1/+2
2021-11-23Add generator lang-itemMichael Goulet-0/+1
2021-11-22Use `derive_default_enum` in the compilerJacob Pratt-0/+1
2021-11-22Partially stabilize `duration_consts_2`Jacob Pratt-19/+24
Methods that were only blocked on `const_panic` have been stabilized. The remaining methods of `duration_consts_2` are all related to floats, and as such have been placed behind the `duration_consts_float` feature gate.
2021-11-21libcore: assume the input of `next_code_point` and `next_code_point_reverse` ↵Eduardo Sánchez Muñoz-24/+34
is UTF-8-like The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0` `unwrap_or_0` was added in 42357d772b8a3a1ce4395deeac0a5cf1f66e951d. I guess `unwrap_unchecked` was not available back then. Given this example: ```rust pub fn first_char(s: &str) -> Option<char> { s.chars().next() } ``` Previously, the following assembly was produced: ```asm _ZN7example10first_char17ha056ddea6bafad1cE: .cfi_startproc test rsi, rsi je .LBB0_1 movzx edx, byte ptr [rdi] test dl, dl js .LBB0_3 mov eax, edx ret .LBB0_1: mov eax, 1114112 ret .LBB0_3: lea r8, [rdi + rsi] xor eax, eax mov r9, r8 cmp rsi, 1 je .LBB0_5 movzx eax, byte ptr [rdi + 1] add rdi, 2 and eax, 63 mov r9, rdi .LBB0_5: mov ecx, edx and ecx, 31 cmp dl, -33 jbe .LBB0_6 cmp r9, r8 je .LBB0_9 movzx esi, byte ptr [r9] add r9, 1 and esi, 63 shl eax, 6 or eax, esi cmp dl, -16 jb .LBB0_12 .LBB0_13: cmp r9, r8 je .LBB0_14 movzx edx, byte ptr [r9] and edx, 63 jmp .LBB0_16 .LBB0_6: shl ecx, 6 or eax, ecx ret .LBB0_9: xor esi, esi mov r9, r8 shl eax, 6 or eax, esi cmp dl, -16 jae .LBB0_13 .LBB0_12: shl ecx, 12 or eax, ecx ret .LBB0_14: xor edx, edx .LBB0_16: and ecx, 7 shl ecx, 18 shl eax, 6 or eax, ecx or eax, edx ret ``` After this change, the assembly is reduced to: ```asm _ZN7example10first_char17h4318683472f884ccE: .cfi_startproc test rsi, rsi je .LBB0_1 movzx ecx, byte ptr [rdi] test cl, cl js .LBB0_3 mov eax, ecx ret .LBB0_1: mov eax, 1114112 ret .LBB0_3: mov eax, ecx and eax, 31 movzx esi, byte ptr [rdi + 1] and esi, 63 cmp cl, -33 jbe .LBB0_4 movzx edx, byte ptr [rdi + 2] shl esi, 6 and edx, 63 or edx, esi cmp cl, -16 jb .LBB0_7 movzx ecx, byte ptr [rdi + 3] and eax, 7 shl eax, 18 shl edx, 6 and ecx, 63 or ecx, edx or eax, ecx ret .LBB0_4: shl eax, 6 or eax, esi ret .LBB0_7: shl eax, 12 or eax, edx ret ```
2021-11-21Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcmMatthias Krüger-0/+136
Adds IEEE 754-2019 minimun and maximum functions for f32/f64 IEEE 754-2019 removed the `minNum` (`min` in Rust) and `maxNum` (`max` in Rust) operations in favor of the newly created `minimum` and `maximum` operations due to their [non-associativity](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf) that cannot be fix in a backwards compatible manner. This PR adds `fN::{minimun,maximum}` functions following the new rules. ### IEEE 754-2019 Rules > **minimum(x, y)** is x if x < y, y if y < x, and a quiet NaN if either operand is a NaN, according to 6.2. For this operation, −0 compares less than +0. Otherwise (i.e., when x = y and signs are the same) it is either x or y. > **maximum(x, y)** is x if x > y, y if y > x, and a quiet NaN if either operand is a NaN, according to 6.2. For this operation, +0 compares greater than −0. Otherwise (i.e., when x = y and signs are the same) it is either x or y. "IEEE Standard for Floating-Point Arithmetic," in IEEE Std 754-2019 (Revision of IEEE 754-2008) , vol., no., pp.1-84, 22 July 2019, doi: 10.1109/IEEESTD.2019.8766229. ### Implementation This implementation is inspired by the one in [`glibc` ](https://github.com/bminor/glibc/blob/90f0ac10a74b2d43b5a65aab4be40565e359be43/math/s_fminimum_template.c) (it self derived from the C2X draft) expect that: - it doesn't use `copysign` because it's not available in `core` and also because `copysign` is unnecessary (we only want to check the sign, no need to create a new float) - it also prefer `other > self` instead of `self < other` like IEEE 754-2019 does I originally tried to implement them [using intrinsics](https://github.com/Urgau/rust/commit/1d8aa13bc39eeef1afba0524dc5ea10d073522e6) but LLVM [error out](https://godbolt.org/z/7sMrxW49a) when trying to lower them to machine intructions, GCC doesn't yet have built-ins for them, only cranelift support them nativelly (as it doesn't support the nativelly the old sementics). Helps with https://github.com/rust-lang/rust/issues/83984
2021-11-20Apply documentation suggestions from @est31Urgau-8/+8
Co-authored-by: est31 <est31@users.noreply.github.com>
2021-11-20Add similar note as LLVM does for minNum and maxNum functionsLoïc BRANSTETT-0/+12
2021-11-20Implement IEEE 754-2019 minimun and maximum functions for f32/f64Loïc BRANSTETT-0/+124
2021-11-20Rollup merge of #91044 - r00ster91:x1b, r=joshtriplettMatthias Krüger-20/+20
Turn all 0x1b_u8 into '\x1b' or b'\x1b' Supersedes #91040
2021-11-20Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514Matthias Krüger-5/+3
Makes docs for references a little less confusing - Make clear that the `Pointer` trait is related to formatting - Make clear that the `Pointer` trait is implemented for references (previously it was confusing to first see that it's implemented and then see it in "expect") - Make clear that `&T` (shared reference) implements `Send` (if `T: Send + Sync`)
2021-11-19Turn all 0x1b_u8 into '\x1b' or b'\x1b'r00ster91-20/+20
2021-11-19Remove unnecessary doc linksMaybe Waffle-2/+0
2021-11-19Rollup merge of #89258 - est31:const_char_convert, r=oli-obkYuki Okushi-15/+33
Make char conversion functions unstably const The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`. Tracking issue: https://github.com/rust-lang/rust/issues/89259
2021-11-18Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitorbors-21/+44
Rollup of 8 pull requests Successful merges: - #90386 (Add `-Zassert-incr-state` to assert state of incremental cache) - #90438 (Clean up mess for --show-coverage documentation) - #90480 (Mention `Vec::remove` in `Vec::swap_remove`'s docs) - #90607 (Make slice->str conversion and related functions `const`) - #90750 (rustdoc: Replace where-bounded Clean impl with simple function) - #90895 (require full validity when determining the discriminant of a value) - #90989 (Avoid suggesting literal formatting that turns into member access) - #91002 (rustc: Remove `#[rustc_synthetic]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-18Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplettbors-6/+6
std: Get the standard library compiling for wasm64 This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-11-18Fill in tracking issues for `const_str_from_utf8` and ↵Maybe Waffle-5/+5
`const_str_from_utf8_unchecked_mut` features
2021-11-18Make slice->str conversion and related functions constMaybe Waffle-21/+44
This commit makes the following functions from `core::str` `const fn`: - `from_utf8[_mut]` (`feature(const_str_from_utf8)`) - `from_utf8_unchecked_mut` (`feature(const_str_from_utf8_unchecked_mut)`) - `Utf8Error::{valid_up_to,error_len}` (`feature(const_str_from_utf8)`)
2021-11-17Rollup merge of #90687 - jhpratt:const_panic, r=oli-obkMatthias Krüger-2/+3
Permit const panics in stable const contexts in stdlib Without this change, it is not possible to use `panic!` and similar (including `assert!`) in stable const contexts inside of stdlib. See #89542 for a real-world case that currently fails for this reason. This does _not_ affect any user code. For example, this snippet currently fails to compile: ```rust #[stable(feature = "foo", since = "1.0.0")] #[rustc_const_stable(feature = "foo", since = "1.0.0")] const fn foo() { assert!(false); assert!(false, "foo"); } ``` With the addition of `#[rustc_const_unstable]` to `core::panicking::panic`, the error no longer occurs. This snippet has been added verbatim in this PR as a UI test. To avoid needing to add `#![feature(core_panic)]` to libcore, the two instances of direct calls to `core::panicking::panic` have been switched to use the `panic!` macro. I am requesting prioritization because this is holding up other stabilizations such as #89542 (which is otherwise ready to merge and succeeds with this change)
2021-11-16Fill in tracking issue for feature `const_align_offset`Maybe Waffle-2/+2
2021-11-16Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`Maybe Waffle-6/+36
2021-11-16Rollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubileeYuki Okushi-0/+2
disable portable SIMD tests in Miri Until https://github.com/rust-lang/miri/issues/1912 is resolved, we'll have to skip these tests in Miri.
2021-11-16Rollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplettYuki Okushi-68/+1
Remove bigint_helper_methods for *signed* types This PR inspired by `@cuviper's` comment @ https://github.com/rust-lang/rust/issues/90541#issuecomment-967309808 These are working well for *unsigned* types, so keep those, but for the the *signed* ones there are a bunch of questions about what the semantics and API should be. For the main "helpers for big integer implementations" use, there's no need for the signed versions anyway. There are plenty of other methods which exist for unsigned types but not signed ones, like `next_power_of_two`, so this isn't unusual. Fixes #90541 Tracking issue #85532
2021-11-15Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrumbors-91/+32
MIRI says `reverse` is UB, so replace it with something LLVM can vectorize For small types with padding, the current implementation is UB because it does integer operations on uninit values. ``` error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:836:5 | 836 | / uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678", 837 | | "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" } | |________________________________________________________________________________________________^ using uninitialized data, but this operation requires initialized memory | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: inside `core::num::<impl u32>::rotate_left` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:211:13 = note: inside `core::slice::<impl [Foo]>::reverse` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:701:58 ``` <https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=340739f22ca5b457e1da6f361768edc6> But LLVM has gotten smarter since I wrote the previous implementation in 2017, so this PR removes all the manual magic and just writes it in such a way that LLVM will vectorize. This code is much simpler and has very little `unsafe`, and is actually faster to boot! If you're curious to see the codegen: <https://rust.godbolt.org/z/Pcn13Y9E3> Before: ``` running 7 tests test slice::reverse_simd_f64x4 ... bench: 17,940 ns/iter (+/- 481) = 58448 MB/s test slice::reverse_u128 ... bench: 17,758 ns/iter (+/- 205) = 59048 MB/s test slice::reverse_u16 ... bench: 158,234 ns/iter (+/- 6,876) = 6626 MB/s test slice::reverse_u32 ... bench: 62,047 ns/iter (+/- 1,117) = 16899 MB/s test slice::reverse_u64 ... bench: 31,582 ns/iter (+/- 552) = 33201 MB/s test slice::reverse_u8 ... bench: 81,253 ns/iter (+/- 1,510) = 12905 MB/s test slice::reverse_u8x3 ... bench: 270,615 ns/iter (+/- 11,463) = 3874 MB/s ``` After: ``` running 7 tests test slice::reverse_simd_f64x4 ... bench: 17,731 ns/iter (+/- 306) = 59137 MB/s test slice::reverse_u128 ... bench: 17,919 ns/iter (+/- 239) = 58517 MB/s test slice::reverse_u16 ... bench: 43,160 ns/iter (+/- 607) = 24295 MB/s test slice::reverse_u32 ... bench: 21,065 ns/iter (+/- 371) = 49778 MB/s test slice::reverse_u64 ... bench: 21,118 ns/iter (+/- 482) = 49653 MB/s test slice::reverse_u8 ... bench: 76,878 ns/iter (+/- 1,688) = 13639 MB/s test slice::reverse_u8x3 ... bench: 264,723 ns/iter (+/- 5,544) = 3961 MB/s ``` Those are the existing benches, <https://github.com/rust-lang/rust/blob/14a2fd640e0df9ee8cc1e04280b0c3aff93c42da/library/alloc/benches/slice.rs#L322-L346>
2021-11-14disable portable SIMD tests in MiriRalf Jung-0/+2
2021-11-13Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obkbors-1/+1
Stabilize `const_raw_ptr_deref` for `*const T` This stabilizes dereferencing immutable raw pointers in const contexts. It does not stabilize `*mut T` dereferencing. This is behind the same feature gate as mutable references. closes https://github.com/rust-lang/rust/issues/51911
2021-11-13Auto merge of #90041 - jfrimmel:rt_copy_checks, r=Mark-Simulacrumbors-15/+47
Re-enable `copy[_nonoverlapping]()` debug-checks This commit re-enables the debug checks for valid usages of the two functions `copy()` and `copy_nonoverlapping()`. Those checks were commented out in #79684 in order to make the functions const. All that's been left was a FIXME, that could not be resolved until there is was way to only do the checks at runtime. Since #89247 there is such a way: `const_eval_select()`. This commit uses that new intrinsic in order to either do nothing (at compile time) or to do the old checks (at runtime). The change itself is rather small: in order to make the checks usable with `const_eval_select`, they are moved into a local function (one for `copy` and one for `copy_nonoverlapping` to keep symmetry). The change does not break referential transparency, as there is nothing you can do at compile time, which you cannot do on runtime without getting undefined behavior. The CTFE-engine won't allow missuses. The other way round is also fine. I've refactored the code to use `#[cfg(debug_assertions)]` on the new items. If that is not desired, the second commit can be dropped. I haven't added any checks, as I currently don't know, how to test this properly. Closes #90012. cc `@rust-lang/lang,` `@rust-lang/libs` and `@rust-lang/wg-const-eval` (as those teams are linked in the issue above).
2021-11-13Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrumbors-0/+21
pub use core::simd; A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use. `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available. `core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts. There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out. The major types are - `core::simd::Simd<T, N>` - `core::simd::Mask<T, N>` There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-12Remove bigint_helper_methods for *signed* typesScott McMurray-68/+1
These are working well for *unsigned* types, for the the signed ones there are a bunch of questions about what the semantics and API should be. And for the main "helpers for big integer implementations" use, there's no need for the signed versions anyway. And there are plenty of other methods which exist for unsigned types but not signed ones, like `next_power_of_two`, so this isn't unusual. Fixes 90541
2021-11-12Expose portable-simd as core::simdJubilee Young-0/+21
This enables programmers to use a safe alternative to the current `extern "platform-intrinsics"` API for writing portable SIMD code. This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12Rollup merge of #90798 - edmorley:doc-unreachable-custom-message, r=dtolnayMatthias Krüger-2/+5
Document `unreachable!` custom panic message The `unreachable!` docs previously did not mention that there was a second form, `unreachable!("message")` that could be used to specify a custom panic message, The docs now mention this feature in the same wording as currently used for `unimplemented!`: https://doc.rust-lang.org/core/macro.unimplemented.html#panics
2021-11-12Rollup merge of #90644 - est31:const_swap, r=Mark-SimulacrumMatthias Krüger-3/+6
Extend the const swap feature Adds the `const_swap` feature gate to three more swap functions. cc tracking issue #83163 ```Rust impl<T> [T] { pub const fn swap(&mut self, a: usize, b: usize); pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize); } impl<T: ?Sized> *mut T { pub const unsafe fn swap(self, with: *mut T); }
2021-11-11MIRI says `reverse` is UB, so replace it with an implementation that LLVM ↵Scott McMurray-91/+32
can vectorize For small types with padding, the current implementation is UB because it does integer operations on uninit values. But LLVM has gotten smarter since I wrote the previous implementation in 2017, so remove all the manual magic and just write it in such a way that LLVM will vectorize. This code is much simpler (albeit nuanced) and has very little `unsafe`, and is actually faster to boot!
2021-11-11Document `unreachable!()` custom panic messageEd Morley-2/+5
The `unreachable!` docs previously did not mention that there was a second form, `unreachable!("message")` that could be used to specify a custom panic message, The docs now mention this in the same style as currently used for `unimplemented!`: https://doc.rust-lang.org/core/macro.unimplemented.html#panics
2021-11-10Moar #[inline]Scott McMurray-0/+2
2021-11-10Use `target_family = "wasm"`Alex Crichton-12/+6
2021-11-10std: Get the standard library compiling for wasm64Alex Crichton-0/+6
This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-11-09Specialize array cloning for Copy typesScott McMurray-3/+22
Because after PR 86041, the optimizer no longer load-merges at the LLVM IR level, which might be part of the perf loss. (I'll run perf and see if this makes a difference.) Also I added a codegen test so this hopefully won't regress in future -- it passes on stable and with my change here, but not on the 2021-11-09 nightly.
2021-11-09Extend the const_swap featureest31-3/+6
This makes the inherent method ptr::swap unstably const, as well as slice::swap{,_unchecked}.
2021-11-09Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726bors-2/+20
Replace Copy/Clone compiler magic on arrays with library impls With const generics the compiler no longer needs to fake these impls.
2021-11-09Re-enable `copy[_nonoverlapping]()` runtime checksJulian Frimmel-15/+47
This commit re-enables the debug checks for valid usages of the two functions `copy()` and `copy_nonoverlapping()`. Those checks were com- mented out in #79684 in order to make the functions const. All that's been left was a FIXME, that could not be resolved until there is was way to only do the checks at runtime. Since #89247 there is such a way: `const_eval_select()`. This commit uses that new intrinsic in order to either do nothing (at compile time) or to do the old checks (at runtime). The change itself is rather small: in order to make the checks usable with `const_eval_select`, they are moved into a local function (one for `copy` and one for `copy_nonoverlapping` to keep symmetry). The change does not break referential transparency, as there is nothing you can do at compile time, which you cannot do on runtime without get- ting undefined behavior. The CTFE-engine won't allow missuses. The other way round is also fine.