about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2022-03-01Temporarily make `CStr` not a link in the `c_char` docsJosh Triplett-2/+1
When CStr moves to core with an alias in std, this can link to `crate::ffi::CStr`. However, linking in the reverse direction (from core to std) requires a relative path, and that path can't work from both core::ffi and std::os::raw (different number of `../` traversals required).
2022-03-01Provide C FFI types via core::ffi, not just in stdJosh Triplett-165/+188
The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable.
2022-03-01Add a copy of cfg_if to core's internal_macros.rsJosh Triplett-0/+93
core can't depend on external crates the way std can. Rather than revert usage of cfg_if, add a copy of it to core. This does not export our copy, even unstably; such a change could occur in a later commit.
2022-03-01Rollup merge of #94452 - workingjubilee:sync-simd-bitmasks, r=workingjubileeDylan DPC-123/+438
Sync portable-simd for bitmasks &c. In the ideal case, where everything works easily and nothing has to be rearranged, it is as simple as: - `git subtree pull -P library/portable-simd https://github.com/rust-lang/portable-simd - ${branch}` - write the commit message - `python x.py test --stage 1` to make sure it runs - `git push` to your PR-to-rustc branch If anything borks up this flow, you can fix it with sufficient git wizardry but you are usually better off going back to the source, fixing it, and starting over, before you open the PR. r? `@calebzulawski`
2022-03-01Rollup merge of #94384 - cuviper:atomic-slice, r=dtolnayDylan DPC-0/+94
Add Atomic*::from_mut_slice Tracking issue #76314 for `from_mut` has a question about the possibility of `from_mut_slice`, and I found a real case for it. A user in the forum had a parallelism problem that could be solved by open-indexing updates to a vector of atomics, but they didn't want to affect the other code using that vector. Using `from_mut_slice`, they could borrow that data as atomics just long enough for their parallel loop. ref: https://users.rust-lang.org/t/sharing-vector-with-rayon-par-iter-correctly/72022
2022-03-01Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnayDylan DPC-11/+26
use BOOL for TCP_NODELAY setsockopt value on Windows This issue was found by the Wine project and mitigated there [^1]. Windows' setsockopt expects a BOOL (a typedef for int) for TCP_NODELAY [^2]. Windows itself is forgiving and will accept any positive optlen and interpret the first byte of *optval as the value, so this bug does not affect Windows itself, but does affect systems implementing Windows' interface more strictly, such as Wine. Wine was previously passing this through to the host's setsockopt, where, e.g., Linux requires that optlen be correct for the chosen option, and TCP_NODELAY expects an int. [^1]: https://source.winehq.org/git/wine.git/commit/d6ea38f32dfd3edbe107a255c37e9f7f3da06ae7 [^2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
2022-02-28Rollup merge of #92399 - Veeupup:fix_vec_typo, r=Dylan-DPCMatthias Krüger-4/+4
fix typo in btree/vec doc: Self -> self this pr fixes #92345 the documentation refers to the object the method is called for, not the type, so it should be using the lower case self.
2022-02-28Sync rust-lang/portable-simd@5f49d4c8435a25d804b2f375e949cb25479f5be9Jubilee Young-123/+438
2022-02-28Rollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-seMatthias Krüger-0/+137
Add `slice::{from_ptr_range, from_mut_ptr_range} ` Adds `slice::{from_ptr_range, from_mut_ptr_range}` as counterparts to `slice::{as_ptr_range, as_mut_ptr_range}`.
2022-02-27add `slice::{from_ptr_range, from_mut_ptr_range}`Ibraheem Ahmed-0/+137
2022-02-27Auto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obkbors-13/+37
For MIRI, cfg out the swap vectorization logic from 94212 Because of #69488 the swap logic from #94212 doesn't currently work in MIRI. Copying in smaller pieces is probably much worse for its performance anyway, so it'd probably rather just use the simple path regardless. Part of #94371, though another PR will be needed for the CTFE aspect. r? `@oli-obk` cc `@RalfJung`
2022-02-26For MIRI, cfg out the swap logic from 94212Scott McMurray-13/+37
2022-02-27Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrumbors-2/+2
Make TLS __getit #[inline(always)] on non-Windows This may improve perf, and/or stop `externs` perf benchmarks from being flaky. r? `@ghost`
2022-02-26Auto merge of #94385 - matthiaskrgr:rollup-4pwegqk, r=matthiaskrgrbors-6/+6
Rollup of 5 pull requests Successful merges: - #93603 (Populate liveness facts when calling `get_body_with_borrowck_facts` without `-Z polonius`) - #93870 (Fix switch on discriminant detection in a presence of coverage counters) - #94355 (Add one more case to avoid ICE) - #94363 (Remove needless borrows from core::fmt) - #94377 (`check_used` should only look at actual `used` attributes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-26Rollup merge of #94363 - aDotInTheVoid:fmt-needless-borrows, r=scottmcmMatthias Krüger-6/+6
Remove needless borrows from core::fmt
2022-02-25Auto merge of #94342 - ibraheemdev:swap-regression, r=Dylan-DPCbors-5/+11
Revert implementation of `slice::swap` Due to the perf regressions noticed here, possible due to inlining? https://github.com/rust-lang/rust/pull/88540#issuecomment-944344343 r? `@kennytm`
2022-02-25Add Atomic*::from_mut_sliceJosh Stone-0/+94
2022-02-25Make TLS __getit #[inline(always)] on non-WindowsErik Desjardins-2/+2
This may improve perf.
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-95/+25
Bump bootstrap to 1.60 This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25Remove needless borrows from core::fmtNixon Enraght-Moony-6/+6
2022-02-25Re-add track_caller to panic_no_unwind in bootstrapMark Rousskov-0/+3
This function was updated in a recent PR (92911) to be called without the caller information passed in, but the function signature itself was not altered with cfg_attr at the time.
2022-02-25Switch bootstrap cfgsMark Rousskov-95/+22
2022-02-25Fix SGX docs buildJethro Beekman-1/+1
2022-02-25Rollup merge of #94184 - ssomers:btree_tests, r=Dylan-DPCMatthias Krüger-138/+118
BTree: simplify test code Mostly, use `from` & `from_iter`.
2022-02-25Rollup merge of #92714 - yanganto:ignore-message, r=Mark-SimulacrumMatthias Krüger-2/+57
Provide ignore message in the result of test Provide ignore the message in the result of the test. This PR does not need RFC, because it is about the presentation of the report of `cargo test`. However, the following document listed here helps you to know about PR. - [RFC](https://github.com/rust-lang/rfcs/pull/3217) - [Rendered](https://github.com/yanganto/rfcs/blob/ignore-test-message/text/0000-ignore-test-message.md) - [Previous discussion on IRLO](https://internals.rust-lang.org/t/pre-rfc-provide-ignore-message-when-the-test-ignored/15904) If there is something improper, please let me know. Thanks.
2022-02-24revert implementation of `slice::swap`Ibraheem Ahmed-5/+11
2022-02-24Include ignore message in libtest outputAntonio Yang-2/+57
As an example: #[test] #[ignore = "not yet implemented"] fn test_ignored() { ... } Will now render as: running 2 tests test tests::test_ignored ... ignored, not yet implemented test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
2022-02-24Rollup merge of #94212 - scottmcm:swapper, r=dtolnayDylan DPC-97/+123
Stop manually SIMDing in `swap_nonoverlapping` Like I previously did for `reverse` (#90821), this leaves it to LLVM to pick how to vectorize it, since it can know better the chunk size to use, compared to the "32 bytes always" approach we currently have. A variety of codegen tests are included to confirm that the various cases are still being vectorized. It does still need logic to type-erase in some cases, though, as while LLVM is now smart enough to vectorize over slices of things like `[u8; 4]`, it fails to do so over slices of `[u8; 3]`. As a bonus, this change also means one no longer gets the spurious `memcpy`(s?) at the end up swapping a slice of `__m256`s: <https://rust.godbolt.org/z/joofr4v8Y> <details> <summary>ASM for this example</summary> ## Before (from godbolt) note the `push`/`pop`s and `memcpy` ```x86 swap_m256_slice: push r15 push r14 push r13 push r12 push rbx sub rsp, 32 cmp rsi, rcx jne .LBB0_6 mov r14, rsi shl r14, 5 je .LBB0_6 mov r15, rdx mov rbx, rdi xor eax, eax .LBB0_3: mov rcx, rax vmovaps ymm0, ymmword ptr [rbx + rax] vmovaps ymm1, ymmword ptr [r15 + rax] vmovaps ymmword ptr [rbx + rax], ymm1 vmovaps ymmword ptr [r15 + rax], ymm0 add rax, 32 add rcx, 64 cmp rcx, r14 jbe .LBB0_3 sub r14, rax jbe .LBB0_6 add rbx, rax add r15, rax mov r12, rsp mov r13, qword ptr [rip + memcpy@GOTPCREL] mov rdi, r12 mov rsi, rbx mov rdx, r14 vzeroupper call r13 mov rdi, rbx mov rsi, r15 mov rdx, r14 call r13 mov rdi, r15 mov rsi, r12 mov rdx, r14 call r13 .LBB0_6: add rsp, 32 pop rbx pop r12 pop r13 pop r14 pop r15 vzeroupper ret ``` ## After (from my machine) Note no `rsp` manipulation, sorry for different ASM syntax ```x86 swap_m256_slice: cmpq %r9, %rdx jne .LBB1_6 testq %rdx, %rdx je .LBB1_6 cmpq $1, %rdx jne .LBB1_7 xorl %r10d, %r10d jmp .LBB1_4 .LBB1_7: movq %rdx, %r9 andq $-2, %r9 movl $32, %eax xorl %r10d, %r10d .p2align 4, 0x90 .LBB1_8: vmovaps -32(%rcx,%rax), %ymm0 vmovaps -32(%r8,%rax), %ymm1 vmovaps %ymm1, -32(%rcx,%rax) vmovaps %ymm0, -32(%r8,%rax) vmovaps (%rcx,%rax), %ymm0 vmovaps (%r8,%rax), %ymm1 vmovaps %ymm1, (%rcx,%rax) vmovaps %ymm0, (%r8,%rax) addq $2, %r10 addq $64, %rax cmpq %r10, %r9 jne .LBB1_8 .LBB1_4: testb $1, %dl je .LBB1_6 shlq $5, %r10 vmovaps (%rcx,%r10), %ymm0 vmovaps (%r8,%r10), %ymm1 vmovaps %ymm1, (%rcx,%r10) vmovaps %ymm0, (%r8,%r10) .LBB1_6: vzeroupper retq ``` </details> This does all its copying operations as either the original type or as `MaybeUninit`s, so as far as I know there should be no potential abstract machine issues with reading padding bytes as integers. <details> <summary>Perf is essentially unchanged</summary> Though perhaps with more target features this would help more, if it could pick bigger chunks ## Before ``` running 10 tests test slice::swap_with_slice_4x_usize_30 ... bench: 894 ns/iter (+/- 11) test slice::swap_with_slice_4x_usize_3000 ... bench: 99,476 ns/iter (+/- 2,784) test slice::swap_with_slice_5x_usize_30 ... bench: 1,257 ns/iter (+/- 7) test slice::swap_with_slice_5x_usize_3000 ... bench: 139,922 ns/iter (+/- 959) test slice::swap_with_slice_rgb_30 ... bench: 328 ns/iter (+/- 27) test slice::swap_with_slice_rgb_3000 ... bench: 16,215 ns/iter (+/- 176) test slice::swap_with_slice_u8_30 ... bench: 312 ns/iter (+/- 9) test slice::swap_with_slice_u8_3000 ... bench: 5,401 ns/iter (+/- 123) test slice::swap_with_slice_usize_30 ... bench: 368 ns/iter (+/- 3) test slice::swap_with_slice_usize_3000 ... bench: 28,472 ns/iter (+/- 3,913) ``` ## After ``` running 10 tests test slice::swap_with_slice_4x_usize_30 ... bench: 868 ns/iter (+/- 36) test slice::swap_with_slice_4x_usize_3000 ... bench: 99,642 ns/iter (+/- 1,507) test slice::swap_with_slice_5x_usize_30 ... bench: 1,194 ns/iter (+/- 11) test slice::swap_with_slice_5x_usize_3000 ... bench: 139,761 ns/iter (+/- 5,018) test slice::swap_with_slice_rgb_30 ... bench: 324 ns/iter (+/- 6) test slice::swap_with_slice_rgb_3000 ... bench: 15,962 ns/iter (+/- 287) test slice::swap_with_slice_u8_30 ... bench: 281 ns/iter (+/- 5) test slice::swap_with_slice_u8_3000 ... bench: 5,324 ns/iter (+/- 40) test slice::swap_with_slice_usize_30 ... bench: 275 ns/iter (+/- 5) test slice::swap_with_slice_usize_3000 ... bench: 28,277 ns/iter (+/- 277) ``` </detail>
2022-02-24Rollup merge of #94300 - WaffleLapkin:patch-4, r=scottmcmMatthias Krüger-1/+1
Fix a typo in documentation of `array::IntoIter::new_unchecked` 🌸
2022-02-24Rollup merge of #94283 - hellow554:stable_flow_control, r=Dylan-DPCMatthias Krüger-2/+0
remove feature gate in control_flow examples Stabilization was done in https://github.com/rust-lang/rust/pull/91091, but the two examples weren't updated accordingly. Probably too late to put it into stable, but it should be in the next release :)
2022-02-24Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplettMatthias Krüger-0/+13
add matching doc to errorkind Rework of #90706
2022-02-24word wrpaDylan DPC-5/+5
2022-02-24word wrpaDylan DPC-6/+9
2022-02-23Update library/std/src/io/error.rsDylan DPC-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-02-23Fix a typo in documentation of `array::IntoIter::new_unchecked`Waffle Maybe-1/+1
2022-02-23Rollup merge of #94264 - NyantasticUwU:patch-1, r=yaahcMatthias Krüger-1/+1
Fix typo. Yeah just a typo (probably some breaking changes in here be careful) :)
2022-02-23Rollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnrMatthias Krüger-1/+1
Suggest calling .display() on `PathBuf` too Fixes #94210
2022-02-23Rollup merge of #94128 - mqy:master, r=Dylan-DPCMatthias Krüger-3/+3
rustdoc: several minor fixes ``@rustbot`` label A-docs
2022-02-23remove feature gate in control_flow examplesMarcel Hellwig-2/+0
2022-02-23add some more summary from pr discussionDylan DPC-1/+1
2022-02-23add some more summary from pr discussionDylan DPC-2/+4
2022-02-23add matching to errorkindDylan DPC-0/+8
2022-02-22Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitorbors-5/+4
Fix a layout possible miscalculation in `alloc::RawVec` A layout miscalculation could happen in `RawVec` when used with a type whose size isn't a multiple of its alignment. I don't know if such type can exist in Rust, but the Layout API provides ways to manipulate such types. Anyway, it is better to calculate memory size in a consistent way.
2022-02-22Fix typo.NyantasticUwU-1/+1
Yeah just a typo (probably some breaking changes in here be careful) :)
2022-02-22Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytmMatthias Krüger-4/+1
solarish current_exe using libc call directly
2022-02-21Suggest calling .display() on PathBuf tooMichael Goulet-1/+1
2022-02-21Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=AmanieuMatthias Krüger-0/+1
Correctly handle miniz_oxide extern crate declaration Fixes https://github.com/rust-lang/rust/issues/94219. Follow-up of https://github.com/rust-lang/rust/pull/94122. The `miniz_oxide` dependency is optional and therefore should allow be "imported" when it makes sense. r? `@ivmarkov`
2022-02-21Rollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-seMatthias Krüger-2/+2
Update pin_static_ref stabilization version. #93580 slipped into 1.61 cc `@m-ou-se`
2022-02-21Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomezMatthias Krüger-8/+18
Some improvements to the async docs The goal here is to make the docs overall a little bit more comprehensive and add more links between the things. One thing that's not working yet is the links to the keywords. Somehow I couldn't get them to work. r? ````@GuillaumeGomez```` do you know how I could get the keyword links to work?
2022-02-21Correctly handle miniz_oxide extern crate declarationGuillaume Gomez-0/+1